aigmixer commited on
Commit
418b839
1 Parent(s): 43d9f00

using scripts not package

Browse files
Files changed (1) hide show
  1. app.py +9 -15
app.py CHANGED
@@ -1,23 +1,17 @@
1
  import gradio as gr
2
  import subprocess
3
- import piper
4
 
 
 
 
 
 
 
5
 
6
- def text_to_speech(text):
7
- # Command to run Piper CLI
8
- command = ['piper', '--model', 'model_path.onnx', '--output_file', 'output.wav']
9
-
10
- # Run Piper CLI with subprocess, passing in text as input
11
- result = subprocess.run(command, input=text, text=True, capture_output=True)
12
-
13
- # Return the path to the audio file or handle the output appropriately
14
- return 'output.wav'
15
-
16
- demo = gr.Interface(
17
- fn=text_to_speech,
18
  inputs="text",
19
  outputs="audio"
20
  )
21
 
22
- if __name__ == "__main__":
23
- demo.launch(show_api=False)
 
1
  import gradio as gr
2
  import subprocess
 
3
 
4
+ def synthesize_text(text):
5
+ # Replace 'piper_cli_script.py' with the path to your Piper CLI script
6
+ command = ['python', 'piper_cli_script.py', '--model', 'model_path.onnx', '--text', text]
7
+ result = subprocess.run(command, capture_output=True, text=True)
8
+ # Handle result and output file path
9
+ return 'path_to_output_audio.wav'
10
 
11
+ iface = gr.Interface(
12
+ fn=synthesize_text,
 
 
 
 
 
 
 
 
 
 
13
  inputs="text",
14
  outputs="audio"
15
  )
16
 
17
+ iface.launch()