0

I have to upsample 8khz telephony audio to 16khz. Until now I'm using this code/very simple transformation :

from scipy import signal

input_rate = 8000
wished_rate = 16000

audio_array = np.fromstring(string=string_of_bytes, dtype=np.int16)
resample_size = int(len(audio_array) / input_rate * wished_rate )
resample = signal.resample(audio_array, resample_size) 

I'm getting 16000hz audio but in very low quality. Does anybody know which library or methods could handle this upsampling better?

2e0byo
  • 5,305
  • 1
  • 6
  • 26
busy
  • 23
  • 3
  • 1
    why do you want to upsample? 8khz audio is going to pretty rubbish whatever you do to it; interpolation will only get you so far. You can try increasingly magic tricks to re-invent the missing data, but at the end of the day if it wasn't sampled you're making it up – 2e0byo Nov 08 '21 at 15:57
  • I have to upsample data for speech recognition model that is trained on 16khz, so it does not work with 8khz data – busy Nov 08 '21 at 17:49
  • What's `signal` here? But you basically have three options: no interpolation, functional interpolation (i.e. some function of the data), or some 'magic' (e.g. NN) interpolation to replace the missing data. Functional interpolation should give you pretty much the quality you already have at 8khz. is your upsampled audio *worse* than the 8khz? (and how are you measuring that?) – 2e0byo Nov 08 '21 at 17:58
  • for reference, [here](https://github.com/jhetherly/EnglishSpeechUpsampler) is some magic NN upsampling code, whereas [here](https://dsp.stackexchange.com/questions/58032/multi-channel-audio-upsampling-interpolation) is a discussion of upsampling audio without NN. – 2e0byo Nov 08 '21 at 18:01
  • @2e0byo signal is from scipy: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.resample.html , in my case I have to conduct the upsampling during the audio stream so it must be applicable to a string of bytes or an array and not a wav file (librosa or sox works on wav files) – busy Nov 09 '21 at 16:18

0 Answers0