Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,14 +2,13 @@ from transformers import pipeline
|
|
| 2 |
import os
|
| 3 |
import gradio as gr
|
| 4 |
import torch
|
| 5 |
-
from IPython.display import Audio as IPythonAudio
|
| 6 |
-
from gtts import gTTS
|
| 7 |
-
import IPython.display as ipd
|
| 8 |
|
| 9 |
#Audio to text
|
| 10 |
-
asr = pipeline(task="automatic-speech-recognition",
|
| 11 |
-
model="distil-whisper/distil-small.en")
|
| 12 |
-
#asr=pipeline("automatic-speech-recognition", model="openai/whisper-large-v3")
|
| 13 |
#Text to text
|
| 14 |
translator = pipeline(task="translation",
|
| 15 |
model="facebook/nllb-200-distilled-600M",
|
|
@@ -23,7 +22,8 @@ def transcribe_speech(filepath):
|
|
| 23 |
if filepath is None:
|
| 24 |
gr.Warning("No audio found, please retry.")
|
| 25 |
return ""
|
| 26 |
-
|
|
|
|
| 27 |
src_lang="eng_Latn",
|
| 28 |
tgt_lang="hin_Deva")
|
| 29 |
narrated_text=pipe(output[0]['translation_text'])
|
|
@@ -35,16 +35,18 @@ def transcribe_speech(filepath):
|
|
| 35 |
|
| 36 |
mic_transcribe = gr.Interface(
|
| 37 |
fn=transcribe_speech,
|
| 38 |
-
inputs=gr.Audio(sources="microphone",
|
| 39 |
-
|
|
|
|
| 40 |
outputs="audio",
|
| 41 |
#outputs=gr.Audio(label="Translated Message"),
|
| 42 |
allow_flagging="never")
|
| 43 |
|
| 44 |
file_transcribe = gr.Interface(
|
| 45 |
fn=transcribe_speech,
|
| 46 |
-
inputs=gr.Audio(sources="upload",
|
| 47 |
-
|
|
|
|
| 48 |
outputs="audio",
|
| 49 |
#outputs=gr.Audio(label="Translated Message"),
|
| 50 |
allow_flagging="never"
|
|
|
|
| 2 |
import os
|
| 3 |
import gradio as gr
|
| 4 |
import torch
|
| 5 |
+
#from IPython.display import Audio as IPythonAudio
|
| 6 |
+
#from gtts import gTTS
|
| 7 |
+
#import IPython.display as ipd
|
| 8 |
|
| 9 |
#Audio to text
|
| 10 |
+
#asr = pipeline(task="automatic-speech-recognition",
|
| 11 |
+
# model="distil-whisper/distil-small.en")
|
|
|
|
| 12 |
#Text to text
|
| 13 |
translator = pipeline(task="translation",
|
| 14 |
model="facebook/nllb-200-distilled-600M",
|
|
|
|
| 22 |
if filepath is None:
|
| 23 |
gr.Warning("No audio found, please retry.")
|
| 24 |
return ""
|
| 25 |
+
#asr(filepath)["text"]
|
| 26 |
+
output = translator(filepath,
|
| 27 |
src_lang="eng_Latn",
|
| 28 |
tgt_lang="hin_Deva")
|
| 29 |
narrated_text=pipe(output[0]['translation_text'])
|
|
|
|
| 35 |
|
| 36 |
mic_transcribe = gr.Interface(
|
| 37 |
fn=transcribe_speech,
|
| 38 |
+
#inputs=gr.Audio(sources="microphone",
|
| 39 |
+
# type="filepath"),
|
| 40 |
+
inputs=gr.Textbox(label="text",lines=3),
|
| 41 |
outputs="audio",
|
| 42 |
#outputs=gr.Audio(label="Translated Message"),
|
| 43 |
allow_flagging="never")
|
| 44 |
|
| 45 |
file_transcribe = gr.Interface(
|
| 46 |
fn=transcribe_speech,
|
| 47 |
+
#inputs=gr.Audio(sources="upload",
|
| 48 |
+
# type="filepath"),
|
| 49 |
+
inputs=gr.Textbox(label="text",lines=3),
|
| 50 |
outputs="audio",
|
| 51 |
#outputs=gr.Audio(label="Translated Message"),
|
| 52 |
allow_flagging="never"
|