0

我有一个原始文件0.flac,我只是用它打开librosa然后另存SoundFile1.flac

import soundfile as sf
import librosa

in_path = "0.flac"
out_path = "1.flac"

sampling_rate = 16000

wav, source_sampling_rate = librosa.load(in_path, sr=None)
assert(source_sampling_rate == sampling_rate)

# 16bit -> PCM_16
sf.write(out_path, wav, sampling_rate, format='flac', subtype='PCM_16')

但是文件大小和文件本身似乎已更改:

User@User-MacBook-Pro:~/check_librosa$ metaflac --list 0.flac 
METADATA block #0
  type: 0 (STREAMINFO)
  is last: false
  length: 34
  minimum blocksize: 4096 samples
  maximum blocksize: 4096 samples
  minimum framesize: 107 bytes
  maximum framesize: 5961 bytes
  sample_rate: 16000 Hz
  channels: 1
  bits-per-sample: 16
  total samples: 225360
  MD5 signature: 41222a894966327db4f89afa74e5e1a1
METADATA block #1
  type: 3 (SEEKTABLE)
  is last: false
  length: 36
  seek points: 2
    point 0: sample_number=0, stream_offset=0, frame_samples=4096
    point 1: sample_number=159744, stream_offset=170830, frame_samples=4096
METADATA block #2
  type: 4 (VORBIS_COMMENT)
  is last: false
  length: 40
  vendor string: reference libFLAC 1.2.1 20070917
  comments: 0
METADATA block #3
  type: 1 (PADDING)
  is last: true
  length: 8192

User@User-MacBook-Pro:~/check_librosa$ metaflac --list 1.flac 
METADATA block #0
  type: 0 (STREAMINFO)
  is last: false
  length: 34
  minimum blocksize: 4096 samples
  maximum blocksize: 4096 samples
  minimum framesize: 107 bytes
  maximum framesize: 6040 bytes
  sample_rate: 16000 Hz
  channels: 1
  bits-per-sample: 16
  total samples: 225360
  MD5 signature: 41222a894966327db4f89afa74e5e1a1
METADATA block #1
  type: 4 (VORBIS_COMMENT)
  is last: true
  length: 40
  vendor string: reference libFLAC 1.3.3 20190804
  comments: 0

元数据块较少,最大帧大小不同。这可能是什么原因?通过 librosa 加载文件是否有损?

4

0 回答 0