import gradio as gr import subprocess import os def tts_model(model_link, json_link, text): # Define paths for the model and config model_path = "model.onnx" json_path = "model.onnx.json" # Download the model and config files subprocess.run(f"wget -O {model_path} {model_link}", shell=True) subprocess.run(f"wget -O {json_path} {json_link}", shell=True) # Define the output file output_file = "output.wav" # Run Piper using stdin to provide the text input command = f"echo '{text}' | piper --model {model_path} --config {json_path} --output_file {output_file}" # Execute the Piper command subprocess.run(command, shell=True) return output_file # Gradio interface iface = gr.Interface( fn=tts_model, inputs=[ gr.Textbox(label="Model File URL"), gr.Textbox(label="Config JSON URL"), gr.Textbox(label="Enter Text") ], outputs=gr.Audio(label="Generated Speech") ) if __name__ == "__main__": iface.launch()