Spaces:
Sleeping
Sleeping
Delete gradio_app.py
Browse files- gradio_app.py +0 -21
gradio_app.py
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
|
2 |
-
import gradio as gr
|
3 |
-
from transformers import pipeline, MarianMTModel, MarianTokenizer
|
4 |
-
|
5 |
-
asr = pipeline("automatic-speech-recognition", model="openai/whisper-small")
|
6 |
-
mt_model_name = "Helsinki-NLP/opus-mt-yo-en"
|
7 |
-
tokenizer = MarianTokenizer.from_pretrained(mt_model_name)
|
8 |
-
model = MarianMTModel.from_pretrained(mt_model_name)
|
9 |
-
|
10 |
-
def translate_speech(audio):
|
11 |
-
transcription = asr(audio)["text"]
|
12 |
-
inputs = tokenizer(transcription, return_tensors="pt", padding=True)
|
13 |
-
translated = model.generate(**inputs)
|
14 |
-
translation = tokenizer.decode(translated[0], skip_special_tokens=True)
|
15 |
-
return transcription, translation
|
16 |
-
|
17 |
-
iface = gr.Interface(fn=translate_speech,
|
18 |
-
inputs=gr.Audio(source="microphone", type="filepath"),
|
19 |
-
outputs=["text", "text"],
|
20 |
-
title="Yoruba to English Speech Translator")
|
21 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|