转载请注明出处:小锋学长生活大爆炸[xfxuezhagn.cn]
如果本文帮助到了你,请不吝给个[点赞、收藏、关注]哦~
安装库:
pip install SpeechRecognition
使用方法:
import speech_recognition as sr
r = sr.Recognizer()
harvard = sr.AudioFile('harvard.wav')
with harvard as source:
r.adjust_for_ambient_noise(source, duration=0.5)
audio = r.record(source)
text = r.recognize_google(audio, language='zh-cn')
print(text)
完整教程可参考:
The Ultimate Guide To Speech Recognition With Python – Real PythonAn in-depth tutorial on speech recognition with Python. Learn which speech recognition library gives the best results and build a full-featured "Guess The Word" game with it.https://realpython.com/python-speech-recognition/