The title is the question. To make this concrete, assume I have a standard 16-bit single channel wav file, with (although it doesn't matter) a 16000 Hz sampling rate.
Each sample magnitude will be a 16-bit value.
Is there a specified semantics or interpretation of these values, not relative to any physical value, but relative to the numerical systems of modern computers? I.e., are those numbers to be interpreted as 16-bit twos-complement, or scaled into single precision floats between -1 and 1, etc?
At the highest level, I recognize this is a little pointless: They're arbitrary scale.
But at a practical level, in the python world, librosa does one thing, scipy does another, and converting those different things into a spectrogram or analyzing with a vocoder can yield different results.
For skeptics, invite you to try the following:
import scipy import librosa.display np_eps = np.finfo('f').eps np_max = np.finfo('f').max x, sr = librosa.load(file, sr=16000) plt.subplot(2, 2, 1) D = librosa.amplitude_to_db(np.abs(librosa.stft(x)), ref=1.0) librosa.display.specshow(D, y_axis='linear') plt.colorbar(format='%+2.0f dB') plt.subplot(2, 2, 2) plt.plot(x) sr, y = scipy.io.wavfile.read(file) y = y.astype(float32) plt.subplot(2, 2, 3) D = librosa.amplitude_to_db(np.abs(librosa.stft(y)), ref=1.0) librosa.display.specshow(D, y_axis='linear') plt.colorbar(format='%+2.0f dB') plt.subplot(2, 2, 4) plt.plot(y)
Do not neglect the extra argument to librosa, forcing the sampling rate; in my case, the file I am using is from the Arctic corpus and is sampled at 16 KHz. Do not neglect the colorbars, which will show you the very obvious shift of 90 dB from one to the other. This should not be surprising, since 20 * log10 (32768) is approximately 90.3.
I assure you, gentle readers, this will have consequences further down the pipeline of speech vocoders, or neural networks (where normalization techniques might want you to reference to numpy epsilon to avoid negative numbers) or both.