Spaces:
Sleeping
Sleeping
Chandranshu Jain
commited on
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
| 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",
|