2018-06-05 12:15:48 +00:00
|
|
|
#!flask/bin/python
|
|
|
|
import argparse
|
|
|
|
from synthesizer import Synthesizer
|
2018-11-19 14:27:22 +00:00
|
|
|
from utils.generic_utils import load_config
|
2018-08-02 14:34:17 +00:00
|
|
|
from flask import Flask, Response, request, render_template, send_file
|
2018-06-05 12:15:48 +00:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
2018-08-02 14:34:17 +00:00
|
|
|
parser.add_argument(
|
|
|
|
'-c', '--config_path', type=str, help='path to config file for training')
|
2018-06-05 12:15:48 +00:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
config = load_config(args.config_path)
|
|
|
|
app = Flask(__name__)
|
2019-04-15 14:13:33 +00:00
|
|
|
synthesizer = Synthesizer(config)
|
2018-08-02 14:34:17 +00:00
|
|
|
|
2018-06-05 12:15:48 +00:00
|
|
|
@app.route('/')
|
|
|
|
def index():
|
|
|
|
return render_template('index.html')
|
|
|
|
|
2018-08-02 14:34:17 +00:00
|
|
|
|
2018-06-05 12:15:48 +00:00
|
|
|
@app.route('/api/tts', methods=['GET'])
|
|
|
|
def tts():
|
|
|
|
text = request.args.get('text')
|
|
|
|
print(" > Model input: {}".format(text))
|
|
|
|
data = synthesizer.tts(text)
|
2018-08-02 14:34:17 +00:00
|
|
|
return send_file(data, mimetype='audio/wav')
|
|
|
|
|
2018-06-05 12:15:48 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2019-04-18 15:35:20 +00:00
|
|
|
app.run(debug=config.debug, host='0.0.0.0', port=config.port)
|