whispy commited on
Commit
ebd69e1
1 Parent(s): 07afe87

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -7,7 +7,12 @@ from transformers import pipeline
7
 
8
  MODEL_NAME = "whispy/whisper_italian"
9
 
10
- device = "cuda" if torch.cuda.is_available() else "cpu"
 
 
 
 
 
11
 
12
  pipe = pipeline(
13
  task="automatic-speech-recognition",
@@ -16,6 +21,7 @@ pipe = pipeline(
16
  device=device,
17
  )
18
 
 
19
 
20
  def transcribe(microphone, file_upload):
21
  warn_output = ""
@@ -52,8 +58,13 @@ def yt_transcribe(yt_url):
52
 
53
  text = pipe("audio.mp3")["text"]
54
 
55
- return html_embed_str, text
 
 
 
 
56
 
 
57
 
58
  demo = gr.Blocks()
59
 
@@ -78,7 +89,7 @@ mf_transcribe = gr.Interface(
78
  yt_transcribe = gr.Interface(
79
  fn=yt_transcribe,
80
  inputs=[gr.inputs.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL")],
81
- outputs=["html", "text"],
82
  layout="horizontal",
83
  theme="huggingface",
84
  title="Whisper Demo: Transcribe YouTube",
 
7
 
8
  MODEL_NAME = "whispy/whisper_italian"
9
 
10
+ device = 0 if torch.cuda.is_available() else "cpu"
11
+
12
+ summarizer = pipeline(
13
+ "summarization",
14
+ model="it5/it5-efficient-small-el32-news-summarization",
15
+ )
16
 
17
  pipe = pipeline(
18
  task="automatic-speech-recognition",
 
21
  device=device,
22
  )
23
 
24
+ translator = pipeline("translation", model="Helsinki-NLP/opus-mt-it-en")
25
 
26
  def transcribe(microphone, file_upload):
27
  warn_output = ""
 
58
 
59
  text = pipe("audio.mp3")["text"]
60
 
61
+ summary = summarizer(text)
62
+ summary = summary[0]["summary_text"]
63
+
64
+ translate = translator(summary)
65
+ translate = translate[0]["translation_text"]
66
 
67
+ return html_embed_str, text, summary, translate
68
 
69
  demo = gr.Blocks()
70
 
 
89
  yt_transcribe = gr.Interface(
90
  fn=yt_transcribe,
91
  inputs=[gr.inputs.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL")],
92
+ outputs=["html", "text", "text", "text"],
93
  layout="horizontal",
94
  theme="huggingface",
95
  title="Whisper Demo: Transcribe YouTube",