6

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.

2
  • It appears that there is inconsistency between your library and executable binary. You installed either wrong architecture library or application. Check out file /sbin/init if it prints 32 bit or 64 bit.
    – kenn
    May 8 '15 at 12:33
  • I did file /sbin/init the output was /sbin/init: symbolic link to `/lib/systemd/systemd' then i did file /lib/systemd/systemd I got this /lib/systemd/systemd: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=ad47c3b45c2d2d67fabd4ef26ea02188c9197855, stripped May 8 '15 at 12:53
2

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"
0

Use gTTS to get a more natural voice.

gTTS (Google Text-to-Speech), a Python library and CLI tool to interface with Google Translate's text-to-speech API. Write spoken mp3 data to a file, a file-like object (bytestring) for further audio manipulation, or stdout.

@hourly   XDG_RUNTIME_DIR=/run/user/1000 /usr/local/bin/gtts-cli -l en "Hour $(/bin/date +\%l)"  | /usr/bin/play -t mp3 - &> /dev/null

Of course, change the text and language code to your desire.

1000 is my $UID/id -u.

Installation

pip install gtts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.