Questions tagged [wave]

This tag is for questions about the Python module wave - for working with the .wav sound format. FOR GENERAL WAV QUESTIONS, not related to Python, please use the [wav] tag.

The wave module provides a convenient interface to the WAV sound format. It does not support compression/decompression, but it does support mono/stereo.

It's recommended to use this tag in connection with , due to the colloquial meaning of wave (ex. in math or physics)

498 questions
121
votes
14 answers

Reading *.wav files in Python

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…
Roman
  • 124,451
  • 167
  • 349
  • 456
42
votes
3 answers

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

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 …
jdsto
  • 455
  • 1
  • 4
  • 11
36
votes
4 answers

How to create a numpy array from a pydub AudioSegment?

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 and so on. It…
J_Zar
  • 2,034
  • 2
  • 21
  • 34
31
votes
8 answers

Downsampling wav audio file

I have to downsample a wav file from 44100Hz to 16000Hz without using any external Python libraries, so preferably wave and/or audioop. I tried just changing the wav files framerate to 16000 by using setframerate function but that just slows down…
d3cr1pt0r
  • 481
  • 1
  • 5
  • 9
30
votes
2 answers

ffmpeg to convert from flac to wav

I need to convert a flac file to a wav file without changing sample rate and bit depth. As far as I know changing these properties may distort the audio, so how do i specify them not to be changed? Also, is there any way to prevent metadata to be…
user3580089
  • 379
  • 1
  • 3
  • 7
26
votes
3 answers

Generating waveform from any music file ios

I'm looking for how to draw the sound waves according to music. I want waves like this image here is some discussion about displaying Waves from music WaveForm on IOS rendering a waveform on an iphone audio waveform visualisation with…
Vishal Khatri
  • 954
  • 2
  • 12
  • 32
26
votes
3 answers

Pass Blob through ajax to generate a file

I'm trying to capture audiorecorder (https://github.com/cwilso/AudioRecorder) and send the blob through Ajax a php file, which will receive the blob content and create the file(the wave file in this case). Ajax…
João Correia
  • 275
  • 1
  • 3
  • 7
21
votes
1 answer

Error on say when output format is wave

I am trying to create wave files using mac's say command, however, I get the following error: $ say "hello" -o hi.wav Opening output file failed: fmt? although, $ say --file-format=? WAVE WAVE (.wav) [lpcm,ulaw,alaw] Is there some way I can get…
simbara
  • 213
  • 2
  • 4
18
votes
3 answers

How to write stereo wav files in Python?

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…
Jonathan Livni
  • 101,334
  • 104
  • 266
  • 359
18
votes
3 answers

Convert OutputStream to ByteArrayOutputStream

I am trying to convert an OutputStream to a ByteArrayOutput Stream. I was unable to find any clear simple answers on how to do this. This question was asked in the title of the question on StackOverflow, but the body of the question aske how to…
Bill Smith
  • 187
  • 1
  • 1
  • 8
17
votes
5 answers

Change the volume of a wav file in python

I have a 2 seconds 16bit single channel 8khz wav file and I need to change its volume. It should be quite straightforward, because changing the volume is the same as changing the amplitude of the signal, and I just need to attenuate it, that is to…
The Dare Guy
  • 487
  • 1
  • 3
  • 12
15
votes
7 answers

Sine Wave Sound Generator in Java

What's the simplest way to generate a sine wave sound at any frequency in Java? A sample size more than 2 bytes would help, but it doesn't really matter.
milo
  • 555
  • 2
  • 7
  • 13
14
votes
4 answers

What is returned by wave.readframes?

I assign a value to a variable x in the following way: import wave w = wave.open('/usr/share/sounds/ekiga/voicemail.wav', 'r') x = w.readframes(1) When I type x I get: '\x1e\x00' So x got a value. But what is that? Is it hexadecimal? type(x) and…
Roman
  • 124,451
  • 167
  • 349
  • 456
13
votes
6 answers

reading a WAV file from TIMIT database in python

I'm trying to read a wav file from the TIMIT database in python but I get an error: When I'm using wave: wave.Error: file does not start with RIFF id When I'm using scipy: ValueError: File format b'NIST'... not understood. and when I'm using…
Cranjis
  • 1,590
  • 8
  • 31
  • 64
12
votes
2 answers

AVAudioRecorder doesn't write out proper WAV File Header

I'm working on a project on the iPhone where I'm recording audio from the device mic using AVAudioRecorder, and then will be manipulating the recording. To ensure that I'm reading in the samples from the file correctly, I'm using python's wave…
ch3rryc0ke
  • 2,793
  • 1
  • 22
  • 28
1
2 3
33 34