Notes for when running on the Raspberry Pi with the Rasbian Buster OS.
When using Java 11 OpenJDK, you may find the audio from the Text To Speech coming out the HDMI port instead of the selected 3.5mm Audio socket on the side of the Raspberry Pi.
This is caused by Pulse Audio not following the requested settings and routing the audio from the Java apps to a different output, the HDMI like it or not.
The solution is to edit the Java sound.properties file.
sudo nano /etc/java-11-openjdk/sound.properties
You will need to add in the following lines into the config:
javax.sound.sampled.Clip=com.sun.media.sound.DirectAudioDeviceProvider javax.sound.sampled.Port=com.sun.media.sound.PortMixerProvider javax.sound.sampled.SourceDataLine=com.sun.media.sound.DirectAudioDeviceProvider javax.sound.sampled.TargetDataLine=com.sun.media.sound.DirectAudioDeviceProvider
Make sure you don't have the # in front of the lines.
Reboot the Raspberry Pi.
sudo reboot
Make sure you selected the 3.5mm Audio jack as your output device:
alsamixer
press F6 to select the sound card you want as the output.
Select 1 Headphones.
now change into your MRL directory and start MRL the way you normally would.
There had been a similar issue with the Java 1.8
Edit the sound.properties
sudo nano /etc/java-8-openjdk/sound.properties
In that one, you had to comment out the following line:
#javax.sound.sampled.Clip=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider #javax.sound.sampled.Port=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider #javax.sound.sampled.SourceDataLine=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider #javax.sound.sampled.TargetDataLine=org.classpath.icedtea.pulseaudio.PulseAudioMixerProvider
and uncomment these ones:
javax.sound.sampled.Clip=com.sun.media.sound.DirectAudioDeviceProvider javax.sound.sampled.Port=com.sun.media.sound.PortMixerProvider javax.sound.sampled.SourceDataLine=com.sun.media.sound.DirectAudioDeviceProvider javax.sound.sampled.TargetDataLine=com.sun.media.sound.DirectAudioDeviceProvider
I hope this helps any one having issues with the audio output on their Raspberry Pis :-)
Ray