How to Load WAVE Files in Python as Float Type

Asked 2 years ago, Updated 2 years ago, 21 views


in python I'd like to convert the wave file to float type and calculate it.
Is there any good way?
Could you teach me?

python

2022-09-30 19:26

1 Answers

We have created an example of loading each WAVE file one frame at a time and returning it as a list of Floats.

import wave
import structure
from print import print

PATH="/path/to/some/audio.wav"


defmain():
    with wave.open (PATH) as f:
        length = f.getnframes()
        flows = [struct.unpack('f', f.readframes(1))) for_inrange(length)]
    print(floats)
    return flows


if__name__=="__main__":
    main()

7.1.structure—Interpreting byte columns as packed binary data—Python 3.6.5 document
22.4.wave—Reading and Writing WAV Files—Python 3.6.5 Documentation


2022-09-30 19:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.