Skip to content

Option to save audio in the original format when exporting to shar#1422

Merged
pzelasko merged 2 commits into
lhotse-speech:masterfrom
anteju:pr/shar-audio-original
Nov 23, 2024
Merged

Option to save audio in the original format when exporting to shar#1422
pzelasko merged 2 commits into
lhotse-speech:masterfrom
anteju:pr/shar-audio-original

Conversation

@anteju

@anteju anteju commented Nov 22, 2024

Copy link
Copy Markdown
Collaborator

Added an option to use the original audio format when exporting to shar.

Example

Use --audio original when calling lhotse shar export.
For example:

lhotse shar export --num-jobs 1 --verbose --shard-size 2 --audio original --no-shuffle ${INPUT_MANIFEST} ${OUTPUT_DIR}

@anteju anteju requested a review from pzelasko November 22, 2024 03:10
@anteju anteju force-pushed the pr/shar-audio-original branch from 36e005e to abb7fcb Compare November 22, 2024 03:10
Comment thread lhotse/testing/dummies.py
# generate 1kHz sine wave
f_sine = 1000
assert f_sine < sampling_rate / 2, "Sine wave frequency exceeds Nyquist frequency"
data = torch.sin(2 * np.pi * f_sine / sampling_rate * torch.arange(num_samples))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pzelasko, including a bugfix here: frequency was not normalized.

Comment thread test/shar/test_write.py Outdated
],
)
# TODO: check if this should be removed?
def test_audio_tar_writer(tmp_path: Path, format: str):

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pzelasko, this test is repeated twice test_audio_tar_writer, so only the latter is running.
It seems that this (top) version is older, but please check if one should be removed (or renamed if both should be kept).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well spotted! yes, please remove it. thanks

@anteju anteju force-pushed the pr/shar-audio-original branch from 8dadd01 to a3e2bf6 Compare November 22, 2024 03:34

@pzelasko pzelasko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! Let's remove that duplicated test you found and merge.

@pzelasko pzelasko added this to the v1.29.0 milestone Nov 22, 2024
@pzelasko pzelasko merged commit 36ce63e into lhotse-speech:master Nov 23, 2024
yfyeung pushed a commit to yfyeung/lhotse that referenced this pull request Jan 8, 2025
…hotse-speech#1422)

* Option to save audio in the original format when exporting to shar

* Removed duplicate test
nshmyrev pushed a commit to alphacep/lhotse that referenced this pull request Aug 15, 2025
…hotse-speech#1422)

* Option to save audio in the original format when exporting to shar

* Removed duplicate test
racoiaws pushed a commit to racoiaws/lhotse that referenced this pull request Sep 17, 2025
…hotse-speech#1422)

* Option to save audio in the original format when exporting to shar

* Removed duplicate test
HsunGong pushed a commit to HsunGong/lhotse that referenced this pull request Dec 16, 2025
…hotse-speech#1422)

* Option to save audio in the original format when exporting to shar

* Removed duplicate test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants