Spaces:
Runtime error
Runtime error
Update app.py
Browse filesremoved extra stuff added by model on translation
app.py
CHANGED
@@ -32,6 +32,8 @@ def translate(audio):
|
|
32 |
generated_ids = asr_model.generate(inputs["input_features"],attention_mask=inputs["attention_mask"],
|
33 |
forced_bos_token_id=asr_processor.tokenizer.lang_code_to_id['it'],)
|
34 |
translation = asr_processor.batch_decode(generated_ids, skip_special_tokens=True)
|
|
|
|
|
35 |
return translation
|
36 |
|
37 |
|
@@ -61,7 +63,7 @@ demo = gr.Blocks()
|
|
61 |
|
62 |
mic_translate = gr.Interface(
|
63 |
fn=speech_to_speech_translation,
|
64 |
-
inputs=gr.Audio(
|
65 |
outputs=gr.Audio(label="Generated Speech", type="numpy"),
|
66 |
title=title,
|
67 |
description=description,
|
@@ -69,7 +71,7 @@ mic_translate = gr.Interface(
|
|
69 |
|
70 |
file_translate = gr.Interface(
|
71 |
fn=speech_to_speech_translation,
|
72 |
-
inputs=gr.Audio(
|
73 |
outputs=gr.Audio(label="Generated Speech", type="numpy"),
|
74 |
examples=[["./example.wav"]],
|
75 |
title=title,
|
@@ -79,4 +81,4 @@ file_translate = gr.Interface(
|
|
79 |
with demo:
|
80 |
gr.TabbedInterface([mic_translate, file_translate], ["Microphone", "Audio File"])
|
81 |
|
82 |
-
demo.launch()
|
|
|
32 |
generated_ids = asr_model.generate(inputs["input_features"],attention_mask=inputs["attention_mask"],
|
33 |
forced_bos_token_id=asr_processor.tokenizer.lang_code_to_id['it'],)
|
34 |
translation = asr_processor.batch_decode(generated_ids, skip_special_tokens=True)
|
35 |
+
_, parsedTranslation = translation[0].split(")", 1)
|
36 |
+
translation[0] = parsedTranslation
|
37 |
return translation
|
38 |
|
39 |
|
|
|
63 |
|
64 |
mic_translate = gr.Interface(
|
65 |
fn=speech_to_speech_translation,
|
66 |
+
inputs=gr.Audio(sources="microphone"),
|
67 |
outputs=gr.Audio(label="Generated Speech", type="numpy"),
|
68 |
title=title,
|
69 |
description=description,
|
|
|
71 |
|
72 |
file_translate = gr.Interface(
|
73 |
fn=speech_to_speech_translation,
|
74 |
+
inputs=gr.Audio(sources="upload"),
|
75 |
outputs=gr.Audio(label="Generated Speech", type="numpy"),
|
76 |
examples=[["./example.wav"]],
|
77 |
title=title,
|
|
|
81 |
with demo:
|
82 |
gr.TabbedInterface([mic_translate, file_translate], ["Microphone", "Audio File"])
|
83 |
|
84 |
+
demo.launch()
|