Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ os.environ['index_root']="logs"
|
|
7 |
os.environ['weight_root']="assets/weights"
|
8 |
|
9 |
def convert(audio_picker,model_picker):
|
|
|
10 |
now = datetime.now().strftime("%d%m%Y%H%M%S")
|
11 |
command = [
|
12 |
"python",
|
@@ -26,11 +27,12 @@ def convert(audio_picker,model_picker):
|
|
26 |
]
|
27 |
|
28 |
try:
|
29 |
-
process = subprocess.
|
30 |
-
process.wait() # Wait for the subprocess to finish
|
31 |
print("Script executed successfully.")
|
|
|
32 |
except subprocess.CalledProcessError as e:
|
33 |
print(f"Error: {e}")
|
|
|
34 |
|
35 |
assets_folder = "assets"
|
36 |
if not os.path.exists(assets_folder):
|
@@ -149,9 +151,9 @@ with gr.Blocks() as app:
|
|
149 |
audio_refresher = gr.Button("Refresh")
|
150 |
audio_refresher.click(fn=refresh,inputs=[],outputs=[audio_picker,model_picker])
|
151 |
convert_button = gr.Button("Convert")
|
152 |
-
convert_button.click(convert, inputs=[audio_picker,model_picker])
|
153 |
with gr.Row():
|
154 |
audio_player = gr.Audio()
|
155 |
audio_picker.change(fn=update_audio_player, inputs=[audio_picker],outputs=[audio_player])
|
|
|
156 |
|
157 |
app.queue().launch()
|
|
|
7 |
os.environ['weight_root']="assets/weights"
|
8 |
|
9 |
def convert(audio_picker,model_picker):
|
10 |
+
gr.Warning("Your audio is being converted. Please wait.")
|
11 |
now = datetime.now().strftime("%d%m%Y%H%M%S")
|
12 |
command = [
|
13 |
"python",
|
|
|
27 |
]
|
28 |
|
29 |
try:
|
30 |
+
process = subprocess.run(command, check=True)
|
|
|
31 |
print("Script executed successfully.")
|
32 |
+
return {"choices":show_available("audios"),"__type__":"update","value":f"cli_output_{now}.wav"},f"audios/cli_output_{now}.wav"
|
33 |
except subprocess.CalledProcessError as e:
|
34 |
print(f"Error: {e}")
|
35 |
+
return {"choices":show_available("audios"),"__type__":"update"}, None
|
36 |
|
37 |
assets_folder = "assets"
|
38 |
if not os.path.exists(assets_folder):
|
|
|
151 |
audio_refresher = gr.Button("Refresh")
|
152 |
audio_refresher.click(fn=refresh,inputs=[],outputs=[audio_picker,model_picker])
|
153 |
convert_button = gr.Button("Convert")
|
|
|
154 |
with gr.Row():
|
155 |
audio_player = gr.Audio()
|
156 |
audio_picker.change(fn=update_audio_player, inputs=[audio_picker],outputs=[audio_player])
|
157 |
+
convert_button.click(convert, inputs=[audio_picker,model_picker],outputs=[audio_picker,audio_player])
|
158 |
|
159 |
app.queue().launch()
|