Пример #1
0
 def test_in_out(self):
     self._create_random_model()
     config = load_config(
         os.path.join(get_tests_input_path(), 'server_config.json'))
     config['tts_path'] = get_tests_output_path()
     synthesizer = Synthesizer(config)
     synthesizer.tts("Better this test works!!")
Пример #2
0
 def test_split_into_sentences(self):
     """Check demo server sentences split as expected"""
     print("\n > Testing demo server sentence splitting")
     # pylint: disable=attribute-defined-outside-init
     self.seg = Synthesizer.get_segmenter("en")
     sis = Synthesizer.split_into_sentences
     assert sis(self, 'Hello. Two sentences') == ['Hello.', 'Two sentences']
     assert sis(self, 'He went to meet the adviser from Scott, Waltman & Co. next morning.') == ['He went to meet the adviser from Scott, Waltman & Co. next morning.']
     assert sis(self, 'Let\'s run it past Sarah and co. They\'ll want to see this.') == ['Let\'s run it past Sarah and co.', 'They\'ll want to see this.']
     assert sis(self, 'Where is Bobby Jr.\'s rabbit?') == ['Where is Bobby Jr.\'s rabbit?']
     assert sis(self, 'Please inform the U.K. authorities right away.') == ['Please inform the U.K. authorities right away.']
     assert sis(self, 'Were David and co. at the event?') == ['Were David and co. at the event?']
     assert sis(self, 'paging dr. green, please come to theatre four immediately.') == ['paging dr. green, please come to theatre four immediately.']
     assert sis(self, 'The email format is [email protected]. I think you reversed them.') == ['The email format is [email protected].', 'I think you reversed them.']
     assert sis(self, 'The demo site is: https://top100.example.com/subsection/latestnews.html. Please send us your feedback.') == ['The demo site is: https://top100.example.com/subsection/latestnews.html.', 'Please send us your feedback.']
     assert sis(self, 'Scowling at him, \'You are not done yet!\' she yelled.') == ['Scowling at him, \'You are not done yet!\' she yelled.'] # with the  final lowercase "she" we see it's all one sentence
     assert sis(self, 'Hey!! So good to see you.') == ['Hey!!', 'So good to see you.']
     assert sis(self, 'He went to Yahoo! but I don\'t know the division.') == ['He went to Yahoo! but I don\'t know the division.']
     assert sis(self, 'If you can\'t remember a quote, “at least make up a memorable one that\'s plausible..."') == ['If you can\'t remember a quote, “at least make up a memorable one that\'s plausible..."']
     assert sis(self, 'The address is not google.com.') == ['The address is not google.com.']
     assert sis(self, '1.) The first item 2.) The second item') == ['1.) The first item', '2.) The second item']
     assert sis(self, '1) The first item 2) The second item') == ['1) The first item', '2) The second item']
     assert sis(self, 'a. The first item b. The second item c. The third list item') == ['a. The first item', 'b. The second item', 'c. The third list item']
Пример #3
0
VOCODER_MODEL_PATH = './vocoder_model.pth.tar'
VOCODER_CONFIG_PATH = './config_vocoder.json'


class Config:
    tts_checkpoint = MODEL_PATH
    tts_config = CONFIG_PATH
    use_cuda = False
    tts_speakers = None
    vocoder_checkpoint = VOCODER_MODEL_PATH
    vocoder_config = VOCODER_CONFIG_PATH
    wavernn_lib_path = None


synthesizer = Synthesizer(Config())

texts = """
Hello world, i can speak, yahoo!
"""
data = synthesizer.tts(texts)

with open("./audio_output/hello.wav", "wb") as f:
    f.write(data.read())

from pysndfx import AudioEffectsChain

fx = (
    AudioEffectsChain().highshelf().speed(0.8).pitch(-31).reverb(30)
    # .chorus(0.4, 0.6, [[55, 0.4, 0.55, .5, 't']])
    .lowshelf())
Пример #4
0

config = None
synthesizer = None

embedded_model_folder = os.path.join(
    os.path.dirname(os.path.realpath(__file__)), 'model')
checkpoint_file = os.path.join(embedded_model_folder, 'checkpoint.pth.tar')
config_file = os.path.join(embedded_model_folder, 'config.json')

if os.path.isfile(checkpoint_file) and os.path.isfile(config_file):
    # Use default config with embedded model files
    config = create_argparser().parse_args([])
    config.tts_checkpoint = checkpoint_file
    config.tts_config = config_file
    synthesizer = Synthesizer(config)

app = Flask(__name__)


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


@app.route('/api/tts', methods=['GET'])
def tts():
    text = request.args.get('text')
    print(" > Model input: {}".format(text))
    data = synthesizer.tts(text)
    return send_file(data, mimetype='audio/wav')
Пример #5
0
#!flask/bin/python
import argparse
from TTS.server.synthesizer import Synthesizer
from TTS.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(args.config_path)
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')
    print(" > Model input: {}".format(text))
    data = synthesizer.tts(text)
    return send_file(data, mimetype='audio/wav')
Пример #6
0
    args.tts_config = tts_config_file
if not args.vocoder_checkpoint and os.path.isfile(tts_checkpoint_file):
    args.tts_checkpoint = tts_checkpoint_file
if not args.vocoder_config and os.path.isfile(tts_config_file):
    args.tts_config = tts_config_file

if not args.wavernn_file and os.path.isfile(wavernn_checkpoint_file):
    args.wavernn_file = wavernn_checkpoint_file
if not args.wavernn_config and os.path.isfile(wavernn_config_file):
    args.wavernn_config = wavernn_config_file
if not args.pwgan_file and os.path.isfile(pwgan_checkpoint_file):
    args.pwgan_file = pwgan_checkpoint_file
if not args.pwgan_config and os.path.isfile(pwgan_config_file):
    args.pwgan_config = pwgan_config_file

synthesizer = Synthesizer(args)

app = Flask(__name__)


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


@app.route('/api/tts', methods=['GET'])
def tts():
    text = request.args.get('text')
    print(" > Model input: {}".format(text))
    data = synthesizer.tts(text)
    return send_file(data, mimetype='audio/wav')