Skip to content
Closed
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python

# Distribution / packaging
dist/
build/
*.egg-info/

# Testing
.pytest_cache/
.coverage
htmlcov/

# IDEs
.vscode/
.idea/
*.swp
*.swo
*~
6 changes: 5 additions & 1 deletion wsds/ws_audio.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from __future__ import annotations

import io
import logging
import typing
from dataclasses import dataclass

import pyarrow as pa

logger = logging.getLogger(__name__)


def to_filelike(src: typing.Any) -> typing.BinaryIO:
"""Coerces files, byte-strings and PyArrow binary buffers into file-like objects."""
Expand Down Expand Up @@ -127,7 +130,8 @@ def get_reader(self, sample_rate=None):
if self.reader is None or sample_rate_switch:
try:
from torchcodec.decoders import AudioDecoder
except Exception:
except (ImportError, OSError, RuntimeError) as e:
logger.warning("Failed to import torchcodec AudioDecoder, falling back to torchaudio: %s", e)
AudioDecoder = CompatAudioDecoder

reader = AudioDecoder(to_filelike(self.src), sample_rate=sample_rate)
Expand Down