|
|
import gradio as gr |
|
|
import os |
|
|
import logging |
|
|
from assets.i18n.i18n import I18nAuto |
|
|
from helpers import update_model_dropdown |
|
|
from model import MODEL_CONFIGS |
|
|
from processing import process_audio |
|
|
|
|
|
logging.basicConfig(filename='sesa_gui.log', level=logging.DEBUG) |
|
|
|
|
|
|
|
|
i18n = I18nAuto() |
|
|
|
|
|
def create_interface(): |
|
|
css = """ |
|
|
body { background: #222; color: #fff; font-family: Arial, sans-serif; } |
|
|
.gr-tab { background: #444 !important; color: #fff !important; border: 1px solid #888 !important; } |
|
|
button { background: #555 !important; color: #fff !important; border: 1px solid #888 !important; } |
|
|
button:hover { background: #777 !important; } |
|
|
""" |
|
|
|
|
|
with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo: |
|
|
gr.HTML(f"<h1>{i18n('SESA Audio Separation')}</h1>") |
|
|
|
|
|
with gr.Row(): |
|
|
with gr.Column(): |
|
|
input_audio_file = gr.File( |
|
|
file_types=[".wav", ".mp3", ".flac"], |
|
|
label=i18n("upload_file") |
|
|
) |
|
|
model_dropdown = gr.Dropdown( |
|
|
label=i18n("model"), |
|
|
choices=update_model_dropdown("Vocal Models")["choices"], |
|
|
value=None |
|
|
) |
|
|
process_btn = gr.Button(i18n("process")) |
|
|
|
|
|
with gr.Column(): |
|
|
output_audio = gr.Audio(label=i18n("output")) |
|
|
status = gr.Textbox(label=i18n("status"), interactive=False) |
|
|
|
|
|
|
|
|
process_btn.click( |
|
|
fn=process_audio, |
|
|
inputs=[input_audio_file, model_dropdown], |
|
|
outputs=[output_audio, status] |
|
|
) |
|
|
|
|
|
input_audio_file.upload( |
|
|
fn=lambda x: (x, x), |
|
|
inputs=input_audio_file, |
|
|
outputs=[input_audio_file, output_audio] |
|
|
) |
|
|
|
|
|
return demo |