title: Convert wav file to 16 bit raw signed raw and little endian form without using sox
body: <p>I am trying to convert mono channeled wav file to 16 bit raw file, more specifically the SOX command that is given below:</p>
  
  <pre><code>sox_cmd = 'sox {} --type raw --bits 16 --channels 1 --rate {} --encoding signed-integer --endian little --compression 0.0 --no-dither - '.format(quote(audio_path), desired_sample_rate)
  </code></pre>
  
  <p>I cannot use this in Windows because it requires installation of sox by altering path variables and all which cannot be done in an installation package. So, I want python code that can do the same task and can return a numpy array of raw data.</p>
  
  <p>Currently, I am doing it like this:</p>
  
  <pre><code>import sounddevice as sd
  from scipy.io.wavfile import write
  
  fs = 44100  # Sample rate
  seconds = 3  # Duration of recording
  
  myrecording = sd.rec(int(seconds * fs), samplerate=fs, channels=1)   #record as mono channeled
  sd.wait()  # Wait until recording is finished
  write('output.wav', fs, myrecording)  # Save as WAV file 
  
  from scipy.io.wavfile import read
  import numpy as np
  
  from pydub import AudioSegment
  from pydub.utils import make_chunks
  
  myaudio = AudioSegment.from_file("output.wav" , "wav") 
  chunk_length_ms = 1000 # pydub calculates in millisec
  chunks = make_chunks(myaudio, chunk_length_ms) #Make chunks of one sec
  
  #Convert chunks to raw audio data which you can then feed to HTTP stream
  for i, chunk in enumerate(chunks):
  
      raw_audio_data = chunk.raw_data
  raw_audio_data=np.array(raw_audio_data)
  raw_audio_data.shape   # prints "()"
  </code></pre>
  
  <p>Any help on this will be highly appreciated. Thanks!</p>