Spanish mental addition mp3

Fri, 2008-08-01

In another post I wrote how to create with festival, lame and sox an mp3 to practice mental addition. That mp3 used festival’s default english voice. What I did to have a spanish version is the following:

Copy the text2wave script to ~/bin/
mkdir ~/bin
cp $(which text2wave) ~/bin/text2wavees

Add the following after line 46 of ~/bin/text2wavees:
(voice_el_diphone)

Use the following script to generate the mp3:


#!/bin/bash -e

# output file
output=$1

if [ -z "$output" ]; then 
        echo "usage: $0 OUTFILE"
        exit
fi

TEXT2WAVE="$HOME/bin/text2wavees"

CWD=`pwd`
TMP=`mktemp -d /tmp/speed_addition.XXXX`
pushd $TMP

# pause length in seconds
pause=8

for i in `seq 32`; do
        x=$(($RANDOM % 999))
        while [ $x -lt 11 ]; do
                x=$(($RANDOM % 999))
        done
        y=$(($RANDOM % 999))
        while [ $y -lt 11 ]; do
                y=$(($RANDOM % 999))
        done
        echo "$x + $y" | $TEXT2WAVE -o add$i.wav
        echo "$(($x+$y))" | $TEXT2WAVE -o result$i.wav
        sox add$i.wav add_with_pause$i.wav pad 3 $pause
        sox add_with_pause$i.wav result$i.wav out$i.wav
done;

sox out*wav out.wav
lame --ta speed-math --tl speed-math-es --tt $output --silent out.wav $CWD/$output

popd

rm -r $TMP


Create mp3 to practice mental addition

Sat, 2008-06-28

Repost from my tumblelog.

This script uses the festival text to speech system, SoX and lame to generate an mp3 to practice mental addition. It basically says two numbers and after a delay says the sum of those two numbers, the delay is supposed to give you time to calculate the sum mentally:


#!/bin/bash -e

# output file
output=$1

if [ -z "$output" ]; then 
        echo "usage: $0 OUTFILE"
        exit
fi

CWD=`pwd`
TMP=`mktemp -d /tmp/speed_addition.XXXX`
pushd $TMP

# pause length in seconds
pause=8

for i in `seq 32`; do
        x=$(($RANDOM % 999))
        while [ $x -lt 11 ]; do
                x=$(($RANDOM % 999))
        done
        y=$(($RANDOM % 999))
        while [ $y -lt 11 ]; do
                y=$(($RANDOM % 999))
        done
        echo "$x . + . $y" | text2wave -o add$i.wav
        echo "$(($x+$y))" | text2wave -o result$i.wav
        sox add$i.wav add_with_pause$i.wav pad 3 $pause
        sox add_with_pause$i.wav result$i.wav out$i.wav
done;

sox out*wav out.wav
lame --ta speed-math --tl speed-math --tt $output --silent out.wav $CWD/$output

popd

rm -r $TMP