NVIDIA / OpenSeq2Seq

Toolkit for efficient experimentation with Speech Recognition, Text2Speech and NLP
https://nvidia.github.io/OpenSeq2Seq
Apache License 2.0
1.54k stars 369 forks source link

Sampling Rate Problem #421

Closed flassTer closed 5 years ago

flassTer commented 5 years ago

Why does the Wave2Letter+ output "killed" when I input a wav file that has a sampling frequency of 8000Hz? Even if I resample it to 16000Hz it still outputs "killed".

borisgin commented 5 years ago

Cam you attach the original .wav file, please?

flassTer commented 5 years ago

I have managed to make it use it by resampling the wav file using sox from 8KHz to 16KHz

import audioop import wave import os def resampleWav(src, dst, inrate=8000, outrate=16000, inchannels=2, outchannels=1): if not os.path.exists(src): print 'Source not found!' return False try: s_read = wave.open(src, 'r') s_write = wave.open(dst, 'w') except: print(Failed to open files!') return False n_frames = s_read.getnframes() data = s_read.readframes(n_frames)

try:
    converted = audioop.ratecv(data, 2, inchannels, inrate, outrate, None)
    if outchannels == 1:
        converted = audioop.tomono(converted[0], 2, 1, 0)
except:
    print 'Failed to downsample wav'
    return False

try:
    s_write.setparams((outchannels, 2, outrate, 0, 'NONE', 'Uncompressed'))
    s_write.writeframes(converted)
except:
    print 'Failed to write wav'
    return False

try:
    s_read.close()
    s_write.close()
except:
    print 'Failed to close wav files'
    return False

return True

resampleWav('nameofwav.wav','nameofnewwav.wav) `