diff --git a/TTS/bin/resample.py b/TTS/bin/resample.py index 42de7080..54599b8e 100644 --- a/TTS/bin/resample.py +++ b/TTS/bin/resample.py @@ -1,8 +1,8 @@ import argparse import glob import os -import shutil import librosa +from distutils.dir_util import copy_tree from argparse import RawTextHelpFormatter from multiprocessing import Pool from tqdm import tqdm diff --git a/tests/test_resample.sh b/tests/test_resample.sh new file mode 100755 index 00000000..ddae17ad --- /dev/null +++ b/tests/test_resample.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -xe +BASEDIR=$(dirname "$0") +TARGET_SR=16000 +echo "$BASEDIR" +#run the resample script +python TTS/bin/resample.py --input_dir $BASEDIR/data/ljspeech --output_dir $BASEDIR/outputs/resample_tests --output_sr $TARGET_SR +#check samplerate of output +OUT_SR=$( (echo "import librosa" ; echo "y, sr = librosa.load('"$BASEDIR"/outputs/resample_tests/wavs/LJ001-0012.wav', sr=None)" ; echo "print(sr)") | python ) +OUT_SR=$(($OUT_SR + 0)) +if [[ $OUT_SR -ne $TARGET_SR ]]; then + echo "Missmatch between target and output sample rates" + exit 1 +fi +#cleaning up +rm -rf $BASEDIR/outputs/resample_tests diff --git a/tests/test_vocoder_pqmf.py b/tests/test_vocoder_pqmf.py index 1f141dd2..94e6ed01 100644 --- a/tests/test_vocoder_pqmf.py +++ b/tests/test_vocoder_pqmf.py @@ -4,7 +4,7 @@ import torch import soundfile as sf from librosa.core import load -from tests import get_tests_path, get_tests_input_path +from tests import get_tests_path, get_tests_input_path, get_tests_output_path from TTS.vocoder.layers.pqmf import PQMF @@ -24,4 +24,4 @@ def test_pqmf(): print(w2_.max()) print(w2_.min()) print(w2_.mean()) - sf.write('pqmf_output.wav', w2_.flatten().detach(), sr) + sf.write(os.path.join(get_tests_output_path(),'pqmf_output.wav'), w2_.flatten().detach(), sr) diff --git a/tests/test_vocoder_tf_pqmf.py b/tests/test_vocoder_tf_pqmf.py index a1c4f692..c80def60 100644 --- a/tests/test_vocoder_tf_pqmf.py +++ b/tests/test_vocoder_tf_pqmf.py @@ -4,7 +4,7 @@ import tensorflow as tf import soundfile as sf from librosa.core import load -from tests import get_tests_path, get_tests_input_path +from tests import get_tests_path, get_tests_input_path, get_tests_output_path from TTS.vocoder.tf.layers.pqmf import PQMF @@ -25,4 +25,4 @@ def test_pqmf(): print(w2_.max()) print(w2_.min()) print(w2_.mean()) - sf.write('tf_pqmf_output.wav', w2_.flatten(), sr) + sf.write(os.path.join(get_tests_output_path(),'tf_pqmf_output.wav'), w2_.flatten(), sr)