Skip to content

Instantly share code, notes, and snippets.

@zjn0505
Created August 28, 2019 08:31
Show Gist options
  • Select an option

  • Save zjn0505/97b0cd9cc0564435b15c0b7ff3bd1aee to your computer and use it in GitHub Desktop.

Select an option

Save zjn0505/97b0cd9cc0564435b15c0b7ff3bd1aee to your computer and use it in GitHub Desktop.
Convert PCM to WAV.
import sys
import wave
for arg in sys.argv[1:]:
with open(arg, 'rb') as pcmfile:
pcmdata = pcmfile.read()
wavfile = wave.open(arg+'.wav', 'wb')
# nchannels, sampwidth, framerate, nframes, comptype, compname
wavfile.setparams((1, 2, 16000, 0, 'NONE', 'NONE'))
wavfile.writeframes(pcmdata)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment