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!!")
def test_common_voice_preprocessor(self): root_path = get_tests_input_path() meta_file = "common_voice.tsv" items = common_voice(root_path, meta_file) assert items[0][0] == "Man sollte den Länderfinanzausgleich durch " \ "einen Bundesliga-Soli ersetzen." assert items[0][1] == os.path.join(get_tests_input_path(), "clips", "21fce545b24d9a5af0403b949e95e8dd3" "c10c4ff3e371f14e4d5b4ebf588670b7c" "9e618285fc872d94a89ed7f0217d9019f" "e5de33f1577b49dcd518eacf63c4b.wav") assert items[-1][0] == "Warum werden da keine strafrechtlichen " \ "Konsequenzen gezogen?" assert items[-1][1] == os.path.join(get_tests_input_path(), "clips", "ad2f69e053b0e20e01c82b9821fe5787f1" "cc8e4b0b97f0e4cab1e9a652c577169c82" "44fb222281a60ee3081854014113e04c4c" "a43643100b7c01dab0fac11974.wav")
def test_scaler(self): scaler_stats_path = os.path.join(get_tests_input_path(), 'scale_stats.npy') conf.audio['stats_path'] = scaler_stats_path conf.audio['preemphasis'] = 0.0 conf.audio['do_trim_silence'] = True conf.audio['signal_norm'] = True ap = AudioProcessor(**conf.audio) mel_mean, mel_std, linear_mean, linear_std, _ = ap.load_stats( scaler_stats_path) ap.setup_scaler(mel_mean, mel_std, linear_mean, linear_std) self.ap.signal_norm = False self.ap.preemphasis = 0.0 # test scaler forward and backward transforms wav = self.ap.load_wav(WAV_FILE) mel_reference = self.ap.melspectrogram(wav) mel_norm = ap.melspectrogram(wav) mel_denorm = ap._denormalize(mel_norm) assert abs(mel_reference - mel_denorm).max() < 1e-4
import os import unittest from TTS.tests import get_tests_path, get_tests_input_path, get_tests_output_path from TTS.utils.audio import AudioProcessor from TTS.utils.generic_utils import load_config TESTS_PATH = get_tests_path() OUT_PATH = os.path.join(get_tests_output_path(), "audio_tests") WAV_FILE = os.path.join(get_tests_input_path(), "example_1.wav") os.makedirs(OUT_PATH, exist_ok=True) conf = load_config(os.path.join(TESTS_PATH, 'test_config.json')) class TestAudio(unittest.TestCase): def __init__(self, *args, **kwargs): super(TestAudio, self).__init__(*args, **kwargs) self.ap = AudioProcessor(**conf.audio) def test_audio_synthesis(self): """ 1. load wav 2. set normalization parameters 3. extract mel-spec 4. invert to wav and save the output """ print(" > Sanity check for the process wav -> mel -> wav") def _test(max_norm, signal_norm, symmetric_norm, clip_norm): self.ap.max_norm = max_norm self.ap.signal_norm = signal_norm