UltraSingerUI / app.py
TIMBOVILL's picture
Update app.py
4ba75fd verified
raw
history blame
2.33 kB
import gradio as gr
import subprocess
import os
def run_ultrasinger(opt_i, opt_o, mode, whisper_model, language, crepe_model, extra, device):
# Construct the command based on inputs
cmd = ["python", "UltraSinger.py"]
# Add options
if opt_i:
cmd.extend(["-i", opt_i.name])
if opt_o:
cmd.extend(["-o", opt_o])
# Add mode
if mode:
cmd.extend(mode.split())
# Add transcription options
if whisper_model:
cmd.extend(["--whisper", whisper_model])
if language:
cmd.extend(["--language", language])
# Add pitcher options
if crepe_model:
cmd.extend(["--crepe", crepe_model])
# Add extra options
if extra:
cmd.extend(extra.split())
# Add device options
if device:
cmd.extend(device.split())
# Execute the command
try:
result = subprocess.run(cmd, capture_output=True, text=True)
return result.stdout, result.stderr
except Exception as e:
return str(e), "Error occurred during execution"
# Define Gradio inputs and outputs
opt_i = gr.File(label="Ultrastar.txt or audio file (.mp3, .wav, .txt)")
opt_o = gr.Textbox(label="Output folder")
mode = gr.Dropdown(
label="Mode options",
choices=["default", "-u", "-m", "-s", "-r", "-p"],
value="default"
)
whisper_model = gr.Dropdown(
label="Whisper Model",
choices=[
"tiny", "base", "small", "medium", "large-v1", "large-v2",
"tiny.en", "base.en", "small.en", "medium.en"
],
value="large-v2"
)
language = gr.Textbox(label="Language (e.g., en)")
crepe_model = gr.Dropdown(
label="Crepe Model",
choices=["tiny", "full"],
value="full"
)
extra = gr.Textbox(label="Extra options (e.g., --hyphenation True)")
device = gr.Textbox(label="Device options (e.g., --force_cpu False)")
output_text = gr.Textbox(label="Standard Output")
error_text = gr.Textbox(label="Error Output")
# Create Gradio interface
interface = gr.Interface(
fn=run_ultrasinger,
inputs=[opt_i, opt_o, mode, whisper_model, language, crepe_model, extra, device],
outputs=[output_text, error_text],
title="UltraSinger UI",
description="Upload an Ultrastar.txt or an audio file, set the options, and run UltraSinger."
)
# Launch the app
if __name__ == "__main__":
interface.launch()