forked from coqui-ai/TTS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pr/Edresson/731-rebased' into dev
- Loading branch information
Showing
55 changed files
with
2,623 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
{ | ||
"tts_models": { | ||
"multilingual":{ | ||
"multi-dataset":{ | ||
"your_tts":{ | ||
"description": "Your TTS model accompanying the paper https://arxiv.org/abs/2112.02418", | ||
"github_rls_url": "https://coqui.gateway.scarf.sh/v0.5.0_models/tts_models--multilingual--multi-dataset--your_tts.zip", | ||
"default_vocoder": null, | ||
"commit": "e9a1953e", | ||
"license": "CC BY-NC-ND 4.0", | ||
"contact": "[email protected]" | ||
} | ||
} | ||
}, | ||
"en": { | ||
"ek1": { | ||
"tacotron2": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
"""Find all the unique characters in a dataset""" | ||
import argparse | ||
import multiprocessing | ||
from argparse import RawTextHelpFormatter | ||
|
||
from tqdm.contrib.concurrent import process_map | ||
|
||
from TTS.config import load_config | ||
from TTS.tts.datasets import load_tts_samples | ||
from TTS.tts.utils.text import text2phone | ||
|
||
|
||
def compute_phonemes(item): | ||
try: | ||
text = item[0] | ||
language = item[-1] | ||
ph = text2phone(text, language, use_espeak_phonemes=c.use_espeak_phonemes).split("|") | ||
except: | ||
return [] | ||
return list(set(ph)) | ||
|
||
|
||
def main(): | ||
# pylint: disable=W0601 | ||
global c | ||
# pylint: disable=bad-option-value | ||
parser = argparse.ArgumentParser( | ||
description="""Find all the unique characters or phonemes in a dataset.\n\n""" | ||
""" | ||
Example runs: | ||
python TTS/bin/find_unique_chars.py --config_path config.json | ||
""", | ||
formatter_class=RawTextHelpFormatter, | ||
) | ||
parser.add_argument("--config_path", type=str, help="Path to dataset config file.", required=True) | ||
args = parser.parse_args() | ||
|
||
c = load_config(args.config_path) | ||
|
||
# load all datasets | ||
train_items, eval_items = load_tts_samples(c.datasets, eval_split=True) | ||
items = train_items + eval_items | ||
print("Num items:", len(items)) | ||
|
||
phonemes = process_map(compute_phonemes, items, max_workers=multiprocessing.cpu_count(), chunksize=15) | ||
phones = [] | ||
for ph in phonemes: | ||
phones.extend(ph) | ||
phones = set(phones) | ||
lower_phones = filter(lambda c: c.islower(), phones) | ||
phones_force_lower = [c.lower() for c in phones] | ||
phones_force_lower = set(phones_force_lower) | ||
|
||
print(f" > Number of unique phonemes: {len(phones)}") | ||
print(f" > Unique phonemes: {''.join(sorted(phones))}") | ||
print(f" > Unique lower phonemes: {''.join(sorted(lower_phones))}") | ||
print(f" > Unique all forced to lower phonemes: {''.join(sorted(phones_force_lower))}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import argparse | ||
import glob | ||
import multiprocessing | ||
import os | ||
import pathlib | ||
|
||
from tqdm.contrib.concurrent import process_map | ||
|
||
from TTS.utils.vad import get_vad_speech_segments, read_wave, write_wave | ||
|
||
|
||
def remove_silence(filepath): | ||
output_path = filepath.replace(os.path.join(args.input_dir, ""), os.path.join(args.output_dir, "")) | ||
# ignore if the file exists | ||
if os.path.exists(output_path) and not args.force: | ||
return | ||
|
||
# create all directory structure | ||
pathlib.Path(output_path).parent.mkdir(parents=True, exist_ok=True) | ||
# load wave | ||
audio, sample_rate = read_wave(filepath) | ||
|
||
# get speech segments | ||
segments = get_vad_speech_segments(audio, sample_rate, aggressiveness=args.aggressiveness) | ||
|
||
segments = list(segments) | ||
num_segments = len(segments) | ||
flag = False | ||
# create the output wave | ||
if num_segments != 0: | ||
for i, segment in reversed(list(enumerate(segments))): | ||
if i >= 1: | ||
if not flag: | ||
concat_segment = segment | ||
flag = True | ||
else: | ||
concat_segment = segment + concat_segment | ||
else: | ||
if flag: | ||
segment = segment + concat_segment | ||
# print("Saving: ", output_path) | ||
write_wave(output_path, segment, sample_rate) | ||
return | ||
else: | ||
print("> Just Copying the file to:", output_path) | ||
# if fail to remove silence just write the file | ||
write_wave(output_path, audio, sample_rate) | ||
return | ||
|
||
|
||
def preprocess_audios(): | ||
files = sorted(glob.glob(os.path.join(args.input_dir, args.glob), recursive=True)) | ||
print("> Number of files: ", len(files)) | ||
if not args.force: | ||
print("> Ignoring files that already exist in the output directory.") | ||
|
||
if files: | ||
# create threads | ||
num_threads = multiprocessing.cpu_count() | ||
process_map(remove_silence, files, max_workers=num_threads, chunksize=15) | ||
else: | ||
print("> No files Found !") | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
description="python remove_silence.py -i=VCTK-Corpus-bk/ -o=../VCTK-Corpus-removed-silence -g=wav48/*/*.wav -a=2" | ||
) | ||
parser.add_argument("-i", "--input_dir", type=str, default="../VCTK-Corpus", help="Dataset root dir") | ||
parser.add_argument( | ||
"-o", "--output_dir", type=str, default="../VCTK-Corpus-removed-silence", help="Output Dataset dir" | ||
) | ||
parser.add_argument("-f", "--force", default=False, action="store_true", help="Force the replace of exists files") | ||
parser.add_argument( | ||
"-g", | ||
"--glob", | ||
type=str, | ||
default="**/*.wav", | ||
help="path in glob format for acess wavs from input_dir. ex: wav48/*/*.wav", | ||
) | ||
parser.add_argument( | ||
"-a", | ||
"--aggressiveness", | ||
type=int, | ||
default=2, | ||
help="set its aggressiveness mode, which is an integer between 0 and 3. 0 is the least aggressive about filtering out non-speech, 3 is the most aggressive.", | ||
) | ||
args = parser.parse_args() | ||
preprocess_audios() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.