Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
def run_ultrasinger(opt_i, opt_o, mode, transcription, pitcher, extra, device):
|
| 6 |
+
# Construct the command based on inputs
|
| 7 |
+
cmd = ["python", "UltraSinger.py"]
|
| 8 |
+
|
| 9 |
+
# Add options
|
| 10 |
+
if opt_i:
|
| 11 |
+
cmd.extend(["-i", opt_i])
|
| 12 |
+
if opt_o:
|
| 13 |
+
cmd.extend(["-o", opt_o])
|
| 14 |
+
|
| 15 |
+
# Add mode
|
| 16 |
+
cmd.extend(mode.split())
|
| 17 |
+
|
| 18 |
+
# Add transcription options
|
| 19 |
+
cmd.extend(transcription.split())
|
| 20 |
+
|
| 21 |
+
# Add pitcher options
|
| 22 |
+
cmd.extend(pitcher.split())
|
| 23 |
+
|
| 24 |
+
# Add extra options
|
| 25 |
+
cmd.extend(extra.split())
|
| 26 |
+
|
| 27 |
+
# Add device options
|
| 28 |
+
cmd.extend(device.split())
|
| 29 |
+
|
| 30 |
+
# Execute the command
|
| 31 |
+
try:
|
| 32 |
+
result = subprocess.run(cmd, capture_output=True, text=True)
|
| 33 |
+
return result.stdout, result.stderr
|
| 34 |
+
except Exception as e:
|
| 35 |
+
return str(e), "Error occurred during execution"
|
| 36 |
+
|
| 37 |
+
# Define Gradio inputs and outputs
|
| 38 |
+
opt_i = gr.File(label="Ultrastar.txt or audio file (.mp3, .wav, YouTube link)")
|
| 39 |
+
opt_o = gr.Textbox(label="Output folder")
|
| 40 |
+
mode = gr.Textbox(label="Mode options (e.g., default -u -m -s)")
|
| 41 |
+
transcription = gr.Textbox(label="Transcription options (e.g., --whisper large-v2 --language en)")
|
| 42 |
+
pitcher = gr.Textbox(label="Pitcher options (e.g., --crepe full)")
|
| 43 |
+
extra = gr.Textbox(label="Extra options (e.g., --hyphenation True)")
|
| 44 |
+
device = gr.Textbox(label="Device options (e.g., --force_cpu False)")
|
| 45 |
+
|
| 46 |
+
output_text = gr.outputs.Textbox(label="Standard Output")
|
| 47 |
+
error_text = gr.outputs.Textbox(label="Error Output")
|
| 48 |
+
|
| 49 |
+
# Create Gradio interface
|
| 50 |
+
interface = gr.Interface(
|
| 51 |
+
fn=run_ultrasinger,
|
| 52 |
+
inputs=[opt_i, opt_o, mode, transcription, pitcher, extra, device],
|
| 53 |
+
outputs=[output_text, error_text],
|
| 54 |
+
title="UltraSinger App",
|
| 55 |
+
description="Upload an Ultrastar.txt or an audio file, set the options, and run UltraSinger."
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
# Launch the app
|
| 59 |
+
if __name__ == "__main__":
|
| 60 |
+
interface.launch()
|