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))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值