mirror of https://github.com/coqui-ai/TTS.git
7.1 KiB
7.1 KiB
None
<html lang="en">
<head>
</head>
</html>
In [ ]:
%load_ext autoreload %autoreload 2 import os import sys import io import torch import time import numpy as np from collections import OrderedDict %pylab inline rcParams["figure.figsize"] = (16,5) sys.path.append('/home/erogol/projects/') import librosa import librosa.display from TTS.models.tacotron import Tacotron from TTS.layers import * from TTS.utils.data import * from TTS.utils.audio import AudioProcessor from TTS.utils.generic_utils import load_config from TTS.utils.text import text_to_sequence import IPython from IPython.display import Audio from utils import *
In [ ]:
def tts(model, text, CONFIG, use_cuda, ap, figures=True): t_1 = time.time() waveform, alignment, spectrogram = create_speech(model, text, CONFIG, use_cuda, ap) print(" > Run-time: {}".format(time.time() - t_1)) if figures: visualize(alignment, spectrogram, CONFIG) IPython.display.display(Audio(waveform, rate=CONFIG.sample_rate)) return alignment, spectrogram
In [ ]:
# Set constants ROOT_PATH = '/data/shared/erogol_models/April-26-2018_05:55AM-aa32c76' MODEL_PATH = ROOT_PATH + '/checkpoint_188864.pth.tar' CONFIG_PATH = ROOT_PATH + '/config.json' OUT_FOLDER = ROOT_PATH + '/test/' CONFIG = load_config(CONFIG_PATH) use_cuda = False
In [ ]:
# load the model model = Tacotron(CONFIG.embedding_size, CONFIG.num_freq, CONFIG.num_mels, CONFIG.r) # load the audio processor ap = AudioProcessor(CONFIG.sample_rate, CONFIG.num_mels, CONFIG.min_level_db, CONFIG.frame_shift_ms, CONFIG.frame_length_ms, CONFIG.preemphasis, CONFIG.ref_level_db, CONFIG.num_freq, CONFIG.power, griffin_lim_iters=80) # load model state if use_cuda: cp = torch.load(MODEL_PATH) else: cp = torch.load(MODEL_PATH, map_location=lambda storage, loc: storage) # load the model model.load_state_dict(cp['model']) if use_cuda: model.cuda() model.eval()
EXAMPLES FROM TRAINING SET¶
In [ ]:
import pandas as pd df = pd.read_csv('/data/shared/KeithIto/LJSpeech-1.0/metadata_val.csv', delimiter='|')
In [ ]:
sentence = df.iloc[175, 1] print(sentence) model.decoder.max_decoder_steps = 250 align, spec = tts(model, sentence, CONFIG, use_cuda, ap)
Comparision with https://mycroft.ai/blog/available-voices/¶
In [ ]:
sentence = "It took me quite a long time to develop a voice, and now that I have it I'm not going to be silent." model.decoder.max_decoder_steps = 250 alignment = tts(model, sentence, CONFIG, use_cuda, ap)
In [ ]:
sentence = "Be a voice, not an echo." # 'echo' is not in training set. alignment = tts(model, sentence, CONFIG, use_cuda, ap)
In [ ]:
sentence = "The human voice is the most perfect instrument of all." alignment = tts(model, sentence, CONFIG, use_cuda, ap)
In [ ]:
sentence = "I'm sorry Dave. I'm afraid I can't do that." alignment = tts(model, sentence, CONFIG, use_cuda, ap)
In [ ]:
sentence = "This cake is great. It's so delicious and moist." alignment = tts(model, sentence, CONFIG, use_cuda, ap)
Comparison with https://keithito.github.io/audio-samples/¶
In [ ]:
sentence = "Generative adversarial network or variational auto-encoder." alignment = tts(model, sentence, CONFIG, use_cuda, ap)
In [ ]:
sentence = "Scientists at the CERN laboratory say they have discovered a new particle." alignment = tts(model, sentence, CONFIG, use_cuda, ap)
In [ ]:
sentence = "here’s a way to measure the acute emotional intelligence that has never gone out of style." alignment = tts(model, sentence, CONFIG, use_cuda, ap)
In [ ]:
sentence = "President Trump met with other leaders at the Group of 20 conference." alignment = tts(model, sentence, CONFIG, use_cuda, ap)
In [ ]:
sentence = "The buses aren't the problem, they actually provide a solution." alignment = tts(model, sentence, CONFIG, use_cuda, ap)