Chandranshu Jain commited on
Commit
cd3812d
·
verified ·
1 Parent(s): dd10baf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -3,13 +3,19 @@ import os
3
  import gradio as gr
4
  asr = pipeline(task="automatic-speech-recognition",
5
  model="distil-whisper/distil-small.en")
 
 
 
6
  demo = gr.Blocks()
7
  def transcribe_speech(filepath):
8
  if filepath is None:
9
  gr.Warning("No audio found, please retry.")
10
  return ""
11
- output = asr(filepath)
12
- return output["text"]
 
 
 
13
  mic_transcribe = gr.Interface(
14
  fn=transcribe_speech,
15
  inputs=gr.Audio(sources="microphone",
 
3
  import gradio as gr
4
  asr = pipeline(task="automatic-speech-recognition",
5
  model="distil-whisper/distil-small.en")
6
+ translator = pipeline(task="translation",
7
+ model="facebook/nllb-200-distilled-600M",
8
+ torch_dtype=torch.bfloat16)
9
  demo = gr.Blocks()
10
  def transcribe_speech(filepath):
11
  if filepath is None:
12
  gr.Warning("No audio found, please retry.")
13
  return ""
14
+ output = translator(asr(filepath)["text"],
15
+ src_lang="eng_Latn",
16
+ tgt_lang="hin_Deva")
17
+
18
+ return output
19
  mic_transcribe = gr.Interface(
20
  fn=transcribe_speech,
21
  inputs=gr.Audio(sources="microphone",