aigmixer commited on
Commit
7febfc4
1 Parent(s): 924e172
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -1,17 +1,21 @@
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/__main__.py', '--model', 'https://huggingface.co/rhasspy/piper-voices/blob/v1.0.0/en/en_GB/alan/medium/en_GB-alan-medium.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()
 
1
  import gradio as gr
2
  import subprocess
3
+ import piper
4
 
5
+ def synthesize_speech(text):
6
+ # Command to execute Piper-TTS CLI
7
+ command = ['piper-tts-cli', '--text', text, '--output', 'output.wav']
8
+ subprocess.run(command, capture_output=True)
9
+
10
+ if os.path.exists('output.wav'):
11
+ return 'output.wav'
12
+ else:
13
+ return None
14
 
15
  iface = gr.Interface(
16
+ fn=synthesize_speech,
17
+ inputs='text',
18
+ outputs='audio'
19
  )
20
 
21
  iface.launch()