pcm

Faster way to convert from 24 bit wav pcm format to float?

情到浓时终转凉″ 提交于 2019-12-02 05:39:32
问题 I need to read data in from a wav file in 24 bit pcm format, and convert to float. I'm using Python 2.7.2. The wave package reads the data in as a string, so what I've tried is: import wave import numpy as np import array import struct f = wave.open('filename.wav') # read in entire wav file wdata = f.readframes(nFrames) f.close() # unpack into signed integers and convert to float data = array.array('f') for i in range(0,nFrames*3,3): data.append(float(struct.unpack('<i', '\x00'+ wdata[i:i+3])

Decode G711(PCM u-law)

匆匆过客 提交于 2019-12-02 03:57:34
问题 Please bear with me as my understanding of audio codec is limited. I have this audio source from a IPCAM (through a htto//... CGI interface). I am trying to write several client programs to play this audio source on Windows, MAC, as well as Android phone. The audio is encoded in G711 (PCM ulaw). Do I need to decode the PCM audio data to a raw audio data before I could pass it to the audio engine to play? If so, is there some sample code on how to decode it? I am confused as somehow I believe

C\\C++ open source Mp3 to PCM convertor [closed]

爱⌒轻易说出口 提交于 2019-12-02 03:47:49
C\C++ open source Mp3 to PCM convertor? What do I need Open Source Libs/wrappers for encoding/decoding. Tutorials and blog articles on How to do it, about etc. I've used this successfully in projects: http://www.mpg123.de/ EDIT: I can't speak for this one http://www.underbit.com/products/mad/ but it's supposed to be very good... if you can deal with the GPL. As Jeffrey mentioned, LAME can do that, but it's not true that you have to run it as an executable, you can build it as a library. You can even use it in commercial software as long as you dynamically link it. http://lame.sourceforge.net

Decode G711(PCM u-law)

帅比萌擦擦* 提交于 2019-12-02 02:54:17
Please bear with me as my understanding of audio codec is limited. I have this audio source from a IPCAM (through a htto//... CGI interface). I am trying to write several client programs to play this audio source on Windows, MAC, as well as Android phone. The audio is encoded in G711 (PCM ulaw). Do I need to decode the PCM audio data to a raw audio data before I could pass it to the audio engine to play? If so, is there some sample code on how to decode it? I am confused as somehow I believe PCM is already RAW. Could I just feed it directly to the audio engine on Android for example? thanks

Faster way to convert from 24 bit wav pcm format to float?

瘦欲@ 提交于 2019-12-02 02:48:37
I need to read data in from a wav file in 24 bit pcm format, and convert to float. I'm using Python 2.7.2. The wave package reads the data in as a string, so what I've tried is: import wave import numpy as np import array import struct f = wave.open('filename.wav') # read in entire wav file wdata = f.readframes(nFrames) f.close() # unpack into signed integers and convert to float data = array.array('f') for i in range(0,nFrames*3,3): data.append(float(struct.unpack('<i', '\x00'+ wdata[i:i+3])[0])) # normalize sample values data = np.array(data) data = data / 0x800000 This is quite a bit faster

Audio output from Silverlight

狂风中的少年 提交于 2019-12-02 00:45:56
I'm looking to develop a Silverlight application which will take a stream of data (not an audio stream as such) from a web server. The data stream would then be manipulated to give audio of a certain format (G.711 a-Law for example) which would then be converted into PCM so that additional effects can be applied (such as boosting the volume). I'm OK up to this point. I've got my data, converted the G.711 into PCM but my problem is being able to output this PCM audio to the sound card. I basing a solution on some C# code intended for a .Net application but in Silverlight there is a problem with

如何利用python进行在线语音识别

£可爱£侵袭症+ 提交于 2019-12-01 21:37:53
如何利用python实现在线语音识别 本篇文章主要介绍使用 python 借助 百度人工智能 实现在线的 语音识别 功能。 学习经历 在正式介绍如何进行在线语音识别功能之前我想先分享一下我自己的学习顺序: 首先对核心内容语音识别模块进行编写,在编写的过程中发现音频文件需要使用 pcm格式 ,于是下载了百度AI的范例pcm文件,并且完成了语音识别,接下来学习转码,用手机录音,然后用 ffmpeg 将录音从mp3文件转换为pcm文件,开始使用cmd手动输入实现转码,顺利转码后改为学习用python调用cmd自动执行。最后是学习python录音,录音得到的文件是wav格式,于是又把mp3->pcm的代码改为wav->pcm,最后按顺序将录音,转码,识别三个模块串在一起,形成了一个在线语音识别的程序。程序可以实现固定时长的录音(说话前预设时间,中途无法中断或延长时间)保存录音文件并将录音文件转码成pcm格式,然后将pcm音频上传到百度AI平台(这就意味着必须保证网络的畅通),进行识别后传输回识别内容。 作为一个初学者在决定学习这项功能时觉得任务非常繁重,网上能搜集到的资料驳杂而零碎,但通过不断的拼凑与尝试,最终完成了程序的编写。现在将我的实现方法分享给大家,希望可以与大家互相交流学习! 逻辑顺序 用python实现在线语音识别,我们首先需要一段语音,这段语音的格式是 .pcm

How to play non-PCM file or convert it to PCM on the fly ?

狂风中的少年 提交于 2019-12-01 18:57:24
The following code works with some wav files, but with others I get, "InvalidOperationException was unhandled. Message=Sound API only supports playing PCM wave files." var webClient = new WebClient(); webClient.DownloadFile(url, fileName); var fileSound = new SoundPlayer(fileName); fileSound.PlaySync(); Is there a way to programmatically check if a wav file is "bad" (not a PCM wave file) and then convert it as necessary? What is odd is that the code works in the legacy Delphi app - all of the wav files play just fine. Here's the Delphi code: filename := GetEnvironmentVariable('TEMP')+'

FFmpeg: Encoding PCM 16 audio data Allocation error

泄露秘密 提交于 2019-12-01 12:44:12
I am currently trying to encode some raw audio data with some video inside an avi container. The video codec used is mpeg4 and I would like to use the PCM_16LE for the audio codec but I am facing a problem regarding the AVCodec->frame_size parameter for the audio samples. After doing all the correct allocation, I try allocating the audio frame and for AV_CODEC_ID_PCM_S16LE codec I don't have the codec frame_size needed to get the samples buffer size. Therefore the sample buffer size is huge and I simply can't allocate such quantity of memory. Does someone know how to bypass this issue and how

FFmpeg: Encoding PCM 16 audio data Allocation error

爱⌒轻易说出口 提交于 2019-12-01 09:55:57
问题 I am currently trying to encode some raw audio data with some video inside an avi container. The video codec used is mpeg4 and I would like to use the PCM_16LE for the audio codec but I am facing a problem regarding the AVCodec->frame_size parameter for the audio samples. After doing all the correct allocation, I try allocating the audio frame and for AV_CODEC_ID_PCM_S16LE codec I don't have the codec frame_size needed to get the samples buffer size. Therefore the sample buffer size is huge