我正在使用librosa库,我想知道librosa.load函数在读取音频(.wav)文件时返回了哪些信息。是pa中的瞬时声压,还是没有单位的声音信号的瞬时振幅?
发布于 2020-09-16 11:04:05
为了确认前面的答案,librosa.load返回一个在librosa术语表中定义为:
时间序列:典型的音频信号,以y表示,表示为浮点值的一维numpy.ndarray。yt对应于样本t处波形的振幅。
振幅通常被测量为麦克风或接收装置周围的压力变化的函数,最初接收音频。(请参阅更多这里)。
发布于 2020-05-24 13:31:03
据我所知,振幅是测量大气压力变化时的记录。根据librosa.load文档这里,该方法返回两件事:
sr:这意味着每秒记录多少个样本。- **The first axis**: represents the recorded samples of amplitudes (change of air pressure) in the audio.
- **The second axis**: represents the number of channels in the audio.以下是正式文档中的一个示例:
>>> import librosa
>>> filename = librosa.util.example_audio_file()
>>> y, sr = librosa.load(filename)
>>> sr #sample rate
22050
>>> y.shape #mono (1 channel)
(1355168,)
>> y.shape[0] / sr #duration of audio file in seconds
61.45886621315193正如我们所看到的:
22050,这意味着记录器每秒记录22050次数。y.shape = (1355168,),这意味着只有一个频道(Mono)记录了整个音频的1355168样本。total_number_of_samples除以sample_rate来计算这个音频文件的持续时间。从评论中添加
请注意,如果您将文件读取为y, sr = librosa.load(filename),librosa将默认将信号重采样为22050 Hz。如文档中所述,如果要获得本机采样率,则应将信号读取为y, sr = librosa.load(filename, sr=None)。
发布于 2020-09-02 16:43:56
要添加上述答案,还可以使用librosa函数librosa.get_duration(y,sr)获取音频文件的持续时间(以秒为单位)。或者您可以使用len(y)/sr获取音频文件的持续时间(秒)。
https://stackoverflow.com/questions/61986490
复制相似问题