Priyanka-Chopra-TTS / api_app.py
rushic24's picture
first commit
bcfd9f0
raw
history blame
No virus
953 Bytes
from flask import Flask, redirect, url_for, request
import gradio as gr
from synthesize import synthesize, load_model
from synthesis.vocoders import Hifigan
import sounddevice as sd
import soundfile as sf
model = load_model("checkpoints/checkpoint_9000.zip")
vocoder = Hifigan("weights/custom_pctest/model.pt", "weights/custom_pctest/config.json")
def inference(text: str):
synthesize(
model=model,
text=text,
graph_path="graph.png",
audio_path="audio.wav",
vocoder=vocoder,
)
return "audio.wav"
app = Flask(__name__)
@app.route('/process',methods = ['POST'])
def login():
if request.method == 'POST':
text = request.json['text']
inference(text)
data, fs = sf.read("audio.wav", dtype='float32')
sd.play(data, fs)
status = sd.wait() # Wait until file is done playing
return {'success': True}
if __name__ == '__main__':
app.run(debug = True)