File size: 1,022 Bytes
6f430c8
fcf6d97
28aabd9
6f430c8
 
fcf6d97
6f430c8
 
 
fcf6d97
 
 
6f430c8
fcf6d97
28aabd9
fcf6d97
5ee9242
 
fcf6d97
5ee9242
fcf6d97
 
6f430c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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()