wave_downsampler
Author: Heli Qi Affiliation: NAIST Date: 2022.07
main(src_file, spk_file, tgt_path, sample_rate=16000, ncpu=8)
Downsample the waveforms specified in the source file to the desired sample rate, and save the downsampled waveforms in the target directory. The function also copies the statistic information from the source directory to the target directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src_file
|
str
|
The path to the source file containing waveform paths and their indices. |
required |
spk_file
|
str
|
The path to the file containing speaker information, or None if speaker information is not used. |
required |
tgt_path
|
str
|
The target directory path where the downsampled waveform files will be saved. |
required |
sample_rate
|
int
|
The desired sample rate for the output waveforms. |
16000
|
ncpu
|
int
|
The number of CPU cores to use for parallel processing. |
8
|
Returns:
| Type | Description |
|---|---|
|
None |
Source code in speechain/datasets/pyscripts/wave_downsampler.py
waveform_downsample(idx2src_wav, tgt_path, sample_rate)
Downsample the input waveforms to the given sample rate and save the downsampled waveforms in the target directory. Note that sf.read(path) + sf.write(path, sample_rate) doesn't work because the values of waveforms remain the same. The only thing that is changed is the sampling rate of the waveform files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx2src_wav
|
List[List[str]]
|
A list of source waveform file information, where each element is a list containing the index, source waveform path, and speaker ID (if available). |
required |
tgt_path
|
str
|
The target directory path where the downsampled waveform files will be saved. |
required |
sample_rate
|
int
|
The desired sample rate for the output waveforms. |
required |
Returns:
| Type | Description |
|---|---|
List[List[str]]
|
List[List[str]]: A list of target waveform file information, where each element is a list containing the index and target waveform path. |