Spaces:
Build error
Build error
from flask import Flask, redirect, url_for, request, send_from_directory | |
from flask import Flask, render_template, request, send_file | |
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="tts.wav", | |
vocoder=vocoder, | |
) | |
return True | |
app = Flask(__name__) | |
def index(): | |
return render_template( | |
"index.html", | |
show_details=False, | |
use_multi_speaker=False, | |
speaker_ids=None, | |
use_gst=False) | |
def details(): | |
vocoder_config = None | |
return render_template( | |
"details.html", | |
show_details=False, | |
model_config=None, | |
vocoder_config=None, | |
args=None, | |
) | |
# This format is similar to coqui-ai TTS api | |
#?text=this%20is%20a%20tses&speaker_id=&style_wav= | |
def get_file(): | |
text = request.args.get('text') | |
print(request.args) | |
if not text: | |
print('empty text') | |
return {'message':'textempty'} | |
else: | |
inference(text) | |
return send_from_directory('./', 'tts.wav', as_attachment=True) | |
if __name__ == '__main__': | |
app.run(debug = True, host='0.0.0.0', port=5002) |