1,下载依赖包
pip install SpeechRecognition
pip install pyaudio
2,代码
import speech_recognition as sr r = sr.Recognizer() # 方案一: 用音频文件 with sr.AudioFile(r'22.wav') as source: audio = r.record(source) # # 方案一: 直接录音 # with sr.Microphone() as source: # audio = r.listen(source, 5) text = r.recognize_google(audio, language='zh-CN') print(text)标签:audio,install,text,source,语音,sr,pip,识别 From: https://www.cnblogs.com/147258llj/p/17850086.html