Пример #1
0
import torch
from synthesizer import Synthesizer
from utils.generic_utils import load_config
from flask import Flask, Response, request, render_template, send_file

parser = argparse.ArgumentParser()
parser.add_argument('-c',
                    '--config_path',
                    type=str,
                    help='path to config file for training')
args = parser.parse_args()

config = load_config('server/config.json')
app = Flask(__name__)
synthesizer = Synthesizer()
synthesizer.load_model(config.model_path, config.model_name,
                       config.model_config, config.use_cuda)


@app.route('/')
def index():
    return render_template('index.html')


@app.route('/api/tts', methods=['GET'])
def tts():
    text = request.args.get('text')
    synthesizer.ap.frame_shift_ms = int(request.args.get('shift'))
    synthesizer.ap.griffin_lim_iters = int(request.args.get('iter'))
    synthesizer.ap.griffin_lim_algorithm = request.args.get('gl')
    synthesizer.ap._stft_parameters()
    synthesizer.ap.set_gl_algorithm()
Пример #2
0
from flask import Flask, request, render_template, jsonify, url_for
app = Flask(__name__, static_folder='static')


@app.route('/')
def index():
    return render_template('index.html')


@app.route('/tts_trans')
def index_tts_trans():
    return render_template('index.html')


model = Synthesizer()
model.load_model()


@app.route('/tts_text', methods=['POST', 'GET'])
def get_tts_text():
    if request.method == 'POST':
        tts_text = request.form.get('tts_text')
        # file_name
        if len(os.listdir('static/tf_outputs')) >= 10:
            shutil.rmtree('static/tf_outputs')
            os.mkdir('static/tf_outputs')
        time_string = time.strftime("%b%d_%H%M_", time.localtime()) + "".join(
            random.sample('zyxwvutsrqponmlkjihgfedcba', 5))
        file_path = 'tf_outputs/{}.wav'.format(time_string)
        net_file_path = url_for('static', filename=file_path)
        local_file_path = 'static/' + file_path
Пример #3
0
from synthesizer import Synthesizer
from utils.generic_utils import load_config
import matplotlib.pyplot as plt
import time

import os

os.chdir('/home/andrei/BachelorThesis/server')

config = load_config('config.json')
synthesizer = Synthesizer()
synthesizer.load_model(model_path=config['model_path'],
                       model_name=config['model_name'],
                       model_config=config['model_config'],
                       use_cuda=config['use_cuda'])

short_inputs = [
    'I am a test.', 'This is a short input.',
    'I must be faster when speaking.', 'I love to speak to you.',
    'Machines have become increasingly capable.'
]

#source: https://en.wikipedia.org/wiki/Artificial_intelligence
medium_inputs = [
    'Artificial intelligence can be classified into three different types of systems.',
    'I am a medium input and I wouldnt be so long and annoying if I would want to.',
    'Its nice to be important but is more important to be nice thats what a wise man said.',
    'I searched so much for medium sentences so I ran out of ideas so now I am writing random stuff.',
    'This enables even young children to easily make inferences like If I roll this pen off a table, it will fall on the floor.'
]