How to create a numpy array from a pydub AudioSegment?

后端 未结 2 1558
甜味超标
甜味超标 2021-02-18 16:51

I\'m aware of the following question: How to create a pydub AudioSegment using an numpy array?

My question is the right opposite. If I have a pydub AudioSegment how can

2条回答
  •  面向向阳花
    2021-02-18 17:28

    You can get an array.array from an AudioSegment then convert it to a numpy.ndarray:

    from pydub import AudioSegment
    import numpy as np
    song = AudioSegment.from_mp3('song.mp3')
    samples = song.get_array_of_samples()
    samples = np.array(samples)
    

提交回复
热议问题