wav

Change the volume of a wav file in python

倖福魔咒の 提交于 2019-11-30 07:03:17
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 multiply it for a number between 0 and 1. But it doesn't work: the new sound is lower but VERY full of noise. What am I doing wrong? Here is my code: import wave, numpy, struct # Open w = wave.open("input.wav","rb") p = w.getparams() f = p[3] # number of frames s = w.readframes(f) w.close() # Edit s = numpy.fromstring(s, numpy.int16) * 5 / 10 # half

How to extract semi-precise frequencies from a WAV file using Fourier Transforms

与世无争的帅哥 提交于 2019-11-30 06:26:08
问题 Let us say that I have a WAV file. In this file, is a series of sine tones at precise 1 second intervals. I want to use the FFTW library to extract these tones in sequence. Is this particularly hard to do? How would I go about this? Also, what is the best way to write tones of this kind into a WAV file? I assume I would only need a simple audio library for the output. My language of choice is C 回答1: To get the power spectrum of a section of your file: collect N samples, where N is a power of

Processing Audio Data using Fourier Transforms in Java

白昼怎懂夜的黑 提交于 2019-11-30 02:06:19
I'm trying to process audio data. I'm working with Java. I've extracted the audio data to an array. Now I should pass N data samples to a function that calculates the Discrete Fourier Transform (or Fast Fourier Transform, which is more efficient). I've read documentation but I'm getting more and more confused. What I'm trying to calculate is the magnitude spectrum (|X(k)|). Can anyone help me? Thanks Robert Harvey Richard G. Baldwin has a number of very good articles on Fast Fourier Transform algorithms in Java on the Developer.com website. In particular, the following articles should prove to

How to write wav file with 32-bit float data?

不羁岁月 提交于 2019-11-30 00:44:43
问题 I would like to be able to write PCM wav files with 32-bit floating point samples. This seems to be a valid format since libsndfile claims to support it. However, if I specify in my header a sample size of 32-bits, any program I open it in assumes that it's 32-bit integer data. What flags, etc need to be set in the wav file header to specify floating point data? Can anyone point me to some documentation that explains how to do this? 回答1: You need to set the wFormat tag in the 'fmt' chunk to

Python - downsampling wav audio file

百般思念 提交于 2019-11-30 00:41:52
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 the entire recording. How can I just downsample the audio file to 16kHz and maintain the same length of the audio? Thank you very much in advance You can use Librosa's load() function, import librosa y, s = librosa.load('test.wav', sr=8000) # Downsample 44.1kHz to 8kHz The extra effort to install Librosa is probably worth the peace of mind. Pro-tip:

Compare voice wav in android or voice tag ( voice commands ) API

风流意气都作罢 提交于 2019-11-29 20:33:32
问题 I'm developing an app and I need some way to compare 2 voices if they' match or not, I know that Voice Recognizer is a way to do that but since (i think) it needs to translate the voice into string first, it won't be so suitable for other language apart from the lang supported by the speech recognizer....any idea? Just like old-day phone used to do, the voice tag where it just compare the voice input with the voice it recorded earlier during the setup 回答1: A relatively simple way to do this

How to combine a .mp4 video with a .wav audio with an offset in ffmpeg from command line?

泪湿孤枕 提交于 2019-11-29 18:54:21
问题 I've got a TV clip in mp4 format containing audio and video, and an WAV audio_commentary track. I've been trying to combine them in ffmpeg and then play it online with a flash player (which can only take h264 format) What's the best ffmpeg command to accomplish this? My inputs are MP4 video, WAV audio, and an offset in seconds, the time the audio commentary starts relative to the start of the mp4 video. I tried ffmpeg -i input_audio.wav -i input_vid.mp4 -vcodec copy output.mp4 and ffmpeg

Playing .wav file in java from file from computer

时光怂恿深爱的人放手 提交于 2019-11-29 18:06:45
package soundTest; import java.applet.*; import java.net.*; import javax.swing.*; import javax.sound.sampled.*; import java.io.*; import java.util.*; public class SoundTest { public static void main(String[] args) throws Exception { try { AudioClip clip1 = Applet.newAudioClip(new URL(new File("E0.wav").getAbsolutePath())); clip1.play(); } catch (MalformedURLException murle) { System.out.println(murle); } URL url = new URL( "http://www.mediafire.com/listen/tok9j9s1hnogj1y/downloads/E0.wav"); Clip clip = AudioSystem.getClip(); AudioInputStream ais = AudioSystem.getAudioInputStream(url); clip

How to stream a WAV file?

房东的猫 提交于 2019-11-29 15:19:35
I'm writing an app where I record audio and upload the audio file over the web. In order to speed up the upload I want to start uploading before I've finished recording. The file I'm creating is a WAV file. My plan was to use multiple data chunks. So instead of the normal encoding (RIFF, fmt , data) I’m using (RIFF, fmt , data, data, ..., data). The first issue is that the RIFF header wants the total length of the whole file, but that is of course not known when streaming the audio (I’m now using an arbitrary number). The other problem is that I'm not sure if it's valid since Audacity doesn't

Normalising FFT data (FFTW)

丶灬走出姿态 提交于 2019-11-29 15:00:32
问题 Using FFTW I have been computing the FFT of normalized .wav file data. I am a bit confused as to how I should normalise the FFT output, however. I have been using the method which seemed obvious to me, which is simply to divide by the highest FFT magnitude. I have seen division by 1/N and N/2 recommended, however (where I assume N = FFT size). How do these work as normalisation factors? There doesn't seem to me to be an intuitive relation between these factors and the actual data - so what am