我想使应用程序,使字幕为视频我提取音频文件如下
import sys
from moviepy.video.tools.subtitles import SubtitlesClip
from moviepy.editor import *
video = VideoFileClip(sys.argv[1])
audio = video.audio
audio.write_audiofile()
我把它转换成文本,但我想记录的时间,使srt文件..我可以记录的时间,当有语音在音频文件或任何方式,使srt文件从音频文件,下面的代码是转换音频到文本
import speech_recognition as sr
AUDIO_FILE=("audi.wav")
r=sr.Recognizer()
with sr.AudioFile(AUDIO_FILE) as source:
audio=r.record(source)
# sr.recognize_api()
googletext = r.recognize_google(audio)
with open("audio5.txt","w") as f:
f.write(googletext)
with open("audio.srt","w") as f:
f.write(googletext)
1条答案
按热度按时间anauzrmj1#
稍后响应,但您可能会发现OpenAI的Whisper很有用。