-
-
Save amankharwal/12aaa65bcea780659720ab5c14078a92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import speech_recognition as sr | |
import moviepy.editor as mp | |
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip | |
num_seconds_video= 52*60 | |
print("The video is {} seconds".format(num_seconds_video)) | |
l=list(range(0,num_seconds_video+1,60)) | |
diz={} | |
for i in range(len(l)-1): | |
ffmpeg_extract_subclip("videorl.mp4", l[i]-2*(l[i]!=0), l[i+1], targetname="chunks/cut{}.mp4".format(i+1)) | |
clip = mp.VideoFileClip(r"chunks/cut{}.mp4".format(i+1)) | |
clip.audio.write_audiofile(r"converted/converted{}.wav".format(i+1)) | |
r = sr.Recognizer() | |
audio = sr.AudioFile("converted/converted{}.wav".format(i+1)) | |
with audio as source: | |
r.adjust_for_ambient_noise(source) | |
audio_file = r.record(source) | |
result = r.recognize_google(audio_file) | |
diz['chunk{}'.format(i+1)]=result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment