wav

Playing WAV file in Chrome fails

百般思念 提交于 2021-01-28 08:47:04
问题 I'm writing web application where users can listen audio (WAV) files using soundmanager2. Application is running on Amazon micro instance, but static files are served from my university server. Everything seemed to work fine, but I encountered problem with playing audio from Chrome browser but ONLY when files are served from university server. The same file served from Amazon server works fine in all browsers. If you want to test I paste links bellow. Amazon (APACHE) - works on all browsers:

Updating/appending to a .wav file in Python

[亡魂溺海] 提交于 2021-01-28 05:23:02
问题 I have a stream of PCM audio frames coming into my Python script, and I am able to save blocks of these frames as .wav files as such: def update_wav(): filename = "test.wav" wav_file = wave.open(filename, "wb") n_frames = len(audio) wav_file.setparams((n_channels, sample_width, sample_rate, n_frames, comptype, compname)) for sample in audio: wav_file.writeframes(struct.pack('h', int(sample * 32767.0))) wav_file.close() However, I'd like this to continually update as new frames come in. Is

Why WAV format doesn't have same mimetype in different browsers?

 ̄綄美尐妖づ 提交于 2021-01-27 16:49:03
问题 File input give different Mimetype for the same file in chrome or firefox. I have a wav file that I want to upload, chrome says it is audio/wav and firefox detect audio/x-wav . I know those two mimetype are very similar ( x- stands for non-standard), but why are they handled differently in this case? Here is a fiddle to illustrate this: https://jsfiddle.net/r9ae0zfd/. And here is the WAV file I used for this example: https://freesound.org/people/zagi2/sounds/391828/. In the end the behavior

reading wav/wave file into short[] array

久未见 提交于 2021-01-24 08:15:55
问题 is there an api to read wav files into an array of short[]? i'm trying to read a wav file into short array. i couldn't find any built API for that 回答1: Bring it in via an AudioInputStream as one normally does for sound. With each buffer load you grab from the stream, iterate through it, two bytes at a time (if it is 16-bit encoding) and use your favorite algorithm to convert the two bytes to a single short int. (Depends if file is Big-Endian or Little-Endian.) Then, save the results by

Convert byte array to wav file

青春壹個敷衍的年華 提交于 2021-01-20 16:37:07
问题 I'm trying to play a wav sound that stored in byte array called bytes. I know that I should convert the byte array to wav file and save it in my local drive then called the saved file but I was not able to convert the byte array to wav file. please help me to give sample code to convert byte arrary of wav sound to wav file. here is my code: protected void Button1_Click(object sender, EventArgs e) { byte[] bytes = GetbyteArray(); //missing code to convert the byte array to wav file ...........

Convert byte array to wav file

£可爱£侵袭症+ 提交于 2021-01-20 16:37:01
问题 I'm trying to play a wav sound that stored in byte array called bytes. I know that I should convert the byte array to wav file and save it in my local drive then called the saved file but I was not able to convert the byte array to wav file. please help me to give sample code to convert byte arrary of wav sound to wav file. here is my code: protected void Button1_Click(object sender, EventArgs e) { byte[] bytes = GetbyteArray(); //missing code to convert the byte array to wav file ...........

Converting 16BitPCM to .wav, after switching endianness, the .wav file plays backwards

心已入冬 提交于 2021-01-07 01:36:33
问题 I am trying to build an Android app that records PCM audio and exports it as a wav file. It worked fine for 8BitPCM, but when I switched to 16BitPCM I got white noise. I finally figured out it was the endianness of the byte array, but now, after converting from Little Endian to Big Endian, I get my audio crystal clear, but reversed! Here is how I call the method: byte[] inputByteArray = convertLittleEndianToBig(readToByte(input)); and then that byte[] is appended to my .wav header here:

Converting 16BitPCM to .wav, after switching endianness, the .wav file plays backwards

北慕城南 提交于 2021-01-07 01:36:32
问题 I am trying to build an Android app that records PCM audio and exports it as a wav file. It worked fine for 8BitPCM, but when I switched to 16BitPCM I got white noise. I finally figured out it was the endianness of the byte array, but now, after converting from Little Endian to Big Endian, I get my audio crystal clear, but reversed! Here is how I call the method: byte[] inputByteArray = convertLittleEndianToBig(readToByte(input)); and then that byte[] is appended to my .wav header here:

How can i pad wav file to specific length?

蓝咒 提交于 2021-01-05 10:33:06
问题 I am using wave files for making deep learning model they are in different length , so i want to pad all of them to 16 sec length using python 回答1: Using pydub: from pydub import AudioSegment pad_ms = 1000 # milliseconds of silence needed silence = AudioSegment.silent(duration=pad_ms) audio = AudioSegment.from_wav('you-wav-file.wav') padded = audio + silence # Adding silence after the audio padded.export('padded-file.wav', format='wav') AudioSegment objects are immutable 回答2: If I understood

Create a wav file from blob audio django

寵の児 提交于 2020-12-27 06:54:19
问题 On the client side, I am sending a blob audio (wav) file. On the server side, I am trying to convert the blob file to an audio wav file. I did the following: blob = request.FILES['file'] name = "TEST.wav" audio = wave.open(name, 'wb') audio.setnchannels(1) audio.writeframes(blob.read()) I thought that converting the blob would be similar to converting a blob image to a jpeg file, but was very incorrect in that assumption. That didn't work; I get an error - "Error: sample width not specified."