Talking Rock Pi

What I am trying to do is make Rock say the current hour each exact hour. I know how to do that in cron, but there are problems earlier.

I’ve installed alsa-utils and espeak. I make alsa play some sounds:
aplay /usr/share/sounds/alsa/*
However espeak does not work:
espeak "Text you wish to hear back"
The are many errors:

ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
...
Expression 'PaAlsaStreamComponent_FinishConfigure( &self->playback, hwParamsPlayback, outParams, self->primeBuffers, realSr, outputLatency )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2738
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2843

snd-bcm2835 is not available in modules…

How can I make Rock talk to me?

This is not Raspberry Pi:

1 Like

As always your comments are very useful…

aplay does play sound but not from espeak, mplayer gives silence even when playing sound and espeak gives error.

@Stephen can you help with that?

Got it!

Use these commands:

> /etc/asound.conf
> ~/.asoundrc
alsamixer
aplay -l
aplay /usr/share/sounds/alsa/*
apt install alsa-utils
apt install espeak
apt install mplayer
apt install pulseaudio
apt install pulseaudio-module-jack 
espeak "Hello World!"
espeak "Hello World!" --stdout > /test.wav
espeak "Hello World!" --stdout | aplay
pactl set-default-sink alsa_output.platform-es8316-sound.analog-stereo
pulseaudio --start
adduser root audio

First two files need some special content.

Now espeak works!

For the problem I have found the solution to add line in /etc/crontab:

0 *	* * *	root	/root/hour

and put in /root/hour file following script:

#!/usr/bin/env bash
h=$(date +"%H")
pulseaudio --start
pactl set-default-sink alsa_output.platform-es8316-sound.analog-stereo
case "$h" in
        "10") espeak -v pl "godzina dziesiąta" --stdout | paplay ;;
        "11") espeak -v pl "godzina jedenasta" --stdout | paplay ;;
        "12") espeak -v pl "godzina dwunasta" --stdout | paplay ;;
        "13") espeak -v pl "godzina trzynasta" --stdout | paplay  ;;
        "14") espeak -v pl "godzina czternasta" --stdout | paplay  ;;
        "15") espeak -v pl "godzina piętnasta" --stdout | paplay  ;;
        "16") espeak -v pl "godzina szesnasta" --stdout | paplay  ;;
        "17") espeak -v pl "godzina siedemnasta" --stdout | paplay  ;;
        "18") espeak -v pl "godzina osiemnasta" --stdout | paplay  ;;
        "19") espeak -v pl "godzina dziewiętnasta" --stdout | paplay  ;;
        "20") espeak -v pl "godzina dwudziesta" --stdout | paplay  ;;
        "21") espeak -v pl "godzina dwudziesta pierwsza" --stdout | paplay  ;;
        "22") espeak -v pl "godzina dwudziesta druga" --stdout | paplay  ;;
        "23") espeak -v pl "godzina dwudziesta trzecia" --stdout | paplay  ;;
        "00") espeak -v pl "północ" --stdout | paplay  ;;
        "01") espeak -v pl "godzina pierwsza" --stdout | paplay  ;;
        *)
esac

Which tells me each full hour which hour is it.

2 Likes