Spaces:
Running
Running
testing piper cli
Browse files
app.py
CHANGED
|
@@ -1,16 +1,23 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
demo = gr.Interface(
|
| 10 |
-
fn=
|
| 11 |
-
inputs=
|
| 12 |
-
outputs="
|
| 13 |
)
|
| 14 |
|
| 15 |
if __name__ == "__main__":
|
| 16 |
-
demo.launch()
|
|
|
|
| 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)
|