TIMBOVILL commited on
Commit
a5e574f
1 Parent(s): bb25927

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -12
app.py CHANGED
@@ -1,20 +1,30 @@
1
  import gradio as gr
2
  import subprocess
3
- import os
4
 
5
- def run_ultrasinger(opt_i, opt_o, mode, whisper_model, language, crepe_model, extra, device):
6
  # Construct the command based on inputs
7
- cmd = ["python", "src/UltraSinger.py"]
8
 
9
- # Add options
10
  if opt_i:
11
- cmd.extend(["-i", opt_i.name])
 
 
 
 
 
 
12
  if opt_o:
13
- cmd.extend(["-o", opt_o])
14
 
15
  # Add mode
16
- if mode:
17
- cmd.extend(mode.split())
 
 
 
 
 
18
 
19
  # Add transcription options
20
  if whisper_model:
@@ -38,6 +48,9 @@ def run_ultrasinger(opt_i, opt_o, mode, whisper_model, language, crepe_model, ex
38
  if device:
39
  cmd.extend(device.split())
40
 
 
 
 
41
  # Execute the command
42
  try:
43
  result = subprocess.run(cmd, capture_output=True, text=True)
@@ -53,11 +66,15 @@ def load_text_file(file_path):
53
  return str(e)
54
 
55
  # Define Gradio inputs and outputs for UltraSinger
56
- opt_i = gr.File(label="Ultrastar.txt or audio file (.mp3, .wav, YouTube link)")
 
57
  opt_o = gr.Textbox(label="Output folder")
58
- mode = gr.Dropdown(
59
  label="Mode options",
60
- choices=["default", "-u", "-m", "-s", "-r", "-p"],
 
 
 
61
  value="default"
62
  )
63
  whisper_model = gr.Dropdown(
@@ -98,7 +115,7 @@ error_text = gr.Textbox(label="Error Output")
98
  # Define Gradio interface for UltraSinger
99
  ultrasinger_tab = gr.Interface(
100
  fn=run_ultrasinger,
101
- inputs=[opt_i, opt_o, mode, whisper_model, language, crepe_model, extra, device],
102
  outputs=[output_text, error_text],
103
  title="UltraSinger UI",
104
  description="Upload an Ultrastar.txt or an audio file, set the options, and run UltraSinger."
 
1
  import gradio as gr
2
  import subprocess
 
3
 
4
+ def run_ultrasinger(opt_i, youtube_link, opt_o, mode, whisper_model, language, crepe_model, extra, device):
5
  # Construct the command based on inputs
6
+ cmd = ["python", "UltraSinger.py"]
7
 
8
+ # Add input option
9
  if opt_i:
10
+ cmd.extend(["-i", f'"{opt_i.name}"'])
11
+ elif youtube_link:
12
+ cmd.extend(["-i", f'"{youtube_link}"'])
13
+ else:
14
+ return "Error: No input file or YouTube link provided", ""
15
+
16
+ # Add output folder option
17
  if opt_o:
18
+ cmd.extend(["-o", f'"{opt_o}"'])
19
 
20
  # Add mode
21
+ if mode != "default":
22
+ mode_flags = {
23
+ "Create Ultrastar txt file": "-u",
24
+ "Create MIDI file": "-m",
25
+ "Create sheet file": "-s"
26
+ }
27
+ cmd.append(mode_flags[mode])
28
 
29
  # Add transcription options
30
  if whisper_model:
 
48
  if device:
49
  cmd.extend(device.split())
50
 
51
+ # Debug: Print the command to check if it's constructed correctly
52
+ print("Running command:", ' '.join(cmd))
53
+
54
  # Execute the command
55
  try:
56
  result = subprocess.run(cmd, capture_output=True, text=True)
 
66
  return str(e)
67
 
68
  # Define Gradio inputs and outputs for UltraSinger
69
+ opt_i = gr.File(label="Ultrastar.txt or audio file (.mp3, .wav)")
70
+ youtube_link = gr.Textbox(label="YouTube Link", placeholder="Enter YouTube URL here")
71
  opt_o = gr.Textbox(label="Output folder")
72
+ mode = gr.Radio(
73
  label="Mode options",
74
+ choices=[
75
+ "default", "Create Ultrastar txt file", "Create MIDI file",
76
+ "Create sheet file"
77
+ ],
78
  value="default"
79
  )
80
  whisper_model = gr.Dropdown(
 
115
  # Define Gradio interface for UltraSinger
116
  ultrasinger_tab = gr.Interface(
117
  fn=run_ultrasinger,
118
+ inputs=[opt_i, youtube_link, opt_o, mode, whisper_model, language, crepe_model, extra, device],
119
  outputs=[output_text, error_text],
120
  title="UltraSinger UI",
121
  description="Upload an Ultrastar.txt or an audio file, set the options, and run UltraSinger."