converter wave 24 bit to 16 bit
<p>i wish to convert some wavs that are 
48kHz 24 bit file.wav   to 48kHz  16 bit  file-2.wav</p>

<pre><code>import wave 
origAudio = wave.open("Sample_5073.wav","r")
frameRate = origAudio.getframerate()
nChannels = origAudio.getnchannels()
sampWidth = origAudio.getsampwidth()
nbframe=origAudio.getnframes()
da = np.fromstring(origAudio.readframes(48000), dtype=np.int16)
left, right = da[0::2], da[1::2]
</code></pre>

<p>Thanks  </p>

<p>If converting files from 24 to 16 bit is the only thing you want to do, you could use <a href="http://sox.sourceforge.net/" rel="nofollow">SoX</a>, it doesn't get much easier than that:</p>

<pre><code>sox file.wav -b 16 file-2.wav
</code></pre>

<p>SoX can also do many more things, just have a look at its <a href="http://sox.sourceforge.net/sox.html" rel="nofollow">man page</a>.</p>

<p>If you want to use Python, I recommend the <a href="http://pysoundfile.readthedocs.io/" rel="nofollow">soundfile</a> module:</p>

<pre><code>import soundfile as sf

data, samplerate = sf.read('file.wav')
sf.write('file-2.wav', data, samplerate, subtype='PCM_16')
</code></pre>

<p>Specifying <code>subtype='PCM_16'</code> isn't even strictly necessary, since it's the default anyway.</p>

<p>If you really want to do it with the built-in <code>áºave</code> module, have a look at my <a href="http://nbviewer.jupyter.org/github/mgeier/python-audio/blob/master/audio-files/audio-files-with-wave.ipynb" rel="nofollow">tutorial about the <code>wave</code> module</a>.</p>

python signals wave pyaudio