【PYTHON】soundfile.read / torchaudio.load / librosa.load

本文介绍了三种Python音频读取方法:soundfile.read、torchaudio.load和librosa.load,分别解析它们的参数、返回类型和特点。soundfile.read是最简单的,Torchaudio.load返回Tensor,Librosa.load允许设置声道和采样率。对比了三者的输出差异。
摘要由CSDN通过智能技术生成

目录

Soundfile.read

Torchaudio.load

Librosa.load


在读取音频时有几种方法,而每一种所读出来的格式都不一样

Soundfile.read

最简单输入参数也最少的方式

import soundfile as sf

file = './my_audio/cat.wav'
y, sr = sf.read(file)
print('If use soundfile, shape of y = ',y.shape)

# 输出:
If use soundfile.read, shape of y =  (187662, 2)

Torchaudio.load

读取完音频则为Tensor的型态

filepath (str):音频路径。

frame_offset (int)(默认是0):在此之后开始读取,以帧为单位。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值