Skip to content

Commit

Permalink
Prorgam to download Youtube Videos
Browse files Browse the repository at this point in the history
  • Loading branch information
sadock123 committed Oct 13, 2022
1 parent 0245c03 commit 7295f87
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
Binary file added speech_processing/2 To ask for a price.mp4
Binary file not shown.
Binary file not shown.
28 changes: 28 additions & 0 deletions speech_processing/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# IMPORTING LIBRARIES
import speech_recognition as sr
import moviepy.editor as mp
from deep_translator import GoogleTranslator

# VIDEO TO AUDIO CONVERSION
clip = mp.VideoFileClip(r'jjk.mkv')
clip.audio.write_audiofile(r'converted.wav')

# SPEECH RECOGNISION
r = sr.Recognizer()
audio = sr.AudioFile('converted.wav')
with audio as source:
audio_file = r.record(source)
print(1)
result = r.recognize_google(audio_file, None, "ja")
print(2)
# TRANSLATING THE TEXT TO ENGLISH
translated = GoogleTranslator(source='auto', target='english').translate(result)
print(3)

# EXPORTING THE RESULTS
with open('recognized.txt', mode ='w', encoding="utf-8") as file:
file.write("Recognized Speech:")
file.write("\n")
# file.write(result)
file.write(translated)
print("ready!")
2 changes: 2 additions & 0 deletions speech_processing/speech.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import wave

19 changes: 19 additions & 0 deletions speech_processing/youtube_downloader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import speech_recognition as sr
import moviepy.editor as mp
from pytube import YouTube

def download_360p_mp4_videos(url: str, outpath: str = "./"):

yt = YouTube(url)

yt.streams.filter(file_extension="mp4").get_by_resolution("360p").download(outpath)


if __name__ == "__main__":

download_360p_mp4_videos(
"https://www.youtube.com/watch?v=D702x_u0rts",
)
clip=mp.VideoFileClip(r"./spiderman.mp4")
clip.audio.write_audiofile(r'converted.wav')

0 comments on commit 7295f87

Please sign in to comment.