【问题标题】:How to get the speech from a video into a text file in text?如何将视频中的语音转换为文本文件?
【发布时间】:2022-08-24 14:18:13
【问题描述】:

谁能指导我如何将视频中的语音转换为文本文件?我试过了,但我收到了这个错误 - \"raise RequestError(\"recognition request failed: {}\".format(e.reason)) Speech_recognition.RequestError:识别请求失败:错误请求\”下面是我正在尝试的代码示例。

import moviepy.editor as mp
import speech_recognition as sr 


clip = mp.VideoFileClip(r\"sample1.mp4\")
clip.audio.write_audiofile(r\"Converted_audio.wav\")
print(\"Finished the convertion into audio...\")

audio = sr.AudioFile(\"Converted_audio.wav\")
print(\"Audio file readed...\")

r = sr.Recognizer()
with audio as source:
    audio_file = r.record(source)
    
result = r.recognize_google(audio_file)
with open(\'recognized.txt\',mode =\'w\') as file:
    file.write(result)

print(\"Wooh.. I did it...\")

    标签: python python-3.x speech-recognition speech-to-text moviepy


    【解决方案1】:

    尝试从拥抱面部转换器的语音到文本模型。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-05
      • 1970-01-01
      • 2011-09-25
      • 2014-09-02
      • 2018-05-24
      • 2010-10-04
      • 2018-04-30
      相关资源
      最近更新 更多