buio commited on
Commit
a725a47
·
1 Parent(s): 2985ec0

changed description, added ko-fi link, removed deprecated gradio parameters

Browse files
Files changed (1) hide show
  1. app.py +25 -21
app.py CHANGED
@@ -22,12 +22,12 @@ def transcribe(microphone, file_upload):
22
  warn_output = ""
23
  if (microphone is not None) and (file_upload is not None):
24
  warn_output = (
25
- "WARNING: You've uploaded an audio file and used the microphone. "
26
- "The recorded file from the microphone will be used and the uploaded audio will be discarded.\n"
27
  )
28
 
29
  elif (microphone is None) and (file_upload is None):
30
- return "ERROR: You have to either use the microphone or upload an audio file"
31
 
32
  file = microphone if microphone is not None else file_upload
33
 
@@ -58,40 +58,44 @@ def yt_transcribe(yt_url):
58
 
59
  demo = gr.Blocks()
60
 
 
 
 
61
  mf_transcribe = gr.Interface(
62
  fn=transcribe,
63
  inputs=[
64
- gr.inputs.Audio(source="microphone", type="filepath", optional=True),
65
- gr.inputs.Audio(source="upload", type="filepath", optional=True),
66
  ],
67
- outputs="text",
68
- layout="horizontal",
69
- theme="huggingface",
70
- title="Fine-Tuned Whisper Demo: Transcribe Italian Audio 🇮🇹",
71
  description=(
72
- "Transcribe long-form microphone or audio inputs with the click of a button! Demo uses the fine-tuned"
73
- f" checkpoint [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) and 🤗 Transformers to transcribe audio files"
74
- " of arbitrary length."
 
75
  ),
76
  allow_flagging="never",
77
  )
78
 
 
 
 
79
  yt_transcribe = gr.Interface(
80
  fn=yt_transcribe,
81
- inputs=[gr.inputs.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL")],
82
- outputs=["html", "text"],
83
- layout="horizontal",
84
- theme="huggingface",
85
- title="Fine-Tuned Whisper Demo: Transcribe Italian YouTube video 🇮🇹",
86
  description=(
87
- "Transcribe long-form YouTube videos with the click of a button! Demo uses the the fine-tuned checkpoint:"
88
- f" [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) and 🤗 Transformers to transcribe audio files of"
89
- " arbitrary length."
 
90
  ),
91
  allow_flagging="never",
92
  )
93
 
94
  with demo:
95
- gr.TabbedInterface([mf_transcribe, yt_transcribe], ["Transcribe Audio", "Transcribe YouTube"])
96
 
97
  demo.launch(enable_queue=True)
 
22
  warn_output = ""
23
  if (microphone is not None) and (file_upload is not None):
24
  warn_output = (
25
+ "ATTENZIONE: Hai caricato un file audio e anche registrato col microfono. "
26
+ "Verrà trascritta la registrazione dal microfono, mentre il file audio verrà cancellato. \n"
27
  )
28
 
29
  elif (microphone is None) and (file_upload is None):
30
+ return "ERRORE: Devi caricare un file audio oppure registrare con il microfono."
31
 
32
  file = microphone if microphone is not None else file_upload
33
 
 
58
 
59
  demo = gr.Blocks()
60
 
61
+ text_output = gr.Textbox(show_label=True)
62
+ text_output.style(show_copy_button=True)
63
+
64
  mf_transcribe = gr.Interface(
65
  fn=transcribe,
66
  inputs=[
67
+ gr.inputs.Audio(source="microphone", type="filepath"),
68
+ gr.inputs.Audio(source="upload", type="filepath"),
69
  ],
70
+ outputs=text_output,
71
+ title="Trascrivi Audio",
 
 
72
  description=(
73
+ "Trascrivi l'input da microfono o file audio con un click!\n"
74
+ "L'inference su scheda grafica riduce i tempi di circa 10 volte, "
75
+ "per coprire le spese puoi offrirmi un caffe ☕️[qui](https://ko-fi.com/marcobuiani)"
76
+ "Questa demo usa una versione di Whisper ottimizzata per l'Italiano da " f"[EdoAbati](https://huggingface.co/{MODEL_NAME})"
77
  ),
78
  allow_flagging="never",
79
  )
80
 
81
+ text_output_yt = gr.Textbox(show_label=True)
82
+ text_output_yt.style(show_copy_button=True)
83
+
84
  yt_transcribe = gr.Interface(
85
  fn=yt_transcribe,
86
+ inputs=[gr.inputs.Textbox(lines=1, placeholder="Incolla qui il link di un video YouTube", label="YouTube link")],
87
+ outputs=["html", text_output_yt],
88
+ title="Trascrivi Video YouTube",
 
 
89
  description=(
90
+ "Trascrivi un video YouTube dal link con un click!\n"
91
+ "L'inference su scheda grafica riduce i tempi di circa 10 volte, "
92
+ "per coprire le spese puoi offrirmi un caffe ☕️[qui](https://ko-fi.com/marcobuiani)"
93
+ "Questa demo usa una versione di Whisper ottimizzata per l'Italiano da " f"[EdoAbati](https://huggingface.co/{MODEL_NAME})"
94
  ),
95
  allow_flagging="never",
96
  )
97
 
98
  with demo:
99
+ gr.TabbedInterface([mf_transcribe, yt_transcribe], ["Trascrivi Audio", "Trascrivi YouTube"])
100
 
101
  demo.launch(enable_queue=True)