Created
February 1, 2018 22:00
-
-
Save MilesDowe/0a430956d9ea57257ade160a1acbff3b to your computer and use it in GitHub Desktop.
One way to slice a wav file in memory and supply to scipy wavreader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pydub import AudioSegment | |
from io import BytesIO | |
from scipy.io import wavfile | |
# get file | |
audio_file = AudioSegment.from_wav("some.wav") | |
# create output, supply to AudioSegment | |
audio_sample = BytesIO() | |
audio_file[2000:5000].export(audio_sample, format='wav') | |
# read into scipy.wavreader | |
audio_info = wavfile.read(BytesIO(audio_sample.getvalue())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment