tacotron2_pipeline_test.py 818 Bytes
Newer Older
moto's avatar
moto committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from torchaudio.pipelines import (
    TACOTRON2_GRIFFINLIM_CHAR_LJSPEECH,
    TACOTRON2_GRIFFINLIM_PHONE_LJSPEECH,
    TACOTRON2_WAVERNN_CHAR_LJSPEECH,
    TACOTRON2_WAVERNN_PHONE_LJSPEECH,
)
import pytest


@pytest.mark.parametrize(
    'bundle',
    [
        TACOTRON2_GRIFFINLIM_CHAR_LJSPEECH,
        TACOTRON2_GRIFFINLIM_PHONE_LJSPEECH,
        TACOTRON2_WAVERNN_CHAR_LJSPEECH,
        TACOTRON2_WAVERNN_PHONE_LJSPEECH,
    ]
)
def test_tts_models(bundle):
    """Smoke test of TTS pipeline"""
    text = "Hello world! Text to Speech!"

    processor = bundle.get_text_processor()
    tacotron2 = bundle.get_tacotron2()
    vocoder = bundle.get_vocoder()
    processed, lengths = processor(text)
    mel_spec, lengths, _ = tacotron2.infer(processed, lengths)
    waveforms, lengths = vocoder(mel_spec, lengths)