每当我尝试运行我的代码时,它都会说:[Errno 2] No such file or directory: 'speechtotext.wav'
,尽管我已将文件以正确的格式保存在计算机上。
这是我的代码:
import speech_recognition as sr
Audio_file= ("speechtotext.wav")
r=sr.Recognizer()
with sr.AudioFile(Audio_file) as source:
audio=r.record(source)
try:
print("audio file contains:" + r.recognize_google( audio))
except sr.UnknownValueError:
print("Google Speech Recognition could not understand")
except sr.RequestError:
print("couldn't get results from Google Speech Regonition")
谁能告诉我怎么了?我该如何解决?