添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
重感情的西装  ·  The GDB Python API | ...·  4 天前    · 
帅呆的匕首  ·  小米投影仪维修点 ...·  1 月前    · 
精明的书包  ·  GitHub ...·  2 月前    · 
沉稳的筷子  ·  产业研究_大众网·  3 月前    · 
librosa. load ( path , sr=22050 , mono=True , offset=0.0 , duration=None , dtype=<class 'numpy.float32'> , res_type='kaiser_best' ) [source]

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 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).

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)

By default, this uses resampy ’s high-quality mode (‘kaiser_best’).

For alternative resampling modes, see resample

audioread may truncate the precision of the audio data to 16 bits.

See Advanced I/O Use Cases for alternate loading methods.

>>> # Load an ogg vorbis file
>>> filename = librosa.ex('trumpet')
>>> y, sr = librosa.load(filename)
array([-1.407e-03, -4.461e-04, ..., -3.042e-05,  1.277e-05],
      dtype=float32)
22050
>>> # Load a file and resample to 11 KHz
>>> filename = librosa.ex('trumpet')
>>> y, sr = librosa.load(filename, sr=11025)
array([-8.746e-04, -3.363e-04, ..., -1.301e-05,  0.000e+00],
      dtype=float32)
11025
>>> # Load 5 seconds of a file, starting 15 seconds in
>>> filename = librosa.ex('brahms')
>>> y, sr = librosa.load(filename, offset=15.0, duration=5.0)
array([0.146, 0.144, ..., 0.128, 0.015], dtype=float32)
22050