Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions preprocessor/aishell3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import librosa
import numpy as np
from scipy.io import wavfile
import soundfile as sf
from tqdm import tqdm


def prepare_align(config):
in_dir = config["path"]["corpus_path"]
out_dir = config["path"]["raw_path"]
sampling_rate = config["preprocessing"]["audio"]["sampling_rate"]
max_wav_value = config["preprocessing"]["audio"]["max_wav_value"]
# max_wav_value = config["preprocessing"]["audio"]["max_wav_value"]
for dataset in ["train", "test"]:
print("Processing {}ing set...".format(dataset))
with open(os.path.join(in_dir, dataset, "content.txt"), encoding="utf-8") as f:
Expand All @@ -22,11 +22,12 @@ def prepare_align(config):
if os.path.exists(wav_path):
os.makedirs(os.path.join(out_dir, speaker), exist_ok=True)
wav, _ = librosa.load(wav_path, sampling_rate)
wav = wav / max(abs(wav)) * max_wav_value
wavfile.write(
wav = wav / max(abs(wav)) # * max_wav_value
sf.write(
os.path.join(out_dir, speaker, wav_name),
wav,
sampling_rate,
wav.astype(np.int16),
subtype='PCM_16'
)
with open(
os.path.join(out_dir, speaker, "{}.lab".format(wav_name[:11])),
Expand Down
11 changes: 6 additions & 5 deletions preprocessor/libritts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import librosa
import numpy as np
from scipy.io import wavfile
import soundfile as sf
from tqdm import tqdm

from text import _clean_text
Expand All @@ -12,7 +12,7 @@ def prepare_align(config):
in_dir = config["path"]["corpus_path"]
out_dir = config["path"]["raw_path"]
sampling_rate = config["preprocessing"]["audio"]["sampling_rate"]
max_wav_value = config["preprocessing"]["audio"]["max_wav_value"]
# max_wav_value = config["preprocessing"]["audio"]["max_wav_value"]
cleaners = config["preprocessing"]["text"]["text_cleaners"]
for speaker in tqdm(os.listdir(in_dir)):
for chapter in os.listdir(os.path.join(in_dir, speaker)):
Expand All @@ -32,11 +32,12 @@ def prepare_align(config):

os.makedirs(os.path.join(out_dir, speaker), exist_ok=True)
wav, _ = librosa.load(wav_path, sampling_rate)
wav = wav / max(abs(wav)) * max_wav_value
wavfile.write(
wav = wav / max(abs(wav)) # * max_wav_value
sf.write(
os.path.join(out_dir, speaker, "{}.wav".format(base_name)),
wav,
sampling_rate,
wav.astype(np.int16),
subtype='PCM_16'
)
with open(
os.path.join(out_dir, speaker, "{}.lab".format(base_name)),
Expand Down
11 changes: 6 additions & 5 deletions preprocessor/ljspeech.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import librosa
import numpy as np
from scipy.io import wavfile
import soundfile as sf
from tqdm import tqdm

from text import _clean_text
Expand All @@ -12,7 +12,7 @@ def prepare_align(config):
in_dir = config["path"]["corpus_path"]
out_dir = config["path"]["raw_path"]
sampling_rate = config["preprocessing"]["audio"]["sampling_rate"]
max_wav_value = config["preprocessing"]["audio"]["max_wav_value"]
# max_wav_value = config["preprocessing"]["audio"]["max_wav_value"]
cleaners = config["preprocessing"]["text"]["text_cleaners"]
speaker = "LJSpeech"
with open(os.path.join(in_dir, "metadata.csv"), encoding="utf-8") as f:
Expand All @@ -26,11 +26,12 @@ def prepare_align(config):
if os.path.exists(wav_path):
os.makedirs(os.path.join(out_dir, speaker), exist_ok=True)
wav, _ = librosa.load(wav_path, sampling_rate)
wav = wav / max(abs(wav)) * max_wav_value
wavfile.write(
wav = wav / max(abs(wav)) # * max_wav_value
sf.write(
os.path.join(out_dir, speaker, "{}.wav".format(base_name)),
wav,
sampling_rate,
wav.astype(np.int16),
subtype='PCM_16'
)
with open(
os.path.join(out_dir, speaker, "{}.lab".format(base_name)),
Expand Down