"fs/git@developer.sourcefind.cn:OpenDAS/ollama.git" did not exist on "903b1fc97f37fda25fd233ed853355acfc0f63cf"
Unverified Commit 70fd2f3d authored by Aziz's avatar Aziz Committed by GitHub
Browse files

Refactor vctk unittest (#1134)

parent 93c3025f
...@@ -12,7 +12,7 @@ from torchaudio_unittest.common_utils import ( ...@@ -12,7 +12,7 @@ from torchaudio_unittest.common_utils import (
) )
# Used to generate a unique utterance for each dummy audio file # Used to generate a unique utterance for each dummy audio file
UTTERANCE = [ _UTTERANCE = [
'Please call Stella', 'Please call Stella',
'Ask her to bring these things', 'Ask her to bring these things',
'with her from the store', 'with her from the store',
...@@ -27,16 +27,12 @@ UTTERANCE = [ ...@@ -27,16 +27,12 @@ UTTERANCE = [
] ]
class TestVCTK(TempDirMixin, TorchaudioTestCase): def get_mock_dataset(root_dir):
backend = 'default' """
root_dir: root directory of the mocked data
root_dir = None """
samples = [] mocked_samples = []
dataset_dir = os.path.join(root_dir, 'VCTK-Corpus-0.92')
@classmethod
def setUpClass(cls):
cls.root_dir = cls.get_base_temp_dir()
dataset_dir = os.path.join(cls.root_dir, 'VCTK-Corpus-0.92')
os.makedirs(dataset_dir, exist_ok=True) os.makedirs(dataset_dir, exist_ok=True)
sample_rate = 48000 sample_rate = 48000
seed = 0 seed = 0
...@@ -63,7 +59,7 @@ class TestVCTK(TempDirMixin, TorchaudioTestCase): ...@@ -63,7 +59,7 @@ class TestVCTK(TempDirMixin, TorchaudioTestCase):
save_wav(audio_file_path, data, sample_rate) save_wav(audio_file_path, data, sample_rate)
txt_file_path = os.path.join(file_dir, filename[:-5] + '.txt') txt_file_path = os.path.join(file_dir, filename[:-5] + '.txt')
utterance = UTTERANCE[utterance_id - 1] utterance = _UTTERANCE[utterance_id - 1]
with open(txt_file_path, 'w') as f: with open(txt_file_path, 'w') as f:
f.write(utterance) f.write(utterance)
...@@ -74,9 +70,21 @@ class TestVCTK(TempDirMixin, TorchaudioTestCase): ...@@ -74,9 +70,21 @@ class TestVCTK(TempDirMixin, TorchaudioTestCase):
speaker_id, speaker_id,
utterance_id utterance_id
) )
cls.samples.append(sample) mocked_samples.append(sample)
seed += 1 seed += 1
return mocked_samples
class TestVCTK(TempDirMixin, TorchaudioTestCase):
backend = 'default'
root_dir = None
samples = []
@classmethod
def setUpClass(cls):
cls.root_dir = cls.get_base_temp_dir()
cls.samples = get_mock_dataset(cls.root_dir)
def _test_vctk(self, dataset): def _test_vctk(self, dataset):
num_samples = 0 num_samples = 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment