转载请注明出处:小锋学长生活大爆炸[xfxuezhagn.cn]
如果本文帮助到了你,请不吝给个[点赞、收藏、关注]哦~
安装库:
bash
pip install SpeechRecognition
使用方法:
python
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)
完整教程可参考: