mirror of
https://github.com/wassname/TTS.git
synced 2026-09-09 11:16:00 +08:00
Make style
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
from TTS.tts.datasets import load_tts_samples
|
||||
from TTS.config.shared_configs import BaseDatasetConfig
|
||||
from TTS.tts.utils.languages import get_language_weighted_sampler
|
||||
import torch
|
||||
import functools
|
||||
|
||||
import torch
|
||||
|
||||
from TTS.config.shared_configs import BaseDatasetConfig
|
||||
from TTS.tts.datasets import load_tts_samples
|
||||
from TTS.tts.utils.languages import get_language_weighted_sampler
|
||||
|
||||
# Fixing random state to avoid random fails
|
||||
torch.manual_seed(0)
|
||||
|
||||
@@ -25,18 +27,19 @@ dataset_config_pt = BaseDatasetConfig(
|
||||
|
||||
# Adding the EN samples twice to create an unbalanced dataset
|
||||
train_samples, eval_samples = load_tts_samples(
|
||||
[dataset_config_en, dataset_config_en, dataset_config_pt],
|
||||
eval_split=True
|
||||
[dataset_config_en, dataset_config_en, dataset_config_pt], eval_split=True
|
||||
)
|
||||
|
||||
|
||||
def is_balanced(lang_1, lang_2):
|
||||
return 0.85 < lang_1/lang_2 < 1.2
|
||||
return 0.85 < lang_1 / lang_2 < 1.2
|
||||
|
||||
|
||||
random_sampler = torch.utils.data.RandomSampler(train_samples)
|
||||
ids = functools.reduce(lambda a, b: a + b, [list(random_sampler) for i in range(100)])
|
||||
en, pt = 0, 0
|
||||
for index in ids:
|
||||
if train_samples[index][3] == 'en':
|
||||
if train_samples[index][3] == "en":
|
||||
en += 1
|
||||
else:
|
||||
pt += 1
|
||||
@@ -47,7 +50,7 @@ weighted_sampler = get_language_weighted_sampler(train_samples)
|
||||
ids = functools.reduce(lambda a, b: a + b, [list(weighted_sampler) for i in range(100)])
|
||||
en, pt = 0, 0
|
||||
for index in ids:
|
||||
if train_samples[index][3] == 'en':
|
||||
if train_samples[index][3] == "en":
|
||||
en += 1
|
||||
else:
|
||||
pt += 1
|
||||
|
||||
Reference in New Issue
Block a user