mirror of
https://github.com/wassname/TTS.git
synced 2026-09-09 11:16:00 +08:00
* add configs * Update config file * Add model configs * Add model layers * Add layer files * Add layer modules * change config names * Add emotion manager * fIX missing ap bug * Fix missing ap bug * Add base TTS e2e class * Fix wrong variable name in load_tts_samples * Add training script * Remove range predictor and gaussian upsampling * Add helper function * Add vctk recipe * Add conformer docs * Fix linting in conformer.py * Add Docs * remove duplicate import * refactor args * Fix bugs * Removew emotion embedding * remove unused arg * Remove emotion embedding arg * Remove emotion embedding arg * fix style issues * Fix bugs * Fix bugs * Add unittests * make style * fix formatter bug * fix test * Add pyworld compute pitch func * Update requirments.txt * Fix dataset Bug * Chnge layer norm to instance norm * Add missing import * Remove emotions.py * remove ssim loss * Add init layers func to aligner * refactor model layers * remove audio_config arg * Rename loss func * Rename to delightful-tts * Rename loss func * Remove unused modules * refactor imports * replace audio config with audio processor * Add change sample rate option * remove broken resample func * update recipe * fix style, add config docs * fix tests and multispeaker embd dim * remove pyworld * Make style and fix inference * Split tts tests * Fixup * Fixup * Fixup * Add argument names * Set "random" speaker in the model Tortoise/Bark * Use a diff f0_cache path for delightfull tts * Fix delightful speaker handling * Fix lint * Make style --------- Co-authored-by: loganhart420 <loganartpersonal@gmail.com> Co-authored-by: Eren Gölge <erogol@hotmail.com>
92 lines
3.0 KiB
Python
92 lines
3.0 KiB
Python
import torch
|
|
|
|
from TTS.tts.configs.delightful_tts_config import DelightfulTTSConfig
|
|
from TTS.tts.layers.delightful_tts.acoustic_model import AcousticModel
|
|
from TTS.tts.models.delightful_tts import DelightfulTtsArgs, VocoderConfig
|
|
from TTS.tts.utils.helpers import rand_segments
|
|
from TTS.tts.utils.text.tokenizer import TTSTokenizer
|
|
from TTS.vocoder.models.hifigan_generator import HifiganGenerator
|
|
|
|
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
|
|
|
args = DelightfulTtsArgs()
|
|
v_args = VocoderConfig()
|
|
|
|
|
|
config = DelightfulTTSConfig(
|
|
model_args=args,
|
|
# compute_f0=True,
|
|
# f0_cache_path=os.path.join(output_path, "f0_cache"),
|
|
text_cleaner="english_cleaners",
|
|
use_phonemes=True,
|
|
phoneme_language="en-us",
|
|
# phoneme_cache_path=os.path.join(output_path, "phoneme_cache"),
|
|
)
|
|
|
|
tokenizer, config = TTSTokenizer.init_from_config(config)
|
|
|
|
|
|
def test_acoustic_model():
|
|
dummy_tokens = torch.rand((1, 41)).long().to(device)
|
|
dummy_text_lens = torch.tensor([41]).to(device)
|
|
dummy_spec = torch.rand((1, 100, 207)).to(device)
|
|
dummy_spec_lens = torch.tensor([207]).to(device)
|
|
dummy_pitch = torch.rand((1, 1, 207)).long().to(device)
|
|
dummy_energy = torch.rand((1, 1, 207)).long().to(device)
|
|
|
|
args.out_channels = 100
|
|
args.num_mels = 100
|
|
|
|
acoustic_model = AcousticModel(args=args, tokenizer=tokenizer, speaker_manager=None).to(device)
|
|
|
|
output = acoustic_model(
|
|
tokens=dummy_tokens,
|
|
src_lens=dummy_text_lens,
|
|
mel_lens=dummy_spec_lens,
|
|
mels=dummy_spec,
|
|
pitches=dummy_pitch,
|
|
energies=dummy_energy,
|
|
attn_priors=None,
|
|
d_vectors=None,
|
|
speaker_idx=None,
|
|
)
|
|
assert list(output["model_outputs"].shape) == [1, 207, 100]
|
|
output["model_outputs"].sum().backward()
|
|
|
|
|
|
def test_hifi_decoder():
|
|
dummy_input = torch.rand((1, 207, 100)).to(device)
|
|
dummy_text_lens = torch.tensor([41]).to(device)
|
|
dummy_spec = torch.rand((1, 100, 207)).to(device)
|
|
dummy_spec_lens = torch.tensor([207]).to(device)
|
|
dummy_pitch = torch.rand((1, 1, 207)).long().to(device)
|
|
dummy_energy = torch.rand((1, 1, 207)).long().to(device)
|
|
|
|
waveform_decoder = HifiganGenerator(
|
|
100,
|
|
1,
|
|
v_args.resblock_type_decoder,
|
|
v_args.resblock_dilation_sizes_decoder,
|
|
v_args.resblock_kernel_sizes_decoder,
|
|
v_args.upsample_kernel_sizes_decoder,
|
|
v_args.upsample_initial_channel_decoder,
|
|
v_args.upsample_rates_decoder,
|
|
inference_padding=0,
|
|
cond_channels=0,
|
|
conv_pre_weight_norm=False,
|
|
conv_post_weight_norm=False,
|
|
conv_post_bias=False,
|
|
).to(device)
|
|
|
|
vocoder_input_slices, slice_ids = rand_segments( # pylint: disable=unused-variable
|
|
x=dummy_input.transpose(1, 2),
|
|
x_lengths=dummy_spec_lens,
|
|
segment_size=32,
|
|
let_short_samples=True,
|
|
pad_short=True,
|
|
)
|
|
|
|
outputs = waveform_decoder(x=vocoder_input_slices.detach())
|
|
assert list(outputs.shape) == [1, 1, 8192]
|
|
outputs.sum().backward()
|