daniel-rdt commited on
Commit
5f32f77
1 Parent(s): 755f106

comment out translation due to google translate package conflict on huggingface

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -3,7 +3,7 @@ from transformers import pipeline
3
  import gradio as gr
4
  import os
5
  from pytube import YouTube
6
- from google_trans_new import google_translator
7
 
8
 
9
  # use model with improved learning rate which yielded better performance
@@ -21,11 +21,11 @@ def transcribe_url_yt(yt_url):
21
  text = pipe(audio)["text"]
22
  # remove stored audio file from disk
23
  os.remove(audio)
24
- # text translation
25
- translator = google_translator()
26
- translation = translator.translate(text, lang_tgt='en')
27
 
28
- return text, translation, title, thumbnail
29
 
30
  def transcribe_microphone(audio):
31
  text = pipe(audio)["text"]
@@ -34,19 +34,19 @@ def transcribe_microphone(audio):
34
  with gr.Blocks() as url:
35
  with gr.Row():
36
  with gr.Column():
37
- yt_url = gr.Textbox(label="Paste YouTube link to lithuanian news video \n (recommended test link https://www.youtube.com/watch?v=9JsBg3pTp8I):")
38
  transcribe_btn = gr.Button(value="Transcribe")
39
  with gr.Column():
40
- news_text = gr.Textbox(label="First paragraph of transcribed News:")
41
- with gr.Column():
42
- translated_text = gr.Textbox(label="First paragraph translation into English:")
43
  with gr.Row():
44
  with gr.Column():
45
- yt_title = gr.Textbox(label="Title of the News Video")
46
  with gr.Column():
47
  yt_thumbnail = gr.Image()
48
 
49
- transcribe_btn.click(transcribe_url_yt, inputs=yt_url, outputs=[news_text, translated_text, yt_title, yt_thumbnail])
50
 
51
  with gr.Blocks() as mike:
52
  with gr.Column():
@@ -54,16 +54,16 @@ with gr.Blocks() as mike:
54
  transcribe_btn = gr.Button(value="Transcribe")
55
  with gr.Column():
56
  text = gr.Textbox(label="Transcription:")
57
- with gr.Column():
58
- translated_text = gr.Textbox(label="First paragraph translation into English:")
59
 
60
- transcribe_btn.click(transcribe_microphone, inputs=mike_input, outputs=[text, translated_text])
61
 
62
  with gr.Blocks() as demo:
63
  gr.Markdown(
64
  """
65
  # Whisper Model fine-tuned to transcribe Lithuanian
66
- Real time demo that can either transcribe a Lithuanian News video YouTube URL to text or directly from microphone input.
67
  """
68
  )
69
  gr.TabbedInterface([url, mike], ["Transcribe Youtube-URL", "Transcribe Audio"])
3
  import gradio as gr
4
  import os
5
  from pytube import YouTube
6
+ # from googletrans import Translator
7
 
8
 
9
  # use model with improved learning rate which yielded better performance
21
  text = pipe(audio)["text"]
22
  # remove stored audio file from disk
23
  os.remove(audio)
24
+ # # text translation
25
+ # translator = Translator()
26
+ # translation = translator.translate(text, src='lt')
27
 
28
+ return text, title, thumbnail #, translation.text
29
 
30
  def transcribe_microphone(audio):
31
  text = pipe(audio)["text"]
34
  with gr.Blocks() as url:
35
  with gr.Row():
36
  with gr.Column():
37
+ yt_url = gr.Textbox(label="Paste YouTube link to e.g. lithuanian news video \n (recommended test link https://www.youtube.com/watch?v=9JsBg3pTp8I):")
38
  transcribe_btn = gr.Button(value="Transcribe")
39
  with gr.Column():
40
+ news_text = gr.Textbox(label="Transcribed first paragraph of video:")
41
+ # with gr.Column():
42
+ # translated_text = gr.Textbox(label="First paragraph translation into English:")
43
  with gr.Row():
44
  with gr.Column():
45
+ yt_title = gr.Textbox(label="Title of the (News) Video")
46
  with gr.Column():
47
  yt_thumbnail = gr.Image()
48
 
49
+ transcribe_btn.click(transcribe_url_yt, inputs=yt_url, outputs=[news_text, yt_title, yt_thumbnail])#, translated_text])
50
 
51
  with gr.Blocks() as mike:
52
  with gr.Column():
54
  transcribe_btn = gr.Button(value="Transcribe")
55
  with gr.Column():
56
  text = gr.Textbox(label="Transcription:")
57
+ # with gr.Column():
58
+ # translated_text = gr.Textbox(label="First paragraph translation into English:")
59
 
60
+ transcribe_btn.click(transcribe_microphone, inputs=mike_input, outputs=[text])
61
 
62
  with gr.Blocks() as demo:
63
  gr.Markdown(
64
  """
65
  # Whisper Model fine-tuned to transcribe Lithuanian
66
+ Real time demo that can either transcribe from e.g. a Lithuanian News video YouTube URL to text or directly from microphone input.
67
  """
68
  )
69
  gr.TabbedInterface([url, mike], ["Transcribe Youtube-URL", "Transcribe Audio"])