Skip to content

Commit

Permalink
[IMPROVEMENT] Remove 48k default expected rate for audio files (#365)
Browse files Browse the repository at this point in the history
Remove 48k default expected rate for audio files
  • Loading branch information
sdatkinson authored Jan 14, 2024
1 parent bdeed78 commit ce232d3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions nam/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,24 @@ def shape_actual(self):

def wav_to_np(
filename: Union[str, Path],
rate: Optional[int] = _DEFAULT_RATE,
rate: Optional[int] = None,
require_match: Optional[Union[str, Path]] = None,
required_shape: Optional[Tuple[int]] = None,
required_shape: Optional[Tuple[int, ...]] = None,
required_wavinfo: Optional[WavInfo] = None,
preroll: Optional[int] = None,
info: bool = False,
) -> Union[np.ndarray, Tuple[np.ndarray, WavInfo]]:
"""
:param filename: Where to load from
:param rate: Expected sample rate. `None` allows for anything.
:param require_match: If not `None`, assert that the data you get matches the shape
and other characteristics of another audio file at the provided location
:param required_shape: If not `None`, assert that the audio loaded is of shape
`(num_samples, num_channels)`.
:param required_wavinfo: If not `None`, assert that the WAV info of the laoded audio
matches that provided.
:param preroll: Drop this many samples off the front
:param info: If `True`, also return the WAV info of this file.
"""
x_wav = wavio.read(str(filename))
assert x_wav.data.shape[1] == _REQUIRED_CHANNELS, "Mono"
Expand Down

0 comments on commit ce232d3

Please sign in to comment.