Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dataset): Fix bug when make shard.list for *.flac #1933

Merged
merged 1 commit into from
Aug 1, 2023
Merged
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
15 changes: 13 additions & 2 deletions tools/make_shard_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,21 @@ def write_tar_file(data_list,
suffix = wav.split('.')[-1]
assert suffix in AUDIO_FORMAT_SETS
if no_segments:
# read & resample
ts = time.time()
with open(wav, 'rb') as fin:
data = fin.read()
audio, sample_rate = sox.load(wav, normalize=False)
if sample_rate != resample:
audio = torchaudio.transforms.Resample(
sample_rate, resample)(audio)
read_time += (time.time() - ts)
# change format to wav
ts = time.time()
f = io.BytesIO()
sox.save(f, audio, resample, format="wav", bits_per_sample=16)
suffix = "wav"
f.seek(0)
data = f.read()
save_time += (time.time() - ts)
else:
if wav != prev_wav:
ts = time.time()
Expand Down