chore: import upstream snapshot with attribution
Create PR to main with cherry-pick from release / cherry-pick (push) Failing after 0s
CICD NeMo / pre-flight (push) Failing after 0s
CICD NeMo / configure (push) Has been skipped
Build, validate, and release Neural Modules / pre-flight (push) Failing after 1s
CICD NeMo / code-linting (push) Has been skipped
Build, validate, and release Neural Modules / release (push) Has been skipped
Build, validate, and release Neural Modules / release-summary (push) Has been cancelled
CICD NeMo / cicd-test-container-build (push) Has been cancelled
CICD NeMo / cicd-import-tests (push) Has been cancelled
CICD NeMo / L0_Setup_Test_Data_And_Models (push) Has been cancelled
CICD NeMo / cicd-main-unit-tests (push) Has been cancelled
CICD NeMo / cicd-main-speech (push) Has been cancelled
CICD NeMo / Nemo_CICD_Test (push) Has been cancelled
CICD NeMo / Coverage (e2e) (push) Has been cancelled
CICD NeMo / Coverage (unit-test) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
CICD NeMo / cicd-wait-in-queue (push) Has been cancelled
Create PR to main with cherry-pick from release / cherry-pick (push) Failing after 0s
CICD NeMo / pre-flight (push) Failing after 0s
CICD NeMo / configure (push) Has been skipped
Build, validate, and release Neural Modules / pre-flight (push) Failing after 1s
CICD NeMo / code-linting (push) Has been skipped
Build, validate, and release Neural Modules / release (push) Has been skipped
Build, validate, and release Neural Modules / release-summary (push) Has been cancelled
CICD NeMo / cicd-test-container-build (push) Has been cancelled
CICD NeMo / cicd-import-tests (push) Has been cancelled
CICD NeMo / L0_Setup_Test_Data_And_Models (push) Has been cancelled
CICD NeMo / cicd-main-unit-tests (push) Has been cancelled
CICD NeMo / cicd-main-speech (push) Has been cancelled
CICD NeMo / Nemo_CICD_Test (push) Has been cancelled
CICD NeMo / Coverage (e2e) (push) Has been cancelled
CICD NeMo / Coverage (unit-test) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
CICD NeMo / cicd-wait-in-queue (push) Has been cancelled
This commit is contained in:
+49
@@ -0,0 +1,49 @@
|
||||
name: "ds_for_fastpitch_align"
|
||||
|
||||
manifest_filepath: "train_manifest.json"
|
||||
sup_data_path: "sup_data"
|
||||
sup_data_types: [ "align_prior_matrix", "pitch" ]
|
||||
phoneme_dict_path: "scripts/tts_dataset_files/zh/24finals/pinyin_dict_nv_22.10.txt"
|
||||
|
||||
dataset:
|
||||
_target_: nemo.collections.tts.data.dataset.TTSDataset
|
||||
manifest_filepath: ${manifest_filepath}
|
||||
sample_rate: 22050
|
||||
sup_data_path: ${sup_data_path}
|
||||
sup_data_types: ${sup_data_types}
|
||||
n_fft: 1024
|
||||
win_length: 1024
|
||||
hop_length: 256
|
||||
window: "hann"
|
||||
n_mels: 80
|
||||
lowfreq: 0
|
||||
highfreq: null
|
||||
max_duration: null
|
||||
min_duration: 0.1
|
||||
ignore_file: null
|
||||
trim: true
|
||||
trim_top_db: 50
|
||||
trim_frame_length: 1024
|
||||
trim_hop_length: 256
|
||||
pitch_fmin: 65.40639132514966
|
||||
pitch_fmax: 2093.004522404789
|
||||
|
||||
text_normalizer:
|
||||
_target_: nemo_text_processing.text_normalization.normalize.Normalizer
|
||||
lang: zh
|
||||
input_case: cased
|
||||
|
||||
text_normalizer_call_kwargs:
|
||||
verbose: false
|
||||
punct_pre_process: true
|
||||
punct_post_process: true
|
||||
|
||||
text_tokenizer:
|
||||
_target_: nemo.collections.common.tokenizers.text_to_speech.tts_tokenizers.ChinesePhonemesTokenizer
|
||||
punct: true
|
||||
apostrophe: true
|
||||
pad_with_space: true
|
||||
g2p:
|
||||
_target_: nemo.collections.tts.g2p.models.zh_cn_pinyin.ChineseG2p
|
||||
phoneme_dict: ${phoneme_dict_path}
|
||||
word_segmenter: jieba # Only jieba is supported now.
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
from opencc import OpenCC
|
||||
|
||||
try:
|
||||
from nemo_text_processing.text_normalization.normalize import Normalizer
|
||||
except (ImportError, ModuleNotFoundError):
|
||||
raise ModuleNotFoundError(
|
||||
"The package `nemo_text_processing` was not installed in this environment. Please refer to"
|
||||
" https://github.com/NVIDIA/NeMo-text-processing and install this package before using "
|
||||
"this script"
|
||||
)
|
||||
|
||||
|
||||
def get_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Prepare SF_bilingual dataset and create manifests with predefined split'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--data-root",
|
||||
type=Path,
|
||||
help="where the dataset will reside",
|
||||
default="./DataChinese/sf_bilingual_speech_zh_en_vv1/SF_bilingual/",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--manifests-path", type=Path, help="where the resulting manifests files will reside", default="./"
|
||||
)
|
||||
parser.add_argument("--val-size", default=0.01, type=float, help="eval set split")
|
||||
parser.add_argument("--test-size", default=0.01, type=float, help="test set split")
|
||||
parser.add_argument(
|
||||
"--seed-for-ds-split",
|
||||
default=100,
|
||||
type=float,
|
||||
help="Seed for deterministic split of train/dev/test, NVIDIA's default is 100",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
||||
def __process_transcript(file_path: str):
|
||||
# Create zh-TW to zh-simplify converter
|
||||
cc = OpenCC('t2s')
|
||||
# Create normalizer
|
||||
text_normalizer = Normalizer(
|
||||
lang="zh",
|
||||
input_case="cased",
|
||||
overwrite_cache=True,
|
||||
cache_dir=str(file_path / "cache_dir"),
|
||||
)
|
||||
text_normalizer_call_kwargs = {"punct_pre_process": True, "punct_post_process": True}
|
||||
normalizer_call = lambda x: text_normalizer.normalize(x, **text_normalizer_call_kwargs)
|
||||
entries = []
|
||||
i = 0
|
||||
with open(file_path / "text_SF.txt", encoding="utf-8") as fin:
|
||||
for line in fin:
|
||||
content = line.split()
|
||||
wav_name, text = content[0], "".join(content[1:])
|
||||
wav_name = wav_name.replace(u'\ufeff', '')
|
||||
# WAR: change DL to SF, e.g. real wave file com_SF_ce2727.wav, wav name in text_SF
|
||||
# com_DL_ce2727. It would be fixed through the dataset in the future.
|
||||
wav_name = wav_name.replace('DL', 'SF')
|
||||
wav_file = file_path / "wavs" / (wav_name + ".wav")
|
||||
assert os.path.exists(wav_file), f"{wav_file} not found!"
|
||||
duration = subprocess.check_output(["soxi", "-D", str(wav_file)])
|
||||
simplified_text = cc.convert(text)
|
||||
normalized_text = normalizer_call(simplified_text)
|
||||
entry = {
|
||||
'audio_filepath': os.path.abspath(wav_file),
|
||||
'duration': float(duration),
|
||||
'text': text,
|
||||
'normalized_text': normalized_text,
|
||||
}
|
||||
|
||||
i += 1
|
||||
entries.append(entry)
|
||||
return entries
|
||||
|
||||
|
||||
def __process_data(dataset_path, val_size, test_size, seed_for_ds_split, manifests_dir):
|
||||
entries = __process_transcript(dataset_path)
|
||||
|
||||
random.Random(seed_for_ds_split).shuffle(entries)
|
||||
|
||||
train_size = 1.0 - val_size - test_size
|
||||
train_entries, validate_entries, test_entries = np.split(
|
||||
entries, [int(len(entries) * train_size), int(len(entries) * (train_size + val_size))]
|
||||
)
|
||||
|
||||
assert len(train_entries) > 0, "Not enough data for train, val and test"
|
||||
|
||||
def save(p, data):
|
||||
with open(p, 'w') as f:
|
||||
for d in data:
|
||||
f.write(json.dumps(d) + '\n')
|
||||
|
||||
save(manifests_dir / "train_manifest.json", train_entries)
|
||||
save(manifests_dir / "val_manifest.json", validate_entries)
|
||||
save(manifests_dir / "test_manifest.json", test_entries)
|
||||
|
||||
|
||||
def main():
|
||||
args = get_args()
|
||||
dataset_root = args.data_root
|
||||
dataset_root.mkdir(parents=True, exist_ok=True)
|
||||
__process_data(
|
||||
dataset_root,
|
||||
args.val_size,
|
||||
args.test_size,
|
||||
args.seed_for_ds_split,
|
||||
args.manifests_path,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user