-
Notifications
You must be signed in to change notification settings - Fork 221
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
add chunked sph file processing #367
add chunked sph file processing #367
Conversation
lhotse/audio.py
Outdated
@@ -15,6 +15,7 @@ | |||
from typing import Any, Callable, Dict, Iterable, List, Mapping, NamedTuple, Optional, Sequence, Tuple, Union | |||
|
|||
import numpy as np | |||
import soundfile as sf |
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.
Please stick to a local import, otherwise building the docs is going to fail (the import tries to load libsndfile.so into memory which is not available on read-the-docs servers).
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.
Oh, sorry, will move it back
@@ -231,8 +232,7 @@ def from_file( | |||
else: | |||
try: | |||
# Try to parse the file using pysoundfile first. | |||
import soundfile | |||
info = soundfile.info(str(path)) | |||
info = sf.info(str(path)) |
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.
is there a missing case for using sph_info
?
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.
Right, good catch.
Thanks that looks good! Please address my comments and we'll merge it. |
Co-authored-by: Piotr Żelasko <petezor@gmail.com>
Import and SPHERE file handling in Recording are fixed. |
@pzelasko Can we merge this as I want to add Fisher English that will depend on this PR? |
Hmm, the tests are failing because there is no sph2pipe in the CI. Let me try to add it, and then we can merge. |
@videodanchik I made a PR #370 that makes it easy to install sph2pipe in a way that enables Lhotse to auto-discover it. I'll wait for Dan to say what he thinks; as soon as it's merged, we can try re-run the CI for your PR again with no code changes -- it should help. |
@pzelasko Oh, sorry that it caused this additional effort, I haven't even realized that you can't install |
no worries, I think that it’s better for Lhotse users not to have to worry about how to find these esoteric programs… |
Seems to work now, merging. |
This MR aims to provide an optimal way for reading SPHERE files, avoiding reading the whole file, when offset and duration are provided. These parameters can be specified directly in
sph2pipe
command which helps to load only chunk of audio in memory duringlhotse.audio.read_audio
function call.