python 3.x – Torchaudio.save() .wav file is twice bigger than the original .wav file

I’m really new to pytorch and torchaudio.
I found that the file it save is twice bigger than the original file.
But I just load a .wav file and save the audio to another .wav file immediately.
Why it get bigger?

I’ve check that the bit depth(?), sample rate are all the same.
What make the resaved file twice bigger than the original one?
Furthemore, it’s not totally twice bigger. It’s slightly smaller.
I can’t find other ppl with the same situation.
I guess the original is a compressed file? Becuase the resaved file of resave_audio maintain the same size.

Cany anyone give me a hint or keyword about what’s this situation?

import os
import torchaudio

ori_audio, ori_sr = torchaudio.load('LJ037-0171.wav')

torchaudio.save('LJ037-0171_resave.wav', ori_audio, ori_sr)

resave_audio, resave_sr = torchaudio.load('LJ037-0171_resave.wav')

print(f'Original sr: {ori_sr}, Resaved sr: {resave_sr}')
print(f'Audio tensor equal: {torch.equal(ori_audio, resave_audio)}')
print(f'datatype of ori_audio: {ori_audio[0, 1].dtype}')
print(f'datatype of ori_audio: {resave_audio[0, 1].dtype}')
print(f'Shape of ori: {ori_audio.shape}')
print(f'Shape of resave: {ori_audio.shape}')

print(f'File size of original wav: {os.path.getsize("LJ037-0171.wav")}')
print(f'File size of resaved wav: {os.path.getsize("LJ037-0171_resave.wav")}')

Output:

Original sr: 22050, Resaved sr: 22050
Audio tensor equal: True
datatype of ori_audio: torch.float32
datatype of ori_audio: torch.float32
Shape of ori: torch.Size([1, 167226])
Shape of resave: torch.Size([1, 167226])
File size of original wav: 334496
File size of resaved wav: 668962

Read more here: Source link