I am using an audio interface which records audio only with 24-bits per sample. Later, I want to change that to 16-bits per sample.
Which lib
or method
can use for this operation? I want to do this in python-3.x
.
If you must use Python, you could use PySoundFile. Here's a little code snippet:
import soundfile
data, samplerate = soundfile.read('old.wav')
soundfile.write('new.wav', data, samplerate, subtype='PCM_16')
You should also use soundfile.available_subtypes to see which subtypes you can convert a file to. Here's its sample usage:
>>> import soundfile as sf
>>> sf.available_subtypes('FLAC')
{'PCM_24': 'Signed 24 bit PCM',
'PCM_16': 'Signed 16 bit PCM',
'PCM_S8': 'Signed 8 bit PCM'}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.