Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -22,8 +22,14 @@ def process_audio_file(file):
|
|
22 |
return inputs
|
23 |
|
24 |
|
25 |
-
def interpret(file):
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
with torch.no_grad():
|
28 |
output_logit = model(inputs.input_values).logits
|
29 |
pred_ids = torch.argmax(output_logit, dim=-1)
|
@@ -46,10 +52,11 @@ iface = gr.Interface(
|
|
46 |
description="A simple interface to interpret from spoken English to Vietnamese.",
|
47 |
article="Author: <a href=\"https://huggingface.co/vumichien\">Vu Minh Chien</a>.",
|
48 |
inputs=[
|
49 |
-
gr.Audio(source="microphone", type="filepath", streaming=False),
|
50 |
-
gr.Audio(source="upload", type="filepath",
|
51 |
],
|
52 |
-
outputs=gr.
|
53 |
,
|
|
|
54 |
)
|
55 |
-
iface.launch(
|
|
|
22 |
return inputs
|
23 |
|
24 |
|
25 |
+
def interpret(micro, file):
|
26 |
+
if file is not None and micro is None:
|
27 |
+
input_audio = file
|
28 |
+
elif file is None and micro is not None:
|
29 |
+
input_audio = micro
|
30 |
+
else:
|
31 |
+
input_audio = file
|
32 |
+
inputs = process_audio_file(input_audio)
|
33 |
with torch.no_grad():
|
34 |
output_logit = model(inputs.input_values).logits
|
35 |
pred_ids = torch.argmax(output_logit, dim=-1)
|
|
|
52 |
description="A simple interface to interpret from spoken English to Vietnamese.",
|
53 |
article="Author: <a href=\"https://huggingface.co/vumichien\">Vu Minh Chien</a>.",
|
54 |
inputs=[
|
55 |
+
gr.Audio(source="microphone", type="filepath", streaming=False, label="Microphone"),
|
56 |
+
gr.Audio(source="upload", type="filepath", label="File"),
|
57 |
],
|
58 |
+
outputs=gr.Textbox(label="Text output")
|
59 |
,
|
60 |
+
samples=["samples/sample-000000.mp3", "samples/sample-000001.mp3"]
|
61 |
)
|
62 |
+
iface.launch(debug=True)
|