Upload app.py
Browse files
app.py
CHANGED
@@ -18,11 +18,11 @@ def translate(audio):
|
|
18 |
outputs = pipe(
|
19 |
audio,
|
20 |
max_new_tokens=256,
|
21 |
-
generate_kwargs={"task": "transcribe", "language": "
|
22 |
)
|
23 |
|
24 |
-
model = VitsModel.from_pretrained("facebook/mms-tts-
|
25 |
-
tokenizer = VitsTokenizer.from_pretrained("facebook/mms-tts-
|
26 |
|
27 |
def synthesise(text):
|
28 |
inputs=tokenizer(text, return_tensors="pt")
|
@@ -41,17 +41,17 @@ demo = gr.Blocks()
|
|
41 |
|
42 |
mic_translate = gr.Interface(
|
43 |
fn=speech_to_speech_translation,
|
44 |
-
inputs=gr.Audio(
|
45 |
outputs=gr.Audio(label="Generated Speech", type="numpy"),
|
46 |
)
|
47 |
|
48 |
file_translate = gr.Interface(
|
49 |
fn=speech_to_speech_translation,
|
50 |
-
inputs=gr.Audio(
|
51 |
outputs=gr.Audio(label="Generated Speech", type="numpy"),
|
52 |
)
|
53 |
|
54 |
with demo:
|
55 |
gr.TabbedInterface([mic_translate, file_translate], ["Microphone", "Audio File"])
|
56 |
|
57 |
-
demo.launch(
|
|
|
18 |
outputs = pipe(
|
19 |
audio,
|
20 |
max_new_tokens=256,
|
21 |
+
generate_kwargs={"task": "transcribe", "language": "es"}
|
22 |
)
|
23 |
|
24 |
+
model = VitsModel.from_pretrained("facebook/mms-tts-spa")
|
25 |
+
tokenizer = VitsTokenizer.from_pretrained("facebook/mms-tts-spa")
|
26 |
|
27 |
def synthesise(text):
|
28 |
inputs=tokenizer(text, return_tensors="pt")
|
|
|
41 |
|
42 |
mic_translate = gr.Interface(
|
43 |
fn=speech_to_speech_translation,
|
44 |
+
inputs=gr.Audio(source="microphone", type="filepath"),
|
45 |
outputs=gr.Audio(label="Generated Speech", type="numpy"),
|
46 |
)
|
47 |
|
48 |
file_translate = gr.Interface(
|
49 |
fn=speech_to_speech_translation,
|
50 |
+
inputs=gr.Audio(source="upload", type="filepath"),
|
51 |
outputs=gr.Audio(label="Generated Speech", type="numpy"),
|
52 |
)
|
53 |
|
54 |
with demo:
|
55 |
gr.TabbedInterface([mic_translate, file_translate], ["Microphone", "Audio File"])
|
56 |
|
57 |
+
demo.launch(debug=True)
|