title: Audio data string format to numpy array
body: <p>I am trying to convert audio sample rate (from 44100 to 22050) of a numpy.array with 88200 samples in which I have already done some process (such as add silence and convert to mono). I tried to convert this array with <code>audioop.ratecv</code> and it work, but it return a str instead of a numpy array and when I wrote those data with <code>scipy.io.wavfile.write</code> the result was half of the data are lost and the audio speed is twice as fast (instead of slower, at least that would make kinda sense). 
  <code>audio.ratecv</code> works fine with str arrays such as <code>wave.open</code> returns, but I don't know how to process those, so I tried to convert from str to numpy with <code>numpy.array2string(data)</code> to pass this on ratecv and get correct results, and then convert again to numpy with <code>numpy.fromstring(data, dtype)</code> and now len of data is 8 samples. I think this is due to complication of formats, but I don't know how can I control it. I also haven't figure out what kind of format str does <code>wave.open</code> returns so I can force format on this one.</p>
  
  <p>Here is this part of my code</p>
  
  <pre><code>def conv_sr(data, srold, fixSR, dType, chan = 1): 
      state = None
      width = 2 # numpy.int16
      print "data shape", data.shape, type(data[0]) # returns shape 88200, type int16
      fragments = numpy.array2string(data)
      print "new fragments len", len(fragments), "type", type(fragments) # return len 30 type str
      fragments_new, state = audioop.ratecv(fragments, width, chan, srold, fixSR, state)
      print "fragments", len(fragments_new), type(fragments_new[0]) # returns 16, type str
      data_to_return = numpy.fromstring(fragments_new, dtype=dType)
      return data_to_return
  </code></pre>
  
  <p>and I call it like this</p>
  
  <pre><code>data1 = numpy.array(data1, dtype=dType)
  data_to_copy = numpy.append(data1, data2)
  data_to_copy = _to_copy.sum(axis = 1) / chan
  data_to_copy = data_to_copy.flatten() # because its mono
  
  data_to_copy = conv_sr(data_to_copy, sr, fixSR, dType) #sr = 44100, fixSR = 22050
  
  scipy.io.wavfile.write(filename, fixSR, data_to_copy)
  </code></pre>