[ot][spam][crazy] Quickly autotranscribing xkcd 4/1 correctly
Undiscussed Horrific Abuse, One Victim of Many
gmkarl at gmail.com
Sat Apr 2 02:40:37 PDT 2022
Unlike soundfile, librosa.read already does resampling:
Help on function load in module librosa.core.audio:
load(path, *, sr=22050, mono=True, offset=0.0, duration=None,
dtype=<class 'numpy.float32'>, res_type='kaiser_best')
Load an audio file as a floating point time series.
Audio will be automatically resampled to the given rate
(default ``sr=22050``).
To preserve the native sampling rate of the file, use ``sr=None``.
Parameters
----------
path : string, int, pathlib.Path, soundfile.SoundFile or file-like object
path to the input file.
Any codec supported by `soundfile` or `audioread` will work.
Any string file paths, or any object implementing Python's
file interface (e.g. `pathlib.Path`) are supported as `path`.
If the codec is supported by `soundfile`, then `path` can also be
an open file descriptor (int) or an existing
`soundfile.SoundFile` object.
On the contrary, if the codec is not supported by `soundfile`
(for example, MP3), then `path` must be a file path (string or
`pathlib.Path`).
sr : number > 0 [scalar]
target sampling rate
'None' uses the native sampling rate
mono : bool
convert signal to mono
offset : float
start reading after this time (in seconds)
duration : float
only load up to this much audio (in seconds)
dtype : numeric type
data type of ``y``
res_type : str
resample type (see note)
.. note::
By default, this uses `resampy`'s high-quality mode ('kaiser_best').
For alternative resampling modes, see `resample`
.. note::
`audioread` may truncate the precision of the audio data to 16 bits.
See :ref:`ioformats` for alternate loading methods.
Returns
-------
y : np.ndarray [shape=(n,) or (..., n)]
audio time series. Multi-channel is supported.
sr : number > 0 [scalar]
sampling rate of ``y``
Examples
--------
>>> # Load an ogg vorbis file
>>> filename = librosa.ex('trumpet')
>>> y, sr = librosa.load(filename)
>>> y
array([-1.407e-03, -4.461e-04, ..., -3.042e-05, 1.277e-05],
dtype=float32)
>>> sr
22050
More information about the cypherpunks
mailing list