File size: 285 Bytes
438c749
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
import wave

def speech_rate(audio_path, text):
    with wave.open(audio_path, 'r') as f:
        frames = f.getnframes()
        rate = f.getframerate()
        duration = frames / float(rate)

    words = len(text.split())

    wpm = (words / duration) * 60

    return round(wpm, 2)