我最近试图学习如何转录音频文件,但我对python不太熟悉。在
我从下面的网站上读到了SpeechRecognition的例子
我尝试使用以下代码来使用它们:
但是,看起来我无法在windows计算机中导入我的文件。在
我想知道我的电脑里是否有一个带有路径的wav文件
“C:\Users\Chen\Downloads\英语.wav““
我试图用python代码中的“C:\Users\Chen\Downloads”替换文件。在
但它告诉我
FileNotFoundError:[Errno 2]没有这样的文件或目录:'C:\Users\Chen\英语.wav'
请帮我解决这些问题。在import speech_recognition as sr
# obtain path to "english.wav" in the same folder as this script
from os import path
AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "english.wav")
# use the audio file as the audio source
r = sr.Recognizer()
with sr.AudioFile(AUDIO_FILE) as source:
audio = r.record(source) # read the entire audio file
print("Google Speech Recognition thinks you said " + r.recognize_google(audio))