Streaming speech from Android phone to a server for audio analysis doesn't seem to be an easy task.
Android:
In android the audiorecorder provides a nice API which I adapted from Stream Live Android Audio to Server to stream the microphone input to any server.
The output is basically generated with the few following lines:
DatagramSocket socket = new DatagramSocket();
final InetAddress destination = InetAddress.getByName("1.1.1.1");
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,sampleRate,channelConfig,
audioFormat,minBufSize*10);
while(rec == true) {
minBufSize = recorder.read(buffer, 0, buffer.length);
packet = new DatagramPacket (buffer,buffer.length,destination,port);
socket.send(packet);
}
Making the socket work (which should be in C/C++) however gives me a headache. I generally want to do the three steps on my Ubuntu server:
1. Receive audio stream (I locally used Portaudio for audio recording, I couldn't really find an appropriate tool yet in C/C++ that would use the stream as an input.Is there something like a microphone emulator from socket connection??)
2. Analyze stream and give result as jsonstring(or just a text string for the first
3. Stream this result back to the android device.
I am new to network programming and I tried many tutorials such as:
http://codebase.eu/tutorial/linux-socket-programming-c/
http://www.pcs.cnu.edu/~dgame/sockets/socketsC++/sockets.html
http://www.the-tech-tutorial.com/?p=1555
And none of them seems to be appropriate for the task. So:
How can I manage audio streamings in C/C++.
And in what format is the stream then available for further processing?
Any help would be really appreciated. Thanks.