#!/bin/sh
# include common script
. "`dirname $0`/common"
# and run needed checks before
is_hash
is_mbrola

check_voice_folder() {
        voice_file=${1#mb-} # remove mb- prefix
        voice_file=${voice_file%+*} # remove variant suffix
        if [ -f "/usr/share/mbrola/$voice_file" ]; then
                voice_file="/usr/share/mbrola/$voice_file"
        elif [ -f "/usr/share/mbrola/$voice_file/$voice_file" ]; then
                voice_file="/usr/share/mbrola/$voice_file/$voice_file"
        elif [ -f "/usr/share/mbrola/voices/$voice_file" ]; then
                voice_file="/usr/share/mbrola/voices/$voice_file"
        else
                voice_file=""
        fi
}

test_mb () {
        MBVOICE=$1
        EXPECTED=$2
        TEST_TEXT=$3
        check_voice_folder $MBVOICE
        if [ "$voice_file" != "" ]; then
                test_wav $MBVOICE $EXPECTED $TEST_TEXT $TEST_TEXT
        else
                echo "$MBVOICE was not tested"
        fi
}


test_mb mb-fr4 31fae066f45d4a9dc56289344f28dd00bce77875 "Bonjour"
test_mb mb-fr4+announcer f62c9cad15df194ac7cedfcfb36b6d9ccc70a634 "Bonjour" # mbrola + variant