Update app.py
Browse files
app.py
CHANGED
@@ -146,9 +146,26 @@ def process_both(audio_path):
|
|
146 |
# Create Gradio interface
|
147 |
with gr.Blocks(title="Oterin Audio Codec") as demo:
|
148 |
gr.Markdown("# Oterin Audio Codec")
|
149 |
-
gr.Markdown("Upload an audio file to encode it to semantic tokens
|
150 |
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
with gr.Row():
|
153 |
encode_input = gr.Audio(type="filepath", label="Input Audio")
|
154 |
encode_output = gr.File(label="Encoded Tokens (.oterin)", file_types=[".oterin"])
|
@@ -156,21 +173,14 @@ with gr.Blocks(title="Oterin Audio Codec") as demo:
|
|
156 |
encode_btn = gr.Button("Encode")
|
157 |
encode_btn.click(encode_audio, inputs=encode_input, outputs=[encode_output, encode_status])
|
158 |
|
159 |
-
with gr.Tab("Decode
|
|
|
160 |
with gr.Row():
|
161 |
decode_input = gr.File(label="Token File (.oterin)", file_types=[".oterin"])
|
162 |
decode_output = gr.Audio(label="Decoded Audio")
|
163 |
decode_status = gr.Textbox(label="Status")
|
164 |
decode_btn = gr.Button("Decode")
|
165 |
decode_btn.click(decode_tokens, inputs=decode_input, outputs=[decode_output, decode_status])
|
166 |
-
|
167 |
-
with gr.Tab("Both (Encode & Decode)"):
|
168 |
-
with gr.Row():
|
169 |
-
both_input = gr.Audio(type="filepath", label="Input Audio")
|
170 |
-
both_output = gr.Audio(label="Reconstructed Audio")
|
171 |
-
both_status = gr.Textbox(label="Status")
|
172 |
-
both_btn = gr.Button("Process")
|
173 |
-
both_btn.click(process_both, inputs=both_input, outputs=[both_output, both_status])
|
174 |
|
175 |
if __name__ == "__main__":
|
176 |
demo.launch(share=True)
|
|
|
146 |
# Create Gradio interface
|
147 |
with gr.Blocks(title="Oterin Audio Codec") as demo:
|
148 |
gr.Markdown("# Oterin Audio Codec")
|
149 |
+
gr.Markdown("Upload an audio file to encode it to semantic tokens and decode back to audio.")
|
150 |
|
151 |
+
# Make "Both" the primary default tab
|
152 |
+
with gr.Tab("Encode & Decode"):
|
153 |
+
with gr.Row():
|
154 |
+
both_input = gr.Audio(type="filepath", label="Input Audio")
|
155 |
+
both_output = gr.Audio(label="Reconstructed Audio")
|
156 |
+
both_status = gr.Textbox(label="Status")
|
157 |
+
both_btn = gr.Button("Process", variant="primary")
|
158 |
+
both_btn.click(process_both, inputs=both_input, outputs=[both_output, both_status])
|
159 |
+
|
160 |
+
gr.Markdown("""
|
161 |
+
## How it works
|
162 |
+
This option encodes your audio to semantic tokens and immediately decodes it back to audio.
|
163 |
+
It's the recommended way to use the codec as it handles all device management internally.
|
164 |
+
""")
|
165 |
+
|
166 |
+
# Keep separate functions as secondary options with warning
|
167 |
+
with gr.Tab("Advanced (Encode Only)"):
|
168 |
+
gr.Markdown("⚠️ **DEPRECATED**: Using separate encode/decode can lead to device mismatch errors. The combined Encode & Decode tab is recommended.")
|
169 |
with gr.Row():
|
170 |
encode_input = gr.Audio(type="filepath", label="Input Audio")
|
171 |
encode_output = gr.File(label="Encoded Tokens (.oterin)", file_types=[".oterin"])
|
|
|
173 |
encode_btn = gr.Button("Encode")
|
174 |
encode_btn.click(encode_audio, inputs=encode_input, outputs=[encode_output, encode_status])
|
175 |
|
176 |
+
with gr.Tab("Advanced (Decode Only)"):
|
177 |
+
gr.Markdown("⚠️ **DEPRECATED**: Using separate encode/decode can lead to device mismatch errors. The combined Encode & Decode tab is recommended.")
|
178 |
with gr.Row():
|
179 |
decode_input = gr.File(label="Token File (.oterin)", file_types=[".oterin"])
|
180 |
decode_output = gr.Audio(label="Decoded Audio")
|
181 |
decode_status = gr.Textbox(label="Status")
|
182 |
decode_btn = gr.Button("Decode")
|
183 |
decode_btn.click(decode_tokens, inputs=decode_input, outputs=[decode_output, decode_status])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
if __name__ == "__main__":
|
186 |
demo.launch(share=True)
|