Fix Unknow encoder pcm_s4le issue and covert wav format

When cutting wav file into small piece using the following code.

from pydub import AudioSegment  
newAudio = AudioSegment.from_wav("./content/REC0001.WAV")  
newAudio = newAudio[t1:t2]  
newAudio.export('newSong.wav', format="wav") #Exports to a wav file in the current path.  

I got an error saying Unknown encoder 'pcm_s4le'

import soundfile as sf  
f = sf.SoundFile('./content/REC0001.WAV')  
f.format, f.subtype, f.endian  
# output: ('WAV', 'IMA_ADPCM', 'FILE')  

So I save it in PCM_16 format

sig, samplerate = sf.read('./content/REC0001.WAV')  
sf.write('./content/processed_rec001.wav', sig, samplerate)  

Back to top

Copyright © 2019 - 2024 Johnny Li. All contents licensed under CC BY-NC-SA 4.0 本站所有内容基于 CC BY-NC-SA 4.0 协议发布,转载需要署名.
Please read the LICENSE file for specific language governing permissions and limitations under the License.

Page last modified: Apr 16 2024 at 09:36 PM.

Edit this page on GitHub