Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,7 +24,9 @@ def run_ultrasinger(opt_i, opt_o, mode, whisper_model, language, crepe_model, ex
|
|
| 24 |
|
| 25 |
# Add pitcher options
|
| 26 |
if crepe_model:
|
| 27 |
-
cmd.extend(["--crepe",
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# Add extra options
|
| 30 |
if extra:
|
|
@@ -41,8 +43,15 @@ def run_ultrasinger(opt_i, opt_o, mode, whisper_model, language, crepe_model, ex
|
|
| 41 |
except Exception as e:
|
| 42 |
return str(e), "Error occurred during execution"
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
opt_o = gr.Textbox(label="Output folder")
|
| 47 |
mode = gr.Dropdown(
|
| 48 |
label="Mode options",
|
|
@@ -58,26 +67,55 @@ whisper_model = gr.Dropdown(
|
|
| 58 |
value="large-v2"
|
| 59 |
)
|
| 60 |
language = gr.Textbox(label="Language (e.g., en)")
|
| 61 |
-
crepe_model = gr.
|
| 62 |
-
label="Crepe Model",
|
| 63 |
-
choices=["tiny", "full"],
|
| 64 |
-
value="full"
|
| 65 |
-
)
|
| 66 |
extra = gr.Textbox(label="Extra options (e.g., --hyphenation True)")
|
| 67 |
-
device = gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
output_text = gr.Textbox(label="Standard Output")
|
| 70 |
error_text = gr.Textbox(label="Error Output")
|
| 71 |
|
| 72 |
-
#
|
| 73 |
-
|
| 74 |
fn=run_ultrasinger,
|
| 75 |
inputs=[opt_i, opt_o, mode, whisper_model, language, crepe_model, extra, device],
|
| 76 |
outputs=[output_text, error_text],
|
| 77 |
-
title="UltraSinger
|
| 78 |
description="Upload an Ultrastar.txt or an audio file, set the options, and run UltraSinger."
|
| 79 |
)
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
# Launch the app
|
| 82 |
if __name__ == "__main__":
|
| 83 |
-
|
|
|
|
| 24 |
|
| 25 |
# Add pitcher options
|
| 26 |
if crepe_model:
|
| 27 |
+
cmd.extend(["--crepe", "full"])
|
| 28 |
+
else:
|
| 29 |
+
cmd.extend(["--crepe", "tiny"])
|
| 30 |
|
| 31 |
# Add extra options
|
| 32 |
if extra:
|
|
|
|
| 43 |
except Exception as e:
|
| 44 |
return str(e), "Error occurred during execution"
|
| 45 |
|
| 46 |
+
def load_text_file(file_path):
|
| 47 |
+
try:
|
| 48 |
+
with open(file_path, 'r') as file:
|
| 49 |
+
return file.read()
|
| 50 |
+
except Exception as e:
|
| 51 |
+
return str(e)
|
| 52 |
+
|
| 53 |
+
# Define Gradio inputs and outputs for UltraSinger
|
| 54 |
+
opt_i = gr.File(label="Ultrastar.txt or audio file (.mp3, .wav, YouTube link)")
|
| 55 |
opt_o = gr.Textbox(label="Output folder")
|
| 56 |
mode = gr.Dropdown(
|
| 57 |
label="Mode options",
|
|
|
|
| 67 |
value="large-v2"
|
| 68 |
)
|
| 69 |
language = gr.Textbox(label="Language (e.g., en)")
|
| 70 |
+
crepe_model = gr.Checkbox(label="Use Full Crepe Model", value=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
extra = gr.Textbox(label="Extra options (e.g., --hyphenation True)")
|
| 72 |
+
device = gr.Dropdown(
|
| 73 |
+
label="Device options",
|
| 74 |
+
choices=[
|
| 75 |
+
"", "--force_cpu True", "--force_cpu False",
|
| 76 |
+
"--force_whisper_cpu True", "--force_whisper_cpu False",
|
| 77 |
+
"--force_crepe_cpu True", "--force_crepe_cpu False"
|
| 78 |
+
],
|
| 79 |
+
value=""
|
| 80 |
+
)
|
| 81 |
|
| 82 |
output_text = gr.Textbox(label="Standard Output")
|
| 83 |
error_text = gr.Textbox(label="Error Output")
|
| 84 |
|
| 85 |
+
# Define Gradio interface for UltraSinger
|
| 86 |
+
ultrasinger_tab = gr.Interface(
|
| 87 |
fn=run_ultrasinger,
|
| 88 |
inputs=[opt_i, opt_o, mode, whisper_model, language, crepe_model, extra, device],
|
| 89 |
outputs=[output_text, error_text],
|
| 90 |
+
title="UltraSinger App",
|
| 91 |
description="Upload an Ultrastar.txt or an audio file, set the options, and run UltraSinger."
|
| 92 |
)
|
| 93 |
|
| 94 |
+
# Define Gradio interfaces for the other two tabs
|
| 95 |
+
tab1_content = gr.Interface(
|
| 96 |
+
fn=lambda: load_text_file("info.txt"),
|
| 97 |
+
inputs=[],
|
| 98 |
+
outputs=gr.Textbox(label="Tab 1 Content"),
|
| 99 |
+
title="Info"
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
tab2_content = gr.Interface(
|
| 103 |
+
fn=lambda: load_text_file("usdb.txt"),
|
| 104 |
+
inputs=[],
|
| 105 |
+
outputs=gr.Textbox(label="Tab 2 Content"),
|
| 106 |
+
title="FOR USDB USERS
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
# Create Gradio tabs
|
| 110 |
+
with gr.Blocks(theme="soft") as demo:
|
| 111 |
+
with gr.Tabs():
|
| 112 |
+
with gr.TabItem("UltraSinger"):
|
| 113 |
+
ultrasinger_tab.render()
|
| 114 |
+
with gr.TabItem("Info"):
|
| 115 |
+
tab1_content.render()
|
| 116 |
+
with gr.TabItem("FOR USDB USERS"):
|
| 117 |
+
tab2_content.render()
|
| 118 |
+
|
| 119 |
# Launch the app
|
| 120 |
if __name__ == "__main__":
|
| 121 |
+
demo.launch()
|