Posts: 1
Joined: Wed Dec 05, 2018 5:50 am

ALSA java process

Wed Dec 05, 2018 6:13 am


Im trying to do an application with java for voice recognition and voice synthesis. I've created a class for recognition using google speech api, recording audio and processing it using a REST Request, it works fine. Also, I have a bash script to synthesis voice using a REST request to google translate and mplayer reproduction, it also works fine. However, when I try to use both methods in a main program, mplayer reproduction "blocks" devices and recognition program fails recording with: 788:audio open error: device or resource busy. If I close BlueJ java IDE and run first voice recognition, it works fine, but whenever I run mplayer reproduction from java, device stays "blocked"

I dont know how could I resolve this, looks like both methods try to reach same device but I dont know how to specify this.

Any help would be really appreciated.

These are my bash scripts that are called by java methods:


Code: Select all

say() { local IFS=+;/usr/bin/mplayer "$*&tl=es&client=tw-ob";}
say $*


Code: Select all

record() { sudo arecord -d $* -f S16_LE -D plughw:1,0 /home/pi/Braille/record.wav;}
record $*

Also my .asoundrc

Code: Select all

pcm.!default {
 type asym
   playback.pcm {
     type hw
     pcm "hw:0,0"
   capture.pcm {
     type plug
     slave.pcm "hw:1,0"
I've tried using Process()..destroyForcibly(); but it doesnt work.

Thanks in advance


Return to “Java”