用 Python 转录音频文件

Nil*_*age 5 python speech-recognition speech-to-text

我正在尝试转录一个有点大的音频文件。它的属性如下。

Size : 278.3 MB
Duration : 52 minutes
Format : WAV
Run Code Online (Sandbox Code Playgroud)

以下是我用来将其转换为 60 秒持续时间的代码。你能建议立即转录这个文件吗?

import speech_recognition as sr

r = sr.Recognizer()
with sr.AudioFile('sampleMp3.WAV') as source:
    audio = r.record(source, duration=60) 

command = r.recognize_google(audio)

text_file = open("Output.txt", "w")
text_file.write(command)
text_file.close()
Run Code Online (Sandbox Code Playgroud)

Nik*_*rev 3

voice_recognition python 包只是一个包装器,它甚至不提供基本功能。

如果您想使用 Google Speech API(付费),您可以执行以下操作:

https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/speech/cloud-client/transcribe_async.py

如果您想考虑 Bing,它也提供类似的 API,请参阅如何使用 Python 中的 Bing Speech API 转录语音文件?

对于免费替代方案,请考虑https://github.com/alumae/kaldi-offline-transcriber