我正在尝试使用 转录大约 3 分钟长的音频文件SpeechRecognition
,但是,它似乎无法转录超过 20 秒的任何内容。这是我正在使用的代码:
r = sr.Recognizer()
audio = FLAC(output_name +'.' + output_format)
audio_length = audio.info.length
file = sr.AudioFile(output_name +'.' + output_format)
with file as source:
audio = r.record(source, duration = 20)
google = r.recognize_google(audio, language = 'ru-RU' )
print(google)
我怎样才能循环这个,以便它转录 0s - 20s,然后是 20s - 40s 等等,直到音频文件结束?
我希望尽可能避免将文件拆分为 20 秒长的单独文件。