wave

How to ignore corrupted files?

How to ignore corrupted files? Question: How to loop through a directory in Python and open wave files that are good whilst ignoring bad (corrupted) ones? I want to open various wave files from a directory. However, some of these files may be corrupted, some may not be to specification. In particular there will be …

Total answers: 2

Determining Bit-Depth of a wav file

Determining Bit-Depth of a wav file Question: I am looking for a fast, preferably standard library mechanism to determine the bit-depth of wav file e.g. ’16-bit’ or ’24-bit’. I am using a subprocess call to Sox to get a plethora of audio metadata but a subprocess call is very slow and the only information I …

Total answers: 3

How to create a numpy array from a pydub AudioSegment?

How to create a numpy array from a pydub AudioSegment? Question: 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 I convert it to a numpy array? I would like to use scipy filters …

Total answers: 4

How to split a .wav file into multiple .wav files?

How to split a .wav file into multiple .wav files? Question: I have a .wav file several minutes long that I would like to split into different 10 second .wav files. This is my python code so far: import wave import math def main(filename, time): read = wave.open(filename, ‘r’) #get sample rate frameRate = read.getframerate() …

Total answers: 3

How to write stereo wav files in Python?

How to write stereo wav files in Python? Question: The following code writes a simple sine at frequency 400Hz to a mono WAV file. How should this code be changed in order to produce a stereo WAV file. The second channel should be in a different frequency. import math import wave import struct freq = …

Total answers: 3

Reading *.wav files in Python

Reading *.wav files in Python Question: I need to analyze sound written in a .wav file. For that I need to transform this file into set of numbers (arrays, for example). I think I need to use the wave package. However, I do not know how exactly it works. For example I did the following: …

Total answers: 13