Streaming audio through HttpWebrequest
-
Friday, October 19, 2007 3:29 PM
I've written some code using the waveIn/waveOut apis to stream audio from a PPC's mic to a linux (Perl) server on a local network (I can send to an ip address of 192.168.*.*). This is done through a tcp socket, and I would assume has to be local.
The only issue is that we have to do this through a public Http cgi script, and we can only do this through a file upload.
However, the recorded wav format is very large, and I've not found a way to stream data to a cgi-script--I just save the entire file to disk and then upload the wav file. And so this process takes too long, especially if you record your voice for quite a while.
So my question is:
Is there a way to purely stream data through a HttpWebrequest? (a Https cgi script)
Or is there a good API I can use to perhaps encode my wav file as a compressed format such as MP3 or OGG as I record?
*All of this is in C# and .NET CF 2.0, of course
Answers
-
Monday, October 22, 2007 4:54 PM
When recorded over GPRS, I changed the Sample rate to 11.025 Khz rather than 44.100 Khz.
This made it quick enough to function properly, and still sounded okay through our speakers. I even knocked the rate down to 22.050 over Wifi for exceptional speed.
All Replies
-
Monday, October 22, 2007 1:01 PM
After more work with it, I've found that my above method works fine over Wifi. The problem is that over GPRS, uploading a file can take forever--especially a large uncompressed wav file.
Is there a good way to compress a file such as this? Streaming would really only shave off a few seconds over GPRS anyways.
Any smaller format would do: MP3, OGG, or something like a RAR, etc.
-
Monday, October 22, 2007 4:54 PM
When recorded over GPRS, I changed the Sample rate to 11.025 Khz rather than 44.100 Khz.
This made it quick enough to function properly, and still sounded okay through our speakers. I even knocked the rate down to 22.050 over Wifi for exceptional speed.
-
Monday, October 22, 2007 5:11 PMModerator
For phone quality voice transmission you can use 8KHz 16 bit recording which you can "compress" twice to 8 KHz 8 bit A-Law or u-Law nonlinear encoding. That is a standard format used in telephony in the US/Japan (u-Law) and pretty much everywhere else (A-Law). You can find formulas for linear PCM to A/u-Law conversion using your favorite search engine; it's very simple and fast.

