python音频转文字speech recognition_演示如何使用SpeechRecognition转录音频文件

我最近试图学习如何转录音频文件,但我对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))


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部