0

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:

  1. How can I manage audio streamings in C/C++.

  2. And in what format is the stream then available for further processing?

Any help would be really appreciated. Thanks.

Community
  • 1
  • 1
user2212461
  • 3,105
  • 8
  • 49
  • 87
  • 1
    Nonintuitive as it seems, you need to remove the library request or someone will probably close your question. As for the rest of it, have you managed to achieve connection between the android device and your PC? Two tools you may find useful for piping audio around while testing are `netcat` and `aplay` / `arecord`. – Chris Stratton Apr 03 '14 at 21:54

1 Answers1

1

You can take a look at QAudioOutput. In this question you can read how to send audio stream over ethernet with UDP datagrams:

How i can play streaming audio over Ethernet in Qt?

Community
  • 1
  • 1
4pie0
  • 29,204
  • 9
  • 82
  • 118