Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,124 +19,11 @@ def inference(audio, model):
|
|
| 19 |
out_audio = io4(audio)
|
| 20 |
return out_audio
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
background: white;
|
| 31 |
-
}
|
| 32 |
-
input[type='range'] {
|
| 33 |
-
accent-color: black;
|
| 34 |
-
}
|
| 35 |
-
.dark input[type='range'] {
|
| 36 |
-
accent-color: #dfdfdf;
|
| 37 |
-
}
|
| 38 |
-
.container {
|
| 39 |
-
max-width: 730px;
|
| 40 |
-
margin: auto;
|
| 41 |
-
padding-top: 1.5rem;
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
.details:hover {
|
| 45 |
-
text-decoration: underline;
|
| 46 |
-
}
|
| 47 |
-
.gr-button {
|
| 48 |
-
white-space: nowrap;
|
| 49 |
-
}
|
| 50 |
-
.gr-button:focus {
|
| 51 |
-
border-color: rgb(147 197 253 / var(--tw-border-opacity));
|
| 52 |
-
outline: none;
|
| 53 |
-
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
| 54 |
-
--tw-border-opacity: 1;
|
| 55 |
-
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
| 56 |
-
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color);
|
| 57 |
-
--tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
|
| 58 |
-
--tw-ring-opacity: .5;
|
| 59 |
-
}
|
| 60 |
-
.footer {
|
| 61 |
-
margin-bottom: 45px;
|
| 62 |
-
margin-top: 35px;
|
| 63 |
-
text-align: center;
|
| 64 |
-
border-bottom: 1px solid #e5e5e5;
|
| 65 |
-
}
|
| 66 |
-
.footer>p {
|
| 67 |
-
font-size: .8rem;
|
| 68 |
-
display: inline-block;
|
| 69 |
-
padding: 0 10px;
|
| 70 |
-
transform: translateY(10px);
|
| 71 |
-
background: white;
|
| 72 |
-
}
|
| 73 |
-
.dark .footer {
|
| 74 |
-
border-color: #303030;
|
| 75 |
-
}
|
| 76 |
-
.dark .footer>p {
|
| 77 |
-
background: #0b0f19;
|
| 78 |
-
}
|
| 79 |
-
.prompt h4{
|
| 80 |
-
margin: 1.25em 0 .25em 0;
|
| 81 |
-
font-weight: bold;
|
| 82 |
-
font-size: 115%;
|
| 83 |
-
}
|
| 84 |
-
.animate-spin {
|
| 85 |
-
animation: spin 1s linear infinite;
|
| 86 |
-
}
|
| 87 |
-
@keyframes spin {
|
| 88 |
-
from {
|
| 89 |
-
transform: rotate(0deg);
|
| 90 |
-
}
|
| 91 |
-
to {
|
| 92 |
-
transform: rotate(360deg);
|
| 93 |
-
}
|
| 94 |
-
}
|
| 95 |
-
"""
|
| 96 |
-
|
| 97 |
-
block = gr.Blocks(css=css)
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
with block:
|
| 102 |
-
gr.HTML(
|
| 103 |
-
"""
|
| 104 |
-
<div style="text-align: center; max-width: 700px; margin: 0 auto;">
|
| 105 |
-
<div
|
| 106 |
-
style="
|
| 107 |
-
display: inline-flex;
|
| 108 |
-
align-items: center;
|
| 109 |
-
gap: 0.8rem;
|
| 110 |
-
font-size: 1.75rem;
|
| 111 |
-
"
|
| 112 |
-
>
|
| 113 |
-
<h1 style="font-weight: 900; margin-bottom: 7px;">
|
| 114 |
-
Hokkien Translation
|
| 115 |
-
</h1>
|
| 116 |
-
</div>
|
| 117 |
-
<p style="margin-bottom: 10px; font-size: 94%">
|
| 118 |
-
A demo for fairseq speech-to-speech translation models. It supports S2UT and UnitY models for bidirectional Hokkien and English translation. Please select the model and record the input to submit.
|
| 119 |
-
</p>
|
| 120 |
-
</div>
|
| 121 |
-
"""
|
| 122 |
-
)
|
| 123 |
-
with gr.Group():
|
| 124 |
-
with gr.Box():
|
| 125 |
-
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
| 126 |
-
audio = gr.Audio(
|
| 127 |
-
source="microphone", type="filepath", label="Input"
|
| 128 |
-
)
|
| 129 |
-
|
| 130 |
-
btn = gr.Button("Submit")
|
| 131 |
-
model = gr.Dropdown(choices=["xm_transformer_unity_en-hk", "xm_transformer_unity_hk-en", "xm_transformer_s2ut_en-hk", "xm_transformer_s2ut_hk-en"], value="xm_transformer_unity_en-hk",type="value", label="Model")
|
| 132 |
-
out = gr.Audio(label="Output")
|
| 133 |
-
|
| 134 |
-
btn.click(inference, inputs=[audio, model], outputs=out)
|
| 135 |
-
gr.HTML('''
|
| 136 |
-
<div class="footer">
|
| 137 |
-
<p>Model by <a href="https://ai.facebook.com/" style="text-decoration: underline;" target="_blank">Meta AI</a>
|
| 138 |
-
</p>
|
| 139 |
-
</div>
|
| 140 |
-
''')
|
| 141 |
-
|
| 142 |
-
block.launch()
|
|
|
|
| 19 |
out_audio = io4(audio)
|
| 20 |
return out_audio
|
| 21 |
|
| 22 |
+
model = gr.Dropdown(choices=["xm_transformer_unity_en-hk", "xm_transformer_unity_hk-en", "xm_transformer_s2ut_en-hk", "xm_transformer_s2ut_hk-en"]
|
| 23 |
+
|
| 24 |
+
demo = gr.Interface(
|
| 25 |
+
fn=inference,
|
| 26 |
+
inputs=["audio", model],
|
| 27 |
+
outputs=["audo"],
|
| 28 |
+
)
|
| 29 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|