Spaces:
Sleeping
Sleeping
File size: 3,415 Bytes
5d03fef 4ba75fd 5d03fef a152a0a 5d03fef a152a0a 5d03fef 4ba75fd 5d03fef 4ba75fd 64d0573 5d03fef a152a0a 5d03fef a152a0a 5d03fef 64d0573 5d03fef 4ba75fd 64d0573 5d03fef 64d0573 5d03fef a152a0a 5d03fef 64d0573 5d03fef 4ba75fd 5d03fef 64d0573 5d03fef 64d0573 744634a 64d0573 5d03fef 64d0573 |
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
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", "full"])
else:
cmd.extend(["--crepe", "tiny"])
# 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"
def load_text_file(file_path):
try:
with open(file_path, 'r') as file:
return file.read()
except Exception as e:
return str(e)
# Define Gradio inputs and outputs for UltraSinger
opt_i = gr.File(label="Ultrastar.txt or audio file (.mp3, .wav, YouTube link)")
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.Checkbox(label="Use Full Crepe Model", value=True)
extra = gr.Textbox(label="Extra options (e.g., --hyphenation True)")
device = gr.Dropdown(
label="Device options",
choices=[
"", "--force_cpu True", "--force_cpu False",
"--force_whisper_cpu True", "--force_whisper_cpu False",
"--force_crepe_cpu True", "--force_crepe_cpu False"
],
value=""
)
output_text = gr.Textbox(label="Standard Output")
error_text = gr.Textbox(label="Error Output")
# Define Gradio interface for UltraSinger
ultrasinger_tab = 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 App",
description="Upload an Ultrastar.txt or an audio file, set the options, and run UltraSinger."
)
# Define Gradio interfaces for the other two tabs
tab1_content = gr.Interface(
fn=lambda: load_text_file("info.txt"),
inputs=[],
outputs=gr.Textbox(label="Tab 1 Content"),
title="Info"
)
tab2_content = gr.Interface(
fn=lambda: load_text_file("usdb.txt"),
inputs=[],
outputs=gr.Textbox(label="Tab 2 Content"),
title="FOR USDB USERS"
)
# Create Gradio tabs
with gr.Blocks(theme="soft") as demo:
with gr.Tabs():
with gr.TabItem("UltraSinger"):
ultrasinger_tab.render()
with gr.TabItem("Info"):
tab1_content.render()
with gr.TabItem("FOR USDB USERS"):
tab2_content.render()
# Launch the app
if __name__ == "__main__":
demo.launch() |