Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,26 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
| 3 |
import piper
|
|
|
|
| 4 |
|
| 5 |
-
def
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
iface = gr.Interface(
|
| 14 |
-
fn=
|
| 15 |
inputs='text',
|
| 16 |
-
outputs='
|
| 17 |
title="CLI Interface",
|
| 18 |
-
description="Enter your command
|
| 19 |
)
|
| 20 |
|
| 21 |
-
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
| 3 |
import piper
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
+
def run_command_and_get_file(command):
|
| 7 |
+
# Run the command
|
| 8 |
+
subprocess.run(command, shell=True, text=True, capture_output=True)
|
| 9 |
+
|
| 10 |
+
# Assuming the command creates a file with a known name
|
| 11 |
+
file_path = 'output.txt' # Replace with the actual expected file path
|
| 12 |
+
|
| 13 |
+
if os.path.exists(file_path):
|
| 14 |
+
return file_path
|
| 15 |
+
else:
|
| 16 |
+
return "No file generated."
|
| 17 |
|
| 18 |
iface = gr.Interface(
|
| 19 |
+
fn=run_command_and_get_file,
|
| 20 |
inputs='text',
|
| 21 |
+
outputs='file', # Output type changed to 'file'
|
| 22 |
title="CLI Interface",
|
| 23 |
+
description="Enter your command. If a file is generated, you can download it."
|
| 24 |
)
|
| 25 |
|
| 26 |
+
iface.launch()
|