Spaces:
Running
Running
import gradio as gr | |
import subprocess | |
import piper | |
def text_to_speech(text): | |
# Command to run Piper CLI | |
command = ['piper', '--model', 'model_path.onnx', '--output_file', 'output.wav'] | |
# Run Piper CLI with subprocess, passing in text as input | |
result = subprocess.run(command, input=text, text=True, capture_output=True) | |
# Return the path to the audio file or handle the output appropriately | |
return 'output.wav' | |
demo = gr.Interface( | |
fn=text_to_speech, | |
inputs="text", | |
outputs="audio" | |
) | |
if __name__ == "__main__": | |
demo.launch(show_api=False) | |