Answer the question
In order to leave comments, you need to log in
How to quickly recognize speech from an audio file?
There is a link with an audio file in mp3 format. At the moment, this functionality is implemented in the following way:
link = driver.find_element(By.XPATH, '/html/body/div/div/div[7]/a').get_attribute('href');
myfile = requests.get(link)
open('C:/Users/user/Desktop/unbot/audio.mp3', 'wb').write(myfile.content)
sound = AudioSegment.from_mp3("audio.mp3")
sound.export("file.wav", format="wav")
from os import path
AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "file.wav")
r = sr.Recognizer()
with sr.AudioFile(AUDIO_FILE) as source:
audio = r.record(source)
try:
print("Google Speech Recognition thinks you said " + r.recognize_google(audio))
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service; {0}".format(e))
Answer the question
In order to leave comments, you need to log in
If you want faster - make your own recognizer.
No one will give you this Klondike for free
I use offline speech recognition using the vosk library: https://github.com/alphacep/vosk-api
I think it will be much faster)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question