我尝试将语音转换为 WAV 文件,但我被困在这里。很多教程都给出了相同的代码,但它对我不起作用。这里是:
import speech_recognition as sr
r = sr.Recognizer()
with sr.AudioFile("hello_world.wav") as source:
audio = r.record(source)
try:
s = r.recognize_google(audio)
print("Text: "+s)
except Exception as e:
print("Exception: "+str(e))
“hello_world.wav”文件与代码位于同一目录中。我没有任何错误。控制台:
C:\Users\python.exe "D:/voice_recognition.py"
Exception:
Process finished with exit code 0
帮助?:)
(对不起,如果我的英语不好)