def read_wav(wavfile):
'''
read a wav file formatted by kaldi
Args:
wavfile: a pair containing eiher the filaname or the command to read the
wavfile and a boolean that determines if its a name or a command
'''
if wavfile[1]:
#read the audio file and temporarily copy it to tmp (and duplicate, I
#don't know how to avoid this)
os.system(wavfile[0] + ' tee tmp.wav > duplicate.wav')
#read the created wav file
(rate, utterance) = wav.read('tmp.wav')
#delete the create file
os.remove('tmp.wav')
os.remove('duplicate.wav')
else:
(rate, utterance) = wav.read(wavfile[0])
return rate, utterance
评论列表
文章目录