anzorq commited on
Commit
d562ee1
·
verified ·
1 Parent(s): 030116b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -38,12 +38,11 @@ def transcribe_from_youtube(url, progress=gr.Progress()):
38
  progress(0, "Downloading YouTube audio...")
39
  # Download audio from YouTube using pytube
40
  audio_path = YouTube(url).streams.filter(only_audio=True)[0].download(filename="tmp.mp4")
41
-
 
42
  transcription = transcribe_speech(audio_path)
43
-
44
- os.remove(audio_path)
45
 
46
- return transcription
47
 
48
  def populate_metadata(url):
49
  yt = YouTube(url)
@@ -81,8 +80,9 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
81
 
82
  transcribe_button = gr.Button("Transcribe")
83
  transcription_output = gr.Textbox(label="Transcription", placeholder="Transcription Output", lines=10)
 
84
 
85
- transcribe_button.click(fn=transcribe_from_youtube, inputs=youtube_url, outputs=transcription_output)
86
  youtube_url.change(populate_metadata, inputs=[youtube_url], outputs=[img, title])
87
 
88
  demo.launch()
 
38
  progress(0, "Downloading YouTube audio...")
39
  # Download audio from YouTube using pytube
40
  audio_path = YouTube(url).streams.filter(only_audio=True)[0].download(filename="tmp.mp4")
41
+
42
+ progress(0.5, "Transcribing audio...")
43
  transcription = transcribe_speech(audio_path)
 
 
44
 
45
+ return audio_path, transcription
46
 
47
  def populate_metadata(url):
48
  yt = YouTube(url)
 
80
 
81
  transcribe_button = gr.Button("Transcribe")
82
  transcription_output = gr.Textbox(label="Transcription", placeholder="Transcription Output", lines=10)
83
+ youtube_audio_output = gr.Audio(label="Downloaded Audio", type="filepath")
84
 
85
+ transcribe_button.click(fn=transcribe_from_youtube, inputs=youtube_url, outputs=[youtube_audio_output, transcription_output])
86
  youtube_url.change(populate_metadata, inputs=[youtube_url], outputs=[img, title])
87
 
88
  demo.launch()