Created
April 13, 2018 07:30
-
-
Save zeehio/3a1b5f8b9c491ba15ae71489c71b0bb0 to your computer and use it in GitHub Desktop.
How to make Spanish espeak say 'mycroft' properly
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/sh | |
# 1. Check that espeak fails to transcribe mycroft: | |
echo "How espeak transcribes 'hola mycroft':" | |
espeak -v spanish -x -q --pho "hola mycroft" | |
# 'ola mik**'Oft | |
echo "How espeak should transcribe 'hola mycroft':" | |
espeak -v spanish -x -q --pho "hola máicroft" | |
# 'ola m'aik**Oft | |
# 2. Download the Spanish dictionary and phonetic transcription rules: | |
ES_RULES_URL="https://sources.debian.org/data/main/e/espeak/1.48.04+dfsg-5/dictsource/es_rules" | |
ES_LIST_URL="https://sources.debian.org/data/main/e/espeak/1.48.04+dfsg-5/dictsource/es_list" | |
echo "Downloading es_rules and es_list from espeak source package" | |
curl "${ES_RULES_URL}" > es_rules || exit 1 | |
curl "${ES_LIST_URL}" > es_list || exit 1 | |
echo "Download finished" | |
# 3. Edit es_list. Add the transcription for mycroft: | |
# mycroft m'aik**Oft | |
echo "Adding correct mycroft transcription to es_list" | |
echo "mycroft\tm'aik**Oft" >> es_list | |
echo "Transcription added" | |
# 4. Find the espeak-data system directory" | |
echo "Finding espeak-data system directory" | |
ESPEAK_DATA_PATH=`espeak --version | sed 's|.*at: ||'` | |
[ -d "${ESPEAK_DATA_PATH}" ] || ( echo "espeak-data system directory not found"; exit 1) | |
echo "espeak-data system directory was found at ${ESPEAK_DATA_PATH}" | |
# 5. Create espeak-data directory needed by espeak --compile and | |
# copy files needed from the system wide espeak-data directory | |
mkdir -p "espeak-data/voices/europe" | |
# /usr/lib/x86_64-linux-gnu/espeak-data | |
echo "Copying some system espeak-data files into our espeak-data directory" | |
cp "${ESPEAK_DATA_PATH}/phontab" "espeak-data/" || exit 1 | |
cp "${ESPEAK_DATA_PATH}/phonindex" "espeak-data/" || exit 1 | |
cp "${ESPEAK_DATA_PATH}/phondata" "espeak-data/" || exit 1 | |
cp "${ESPEAK_DATA_PATH}/intonations" "espeak-data/" || exit 1 | |
cp "${ESPEAK_DATA_PATH}/voices/europe/es" "espeak-data/voices/europe/" || exit 1 | |
echo "Files successfully copied" | |
# 6. Compile the es_list and es_rules into es_dict: | |
echo "Compiling the new es_list with es_rules into a new es_dict" | |
echo "NOTE: The message below 'Can't read dictionary file' is expected. Ignore it" | |
espeak --path="$PWD" --compile=es || (echo "Compilation failed"; exit 1) | |
echo "Compilation succeeded" | |
# 7. Copy the compiled es_dict into the ESPEAK_DATA_PATH | |
echo "I need to copy the espeak-data/es_dict file into ${ESPEAK_DATA_PATH}" | |
echo "I will use sudo to do this:" | |
echo "sudo cp \"espeak-data/es_dict\" \"${ESPEAK_DATA_PATH}\"" | |
sudo cp "espeak-data/es_dict" "${ESPEAK_DATA_PATH}" || (echo "Copy not successful"; exit 1) | |
echo "Copy was successful" | |
# 8. Try the new espeak | |
echo "espeak now can transcribe 'hola mycroft':" | |
espeak -v spanish -x -q --pho "hola mycroft" | |
# 9. How to undo | |
echo "You can undo this script with: sudo apt reinstall espeak-data" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment