How to make speaking clock (via cron and festival tts) work while playing music

I switched to Linux since last 11 months, I am on Ubuntu 15.04, I have learned to use Cron for various tasks.

I use Cron to announce time via festival TTS (using mbrolla voice) hourly.

This is the command that I use in Cron (it is saved as .sh script and its path pointed in Cron)

echo "Its" `date "+%l O clock now"` |  festival --tts

The problem is it doesn't work when music or video is playing, however after music is stopped or paused it announces the time.

I googled for it and found that in order to have multiple access to sound card one must use aoss (alsa-oss) I installed the required alsa-oss package and I modified the command as per the search results like this

echo "Its" `date "+%l O clock now"` | aoss festival --tts

but still it doesn't work and if I run the command with aoss it gives some error as below:

ERROR: ld.so: object '/usr/lib/x86_64-linux-gnu/libaoss.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.

I don't know if this error is related to it somehow.

Someone in Reddit mentioned to use Alsa or Pulse-audio with festival and pointed me to arch forums which states that to use Alsa or Pulse-Audio we must edit the ~/.festivalrc file, or /usr/share/festival/festival.scm and add some lines to it.

I added the lines mentioned in the link, but still it didn't solve my problem

Hence, I need help from you guys. Please help me correct this so that the time is announced by Cron even when music or video is playing.


As per this answer: Can I use cron to chime at top of hour like a grandfather clock? you need to export an environment variable before playing sounds in your cron script:

export XDG_RUNTIME_DIR="/run/user/1000"