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 on 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.

Pablo Bianchi
  • 15,657
  • 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 08 '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 – raghavendra Kamath May 08 '15 at 12:53

2 Answers2

3

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

Piper

A fast, local neural text to speech system. Check site project for installation, download of a voice and usage. For e.g.:

echo 'Welcome to the world of speech synthesis!' | \
  ./piper --model blizzard_lessac-medium.onnx --output_file welcome.wav

gTTS

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.

XDG_RUNTIME_DIR="/run/user/1000"
@hourly /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.
  • Where 1000 is the user $UID/id -u1.
  • Installation: pip install gtts.

To use it inline: @hourly export XDG_RUNTIME_DIR="/run/user/1000"; /usr/local/bin/gtts-cli...

Check also WaveNet based alternatives, like wavenet_vocoder

Pablo Bianchi
  • 15,657