aigmixer commited on
Commit
21c111d
1 Parent(s): 7e2ab77

Update app.py

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