Remove `/` prefix from the relative path (#2065)

This commit is contained in:
Eren Gölge 2022-10-10 13:32:27 +02:00 committed by GitHub
parent 843fa6f3fa
commit dae79b0acd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 29 deletions

View File

@ -1,3 +1,4 @@
import os
import sys import sys
from collections import Counter from collections import Counter
from pathlib import Path from pathlib import Path
@ -12,20 +13,16 @@ from TTS.tts.datasets.formatters import *
def split_dataset(items, eval_split_max_size=None, eval_split_size=0.01): def split_dataset(items, eval_split_max_size=None, eval_split_size=0.01):
"""Split a dataset into train and eval. Consider speaker distribution in multi-speaker training. """Split a dataset into train and eval. Consider speaker distribution in multi-speaker training.
Args: Args:
<<<<<<< HEAD items (List[List]):
items (List[List]): A list of samples. Each sample is a list of `[audio_path, text, speaker_id]`.
A list of samples. Each sample is a list of `[audio_path, text, speaker_id]`.
eval_split_max_size (int): eval_split_max_size (int):
Number maximum of samples to be used for evaluation in proportion split. Defaults to None (Disabled). Number maximum of samples to be used for evaluation in proportion split. Defaults to None (Disabled).
eval_split_size (float): eval_split_size (float):
If between 0.0 and 1.0 represents the proportion of the dataset to include in the evaluation set. If between 0.0 and 1.0 represents the proportion of the dataset to include in the evaluation set.
If > 1, represents the absolute number of evaluation samples. Defaults to 0.01 (1%). If > 1, represents the absolute number of evaluation samples. Defaults to 0.01 (1%).
=======
items (List[List]): A list of samples. Each sample is a list of `[text, audio_path, speaker_id]`.
>>>>>>> Fix docstring
""" """
speakers = [item["speaker_name"] for item in items] speakers = [item["speaker_name"] for item in items]
is_multi_speaker = len(set(speakers)) > 1 is_multi_speaker = len(set(speakers)) > 1
@ -64,10 +61,9 @@ def add_extra_keys(metadata, language, dataset_name):
# add language name # add language name
item["language"] = language item["language"] = language
# add unique audio name # add unique audio name
relfilepath = os.path.splitext(item["audio_file"].replace(item["root_path"], ""))[0] relfilepath = os.path.splitext(os.path.relpath(item["audio_file"], item["root_path"]))[0]
audio_unique_name = f"{dataset_name}#{relfilepath}" audio_unique_name = f"{dataset_name}#{relfilepath}"
item["audio_unique_name"] = audio_unique_name item["audio_unique_name"] = audio_unique_name
return metadata return metadata

View File

@ -33,7 +33,9 @@ def get_tests_data_path():
def get_tests_output_path(): def get_tests_output_path():
"""Returns the path to the directory for test outputs.""" """Returns the path to the directory for test outputs."""
return os.path.join(get_tests_path(), "outputs") path = os.path.join(get_tests_path(), "outputs")
os.makedirs(path, exist_ok=True)
return path
def run_cli(command): def run_cli(command):

View File

@ -1,5 +1,5 @@
{ {
"#/wavs/LJ001-0001": { "#wavs/LJ001-0001": {
"name": "ljspeech-0", "name": "ljspeech-0",
"embedding": [ "embedding": [
0.05539746582508087, 0.05539746582508087,
@ -260,7 +260,7 @@
-0.09469571709632874 -0.09469571709632874
] ]
}, },
"#/wavs/LJ001-0002": { "#wavs/LJ001-0002": {
"name": "ljspeech-1", "name": "ljspeech-1",
"embedding": [ "embedding": [
0.05539746582508087, 0.05539746582508087,
@ -521,7 +521,7 @@
-0.09469571709632874 -0.09469571709632874
] ]
}, },
"#/wavs/LJ001-0003": { "#wavs/LJ001-0003": {
"name": "ljspeech-2", "name": "ljspeech-2",
"embedding": [ "embedding": [
0.05539746582508087, 0.05539746582508087,
@ -782,7 +782,7 @@
-0.09469571709632874 -0.09469571709632874
] ]
}, },
"#/wavs/LJ001-0004": { "#wavs/LJ001-0004": {
"name": "ljspeech-3", "name": "ljspeech-3",
"embedding": [ "embedding": [
0.05539746582508087, 0.05539746582508087,
@ -1043,7 +1043,7 @@
-0.09469571709632874 -0.09469571709632874
] ]
}, },
"#/wavs/LJ001-0005": { "#wavs/LJ001-0005": {
"name": "ljspeech-4", "name": "ljspeech-4",
"embedding": [ "embedding": [
0.05539746582508087, 0.05539746582508087,
@ -1304,7 +1304,7 @@
-0.09469571709632874 -0.09469571709632874
] ]
}, },
"#/wavs/LJ001-0006": { "#wavs/LJ001-0006": {
"name": "ljspeech-5", "name": "ljspeech-5",
"embedding": [ "embedding": [
0.05539746582508087, 0.05539746582508087,
@ -1565,7 +1565,7 @@
-0.09469571709632874 -0.09469571709632874
] ]
}, },
"#/wavs/LJ001-0007": { "#wavs/LJ001-0007": {
"name": "ljspeech-6", "name": "ljspeech-6",
"embedding": [ "embedding": [
0.05539746582508087, 0.05539746582508087,
@ -1826,7 +1826,7 @@
-0.09469571709632874 -0.09469571709632874
] ]
}, },
"#/wavs/LJ001-0008": { "#wavs/LJ001-0008": {
"name": "ljspeech-7", "name": "ljspeech-7",
"embedding": [ "embedding": [
0.05539746582508087, 0.05539746582508087,
@ -2087,7 +2087,7 @@
-0.09469571709632874 -0.09469571709632874
] ]
}, },
"#/wavs/LJ001-0009": { "#wavs/LJ001-0009": {
"name": "ljspeech-8", "name": "ljspeech-8",
"embedding": [ "embedding": [
0.05539746582508087, 0.05539746582508087,
@ -2348,7 +2348,7 @@
-0.09469571709632874 -0.09469571709632874
] ]
}, },
"#/wavs/LJ001-0010": { "#wavs/LJ001-0010": {
"name": "ljspeech-9", "name": "ljspeech-9",
"embedding": [ "embedding": [
0.05539746582508087, 0.05539746582508087,

View File

@ -1,7 +1,7 @@
import os import os
import unittest import unittest
from tests import get_tests_output_path from tests import get_tests_input_path
from TTS.config import load_config from TTS.config import load_config
from TTS.tts.models import setup_model from TTS.tts.models import setup_model
from TTS.utils.io import save_checkpoint from TTS.utils.io import save_checkpoint
@ -12,14 +12,14 @@ class SynthesizerTest(unittest.TestCase):
# pylint: disable=R0201 # pylint: disable=R0201
def _create_random_model(self): def _create_random_model(self):
# pylint: disable=global-statement # pylint: disable=global-statement
config = load_config(os.path.join(get_tests_output_path(), "dummy_model_config.json")) config = load_config(os.path.join(get_tests_input_path(), "dummy_model_config.json"))
model = setup_model(config) model = setup_model(config)
output_path = os.path.join(get_tests_output_path()) output_path = os.path.join(get_tests_input_path())
save_checkpoint(config, model, None, None, 10, 1, output_path) save_checkpoint(config, model, None, None, 10, 1, output_path)
def test_in_out(self): def test_in_out(self):
self._create_random_model() self._create_random_model()
tts_root_path = get_tests_output_path() tts_root_path = get_tests_input_path()
tts_checkpoint = os.path.join(tts_root_path, "checkpoint_10.pth") tts_checkpoint = os.path.join(tts_root_path, "checkpoint_10.pth")
tts_config = os.path.join(tts_root_path, "dummy_model_config.json") tts_config = os.path.join(tts_root_path, "dummy_model_config.json")
synthesizer = Synthesizer(tts_checkpoint, tts_config, None, None) synthesizer = Synthesizer(tts_checkpoint, tts_config, None, None)