Spaces:
Sleeping
Sleeping
File size: 1,341 Bytes
168a18b 9a6e6ce 168a18b 9a6e6ce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import streamlit as st
import youtubetranscript
import youtubevideo
import transcriptFromWhisper
import sourcetoTarget
import textToSpeech
from pytube import YouTube
link = st.text_input("Youtube Link")
st.selectbox("Target Language", ["German"])
btnTranslate = st.button("Translate video")
if btnTranslate:
video = YouTube(link)
videoId = video.video_id
wasSuccessful = youtubetranscript.getTranscript(videoId)
if(wasSuccessful):
fname = video.video_id + ".mp4"
youtubevideo.Download(video, fname)
st.video(f"videos/{videoId}.mp4")
cols = st.columns(3)
cols[0].header(f'Original')
cols[1].header(f'Whisper')
cols[2].header(f'German')
file_path = f"transcripts/{videoId}.txt"
with open(file_path, 'r', encoding='utf8') as f:
cols[0].write(f.read())
transcriptFromWhisper.getWhisperTranscript(videoId)
file_path = f"whisper/{videoId}.txt"
with open(file_path, 'r') as f:
text = f.read()
text = text.replace("$","dollar")
print(text)
cols[1].write(text)
sourcetoTarget.englishToGerman(videoId)
file_path = f"translatedTranscripts/{videoId}.txt"
with open(file_path, 'r', encoding='utf8') as f:
cols[2].write(f.read())
textToSpeech.ttsSingleFile(videoId)
st.audio(f"tts/{videoId}.wav")
|