Repository navigation
Include WAV recordings in mixed-format Babel manifests #1586
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
base: master
Are you sure you want to change the base?
Changes from all commits
33dc9b6
60d90f5
6ce4b38
9e0e6e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| from pathlib import Path | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove the test file - we don't add tests for recipes in this repo
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the review. I’ll address this in the existing pull request and rerun the focused validation. |
||
|
|
||
| from lhotse import AudioSource, Recording | ||
| from lhotse.recipes.babel import prepare_single_babel_language | ||
|
|
||
|
|
||
| def test_prepare_single_babel_language_includes_sph_and_wav(monkeypatch, tmp_path): | ||
| stems_and_suffixes = ( | ||
| ("BABEL_BP_401_10001_20111024_205740_inLine", ".sph"), | ||
| ("BABEL_BP_401_10002_20111024_205740_inLine", ".wav"), | ||
| ) | ||
| for split in ("dev", "training"): | ||
| audio_dir = tmp_path / "conversational" / split / "audio" | ||
| text_dir = tmp_path / "conversational" / split / "transcription" | ||
| audio_dir.mkdir(parents=True) | ||
| text_dir.mkdir(parents=True) | ||
|
|
||
| for stem, suffix in stems_and_suffixes: | ||
| audio_path = audio_dir / f"{stem}{suffix}" | ||
| audio_path.touch() | ||
| (text_dir / f"{stem}.txt").write_text("[0.0]\nhello\n[1.0]\n") | ||
|
|
||
| def fake_recording_from_file(path): | ||
| path = Path(path) | ||
| return Recording( | ||
| id=path.stem, | ||
| sources=[AudioSource(type="file", channels=[0], source=str(path))], | ||
| sampling_rate=8000, | ||
| num_samples=8000, | ||
| duration=1.0, | ||
| ) | ||
|
|
||
| monkeypatch.setattr(Recording, "from_file", staticmethod(fake_recording_from_file)) | ||
|
|
||
| manifests = prepare_single_babel_language(tmp_path, no_eval_ok=True) | ||
|
|
||
| for split in ("dev", "training"): | ||
| recordings = manifests[split]["recordings"] | ||
| assert not recordings.is_lazy | ||
| assert set(recordings.ids) == {stem for stem, _ in stems_and_suffixes} | ||
| assert {Path(r.sources[0].source).suffix for r in recordings} == { | ||
| ".sph", | ||
| ".wav", | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this change functionally identical?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. The original code only matched
*.sph, so WAV recordings were omitted. This change discovers both*.sphand*.wavfiles in one per-split RecordingSet and adds mixed-format regression coverage.