美文网首页
python 声音处理 AudioSegment.from_fi

python 声音处理 AudioSegment.from_fi

作者: a十二_4765 | 来源:发表于2019-01-21 22:09 被阅读88次

    经历好几个小时的折腾

    from pydub.audio_segmentimport AudioSegment

    from scipy.ioimport wavfile

    from python_speech_features.baseimport mfcc

    import pandas

    import  sys

    song = AudioSegment.from_file('D:/demo/xihuani.MP3',format='MP3')

    print(song)

    错误

    Traceback (most recent call last):

      File "D:/demo/classs_demo.py", line 7, in <module>

        song = AudioSegment.from_file('D:/demo/xihuani.MP3',format='MP3')

      File "C:\Users\dell\AppData\Local\Programs\Python\Python35\lib\site-packages\pydub\audio_segment.py", line 665, in from_file

        info = mediainfo_json(orig_file)

      File "C:\Users\dell\AppData\Local\Programs\Python\Python35\lib\site-packages\pydub\utils.py", line 263, in mediainfo_json

        res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)

      File "C:\Users\dell\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 947, in __init__

        restore_signals, start_new_session)

      File "C:\Users\dell\AppData\Local\Programs\Python\Python35\lib\subprocess.py", line 1224, in _execute_child

        startupinfo)

    FileNotFoundError: [WinError 2] 系统找不到指定的文件。

    Process finished with exit code 1

    上面的错误是少安装了 ffmpeg 但是你用pip install ffmpeg 安装后还是一样的错误

    然后呢 你需要自己去官网下载 。exe的然后再去代码调用ffmpeg

    最后

    from pydub.audio_segmentimport AudioSegment

    from scipy.ioimport wavfile

    from python_speech_features.baseimport mfcc

    import pandas

    import  sys

    AudioSegment.converter ='D:\\ffmpeg\\bin\\ffmpeg.exe'

    song = AudioSegment.from_file('D:/demo/xihuani.MP3',format='MP3')

    print(song)

    相关文章

      网友评论

          本文标题:python 声音处理 AudioSegment.from_fi

          本文链接:https://www.haomeiwen.com/subject/brahjqtx.html