在计算机中显示为.wav文件时,音频文件无法读取为PCM WAV

时间:2019-12-19 00:49:06

标签: python audio speech-recognition wav speech

我正在尝试使用以下代码从语音生成文本:

def genText(path, dataholder = {}):

    for filename in os.listdir(path):
        if filename != '.DS_Store':
            print filename
            eg = sr.AudioFile(path + "/" + filename)
            # print eg
            with eg as source:
                audio = r.record(source)
                try:    
                    print r.recognize_google(audio)
            #s_audio.append(r.recognize_google(audio))
                    dataholder[filename] = r.recognize_google(audio)
                except sr.UnknownValueError:
                    pass

    return dataholder

s9_corpus = genText(path9) # path to my audio files' directory

但是会出现以下错误(它适用于其他几个音频文件的目录,但不适用于s9目录):

Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in another format

但是,当我在Mac计算机上打开这些音频时,这些音频将显示为.wav。例如,查看所附图片enter image description here

将不胜感激。

0 个答案:

没有答案