Spaces:
Sleeping
Sleeping
File size: 1,961 Bytes
5d03fef a152a0a 5d03fef a152a0a 5d03fef a152a0a 5d03fef a152a0a 5d03fef a152a0a 5d03fef a152a0a 5d03fef a152a0a 5d03fef |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
import gradio as gr
import subprocess
import os
def run_ultrasinger(opt_i, opt_o, mode, transcription, pitcher, 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 transcription:
cmd.extend(transcription.split())
# Add pitcher options
if pitcher:
cmd.extend(pitcher.split())
# 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, YouTube link)")
opt_o = gr.Textbox(label="Output folder")
mode = gr.Textbox(label="Mode options (e.g., default -u -m -s)")
transcription = gr.Textbox(label="Transcription options (e.g., --whisper large-v2 --language en)")
pitcher = gr.Textbox(label="Pitcher options (e.g., --crepe 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, transcription, pitcher, extra, device],
outputs=[output_text, error_text],
title="UltraSinger App",
description="Upload an Ultrastar.txt or an audio file, set the options, and run UltraSinger."
)
# Launch the app
if __name__ == "__main__":
interface.launch() |