Skip to content

Commit

Permalink
Fix .m4a support in some setups (possibly for other formats not suppo…
Browse files Browse the repository at this point in the history
…rted by libsndfile) (lhotse-speech#1427)

* LibsndfileBackend: Exclude mp4/m4a/m4b files from set of files it is applicable to

* AudioreadBackend: supports_info=True

* shar export: fix exception printing

* AudioreadBackend: black formatting
  • Loading branch information
racoiaws authored and Your Name committed Jan 7, 2025
1 parent 8ade093 commit 12ae5b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lhotse/audio/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,10 @@ def handles_special_case(self, path_or_fd: Union[Pathlike, FileObject]) -> bool:
return False

def is_applicable(self, path_or_fd: Union[Pathlike, FileObject]) -> bool:
if isinstance(path_or_fd, (Path, str)) and any(
str(path_or_fd).endswith(ext) for ext in [".mp4", ".m4a", ".m4b"]
):
return False
return True

def supports_save(self) -> bool:
Expand Down Expand Up @@ -571,6 +575,9 @@ def read_audio(
duration=duration,
)

def supports_info(self):
return True

def info(
self,
path_or_fd: Union[Pathlike, FileObject],
Expand Down
2 changes: 1 addition & 1 deletion lhotse/cut/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -3570,7 +3570,7 @@ def _export_to_shar_single(
except Exception as e:
if fault_tolerant:
logging.warning(
"Skipping: failed to load cut '{cut.id}'. Error message: {e}."
f"Skipping: failed to load cut '{cut.id}'. Error message: {e}."
)
else:
raise
Expand Down

0 comments on commit 12ae5b2

Please sign in to comment.