tall-autumn-57974
09/25/2025, 6:25 AMtall-airline-16756
09/25/2025, 6:25 AMtall-airline-16756
09/25/2025, 6:26 AMtall-autumn-57974
09/25/2025, 6:27 AMtall-airline-16756
09/25/2025, 6:27 AMimport time
def calculate_speech_rate(transcription):
words = transcription['words']
if not words:
return 0
# Extract start and end times of the first and last words
start_time = words[0]['start']
end_time = words[-1]['end']
# Calculate duration in seconds
duration_sec = end_time - start_time
# Count the number of words
word_count = len(words)
# Calculate words per minute (WPM)
wpm = (word_count / duration_sec) * 60
return wpm
# Example transcription data from Deepgram
transcription = {
'words': [
{'start': 0.5, 'end': 1.0, 'word': 'Hello'},
{'start': 1.1, 'end': 1.5, 'word': 'world'},
{'start': 1.6, 'end': 2.0, 'word': 'example'}
]
}
# Calculate and print the speech rate
speech_rate = calculate_speech_rate(transcription)
print(f"Estimated speech rate: {speech_rate:.2f} words per minute")
This example works if you’re getting transcription data with word-level timing from Deepgram. If you happen to be using Azure STT, the idea is quite similar, but you’ll use start and end timestamps for the whole speech segment.
Please feel free to reach out if you’d like me to help with a customized example for Azure STT or if you have any other questions! I’m here to help.tall-autumn-57974
09/25/2025, 6:31 AMtall-airline-16756
09/25/2025, 6:31 AMis_final=True and speech_final=True to catch the end of a spoken segment and get the final transcription.
These events will give you the key information needed to calculate the speech rate. If you have any questions or need a hand with the implementation, please feel free to reach out—I’m here to help!