Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,24 +3,20 @@ import subprocess
|
|
3 |
import piper
|
4 |
import os
|
5 |
|
6 |
-
def
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
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=
|
20 |
inputs='text',
|
21 |
-
outputs='
|
22 |
title="CLI Interface",
|
23 |
-
description="Enter your command
|
24 |
)
|
25 |
|
26 |
iface.launch()
|
|
|
3 |
import piper
|
4 |
import os
|
5 |
|
6 |
+
def run_command(command):
|
7 |
+
try:
|
8 |
+
# Running the command and capturing the output
|
9 |
+
result = subprocess.run(command, shell=True, text=True, capture_output=True, check=True)
|
10 |
+
return result.stdout
|
11 |
+
except subprocess.CalledProcessError as e:
|
12 |
+
return e.stderr
|
|
|
|
|
|
|
|
|
13 |
|
14 |
iface = gr.Interface(
|
15 |
+
fn=run_command,
|
16 |
inputs='text',
|
17 |
+
outputs='text',
|
18 |
title="CLI Interface",
|
19 |
+
description="Enter your command and see the output."
|
20 |
)
|
21 |
|
22 |
iface.launch()
|