aigmixer commited on
Commit
9eea9dc
1 Parent(s): 21c111d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -14
app.py CHANGED
@@ -3,24 +3,20 @@ 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()
 
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()