Created
March 10, 2016 18:00
-
-
Save bertm/1647a29e61a0779cada0 to your computer and use it in GitHub Desktop.
MP3 stream of spoken time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Outputs a continuous MP3 stream with spoken current time on stdout. | |
# Requirements: text2wave (from festival) and ffmpeg (some old version) | |
# Speak interval. Must be higher than the length of the spoken time. | |
INTERVAL=5 | |
RATE=48000 | |
TS=$(($(date +%s) + $INTERVAL)) | |
BYTESPERSPEAK=$((2 * $RATE * $INTERVAL)) # S16_LE | |
TMP=$(tempfile) | |
while true | |
do | |
date -d @$TS +%-H:%M:%S | text2wave -otype raw -f $RATE > $TMP | |
LEN=$(wc -c < $TMP) | |
cat $TMP | |
head -c $(($BYTESPERSPEAK - $LEN)) /dev/zero | |
TS=$(($TS + $INTERVAL)) | |
done | ffmpeg -v error -f s16le -ar $RATE -ac 1 -i - -f mp3 -ar 11025 -ab 8000 - | |
rm $TMP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment