Spaces:
Runtime error
Runtime error
File size: 1,530 Bytes
c852ee2 bcfd9f0 c852ee2 bcfd9f0 c852ee2 bcfd9f0 c852ee2 bcfd9f0 c852ee2 bcfd9f0 c852ee2 |
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
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__)
@app.route("/")
def index():
return render_template(
"index.html",
show_details=False,
use_multi_speaker=False,
speaker_ids=None,
use_gst=False)
@app.route("/details")
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
@app.route('/api/tts', methods = ['GET']) #?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) |