Streaming audio from microphone with Java

前端 未结 2 879
渐次进展
渐次进展 2020-12-30 17:43

I\'m developing a project which requires me to stream audio from microphone from a client to a server. The code shown below is what I have written. When I run both the clie

相关标签:
2条回答
  • 2020-12-30 18:09

    I am not familiar with this, so don't get mad if I am way off here, but reading the api for DataLine it seems to function like a buffer, that you have to flush or drain in this case to get the output. Have you attempted to put the mic.drain()/speaker.drain() command in the while loop?

    0 讨论(0)
  • 2020-12-30 18:12

    The problem is in client side, in the line

    byte[] data = IOUtils.toByteArray(is);

    It deals with the object itself, not with the content. So, you must change it to this:

    byte[] data = new byte[1024];

    0 讨论(0)
提交回复
热议问题