Read .sph files in Python
Question: I am working on a project where I need to extract the Mel-Cepstral Frequency
Coefficients (MFCC) from audio signals. The first step for this process is to
read the audio file into python.

The audio files I have are stored in a .sph format. I am unable to find a
method to read these files directly into python. I would like to have the
sampling rate, and a numpy array with the data, similar to how wav read works.

Since the audio files I will be dealing with are large in size, I would prefer
not to convert to .wav format for reading. Could you please suggest a possible
method to do so?


Answer: I was against converting to a .wav file as I assumed it would take a lot of
time. That is not the case. So, converting using SoX suited my needs.

The following script when run in a windows folder converts all the files in
that folder to a .wav file.

    
    
    cd %~dp0
    for %%a in (*.sph) do sox "%%~a" "%%~na.wav"
    pause
    

After this, the following command can be used to read the file.

    
    
    import scipy.io.wavfile as wav
    (rate,sig) = wav.read("file.wav")
    

PS: I have posted the answer as opposed to deleting my question, as I found
very little help online regarding .sph files.

