How to input and process audio files to convert to text via pyspeech or dragonfly

六眼飞鱼酱① 提交于 2019-12-07 16:17:00

问题


I have seen the documentation of pyspeech and dragonfly, but don't know how to input an audio file to be converted into text. I have tried it with microphone via speaking to it and the speech is converted into text, but If I want to input a previously recorded audio file. Can anyone help with an example?


回答1:


Both PySpeech and Dragonfly are relatively thin wrappers over SAPI. Unfortunately, both of them use the shared recognizer, which doesn't support input selection. While I'm familiar with SAPI, I'm not that familiar with Python, so I haven't been able to assist anyone with moving PySpeech/Dragonfly over to an in-process recognizer.




回答2:


import speech_recognition as sr
print(sr.__version__)
r = sr.Recognizer()

audio_file = sr.AudioFile('audio_file.wav')

with audio_file as source:
   audio = r.record(source)

print(type(audio))
print(r.recognize_google(audio))


来源:https://stackoverflow.com/questions/12455069/how-to-input-and-process-audio-files-to-convert-to-text-via-pyspeech-or-dragonfl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!