speak.sh
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
| speak.sh [2011/02/23 08:45] – Die Seite wurde neu angelegt: „<pre> #!/bin/sh # # mkulawmsg/speak (C) 2000 Malte J. Wetz <mail@malte-wetz.de> # # If called as "mkulawmsg", this script will generate an # ulaw-encoded audio …“ admin | speak.sh [2017/04/01 21:32] (aktuell) – gelöscht admin | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | < | ||
| - | #!/bin/sh | ||
| - | # | ||
| - | # mkulawmsg/ | ||
| - | # | ||
| - | # If called as " | ||
| - | # ulaw-encoded audio stream from a plain text file. This stream can | ||
| - | # be used with vbox3. | ||
| - | # | ||
| - | # If called as " | ||
| - | # of recoding it for vbox, it will play the audio using aplay from | ||
| - | # ALSA. | ||
| - | # | ||
| - | # It requires " | ||
| - | # configured correctly on your system. | ||
| - | # You can download mbrola from here: | ||
| - | # http:// | ||
| - | # There is also a link to txt2pho. | ||
| - | # | ||
| - | # | ||
| - | # NOTE: I discovered that mbrola appearently does not work together | ||
| - | # with newer glibc (ver 2.3 and higher). As a workaround, I am | ||
| - | # using the uClibc from http:// | ||
| - | # | ||
| - | # ' | ||
| - | # As a workaround for that, I set up a cache that buffers the | ||
| - | # pho and audio as normal files. That works. | ||
| - | # | ||
| - | ############################################################################## | ||
| - | # SETTINGS: Change the following parameters to meet your requirements. | ||
| - | # If you don't know what you're doing, just don't do anything or at | ||
| - | # least keep a backup! | ||
| - | ############################################################################## | ||
| - | |||
| - | # Full path of mbrola binary | ||
| - | MBROLA=/ | ||
| - | |||
| - | # Full path to mbrola voices | ||
| - | VOICEPATH=/ | ||
| - | |||
| - | # mbrola default voice to use with this script (without path!) | ||
| - | # Can be changed on command line via " | ||
| - | VOICE=de5 | ||
| - | |||
| - | # Full path to txt2pho binary | ||
| - | TXT2PHO=/ | ||
| - | |||
| - | # Full path of preproc binary (which is part of txt2pho) | ||
| - | PREPROC=/ | ||
| - | |||
| - | # Parameters for preproc. Specify Rules and abbreviations files | ||
| - | # (both are part of txt2pho). | ||
| - | PPPARAMS="/ | ||
| - | / | ||
| - | |||
| - | # Full path of numfilt binary (which is part of txt2pho) | ||
| - | # NUMFILT=/ | ||
| - | |||
| - | # Full path of pipefilt binary (which is part of txt2pho) | ||
| - | PIPEFILT=/ | ||
| - | |||
| - | # Full path of sox binary | ||
| - | SOX=/ | ||
| - | |||
| - | # Parameters for sox. Please note that the input sampling rate | ||
| - | # (" | ||
| - | # voices output different sample rates. | ||
| - | # Also note, that if $BASENAME is " | ||
| - | # vbox-compatible and be written to stdout. If $BASENAME is " | ||
| - | # output will be written to /dev/audio. | ||
| - | SOXPARAMS=" | ||
| - | |||
| - | # Here, you can specify which voice produces what output sampling | ||
| - | # rate (see above). | ||
| - | # Format is: "< | ||
| - | RATES=" | ||
| - | |||
| - | # Set a default input sampling rate that will be applied if none | ||
| - | # of the entries above match. | ||
| - | DEFAULTRATE=" | ||
| - | |||
| - | # Give your path to aplay here | ||
| - | # | ||
| - | PLAY=/ | ||
| - | # | ||
| - | |||
| - | # Specify what is neccessary to play the resulting audio stream | ||
| - | # (see SOXPARAMS above for details). | ||
| - | # currently only for aplay 0.9.x | ||
| - | PLAYPARAMS=" | ||
| - | # | ||
| - | |||
| - | # Where should the lockfile be placed? | ||
| - | LOCKFILE=/ | ||
| - | |||
| - | # Where to cache the files? | ||
| - | # store .pho and .raw files and use no pipes (see NOTE above). | ||
| - | # The directory will be created if it does not exist and removed | ||
| - | # when not needed anymore. Leave blank for no cache. | ||
| - | CACHE=/ | ||
| - | |||
| - | ############################################################################## | ||
| - | # END OF SETTINGS: There should be nothing to change below this point! | ||
| - | ############################################################################## | ||
| - | |||
| - | # Never change those two! | ||
| - | BASENAME=`basename $0` | ||
| - | VERSION=" | ||
| - | |||
| - | # Evaluate command line options | ||
| - | while getopts hapnv:l: switch; do | ||
| - | case " | ||
| - | a) cmd=" | ||
| - | p) cmd=" | ||
| - | n) cmd=" | ||
| - | v) VOICE=$OPTARG | ||
| - | l) LOCKING=$OPTARG | ||
| - | h) cat<< | ||
| - | $BASENAME $VERSION | ||
| - | |||
| - | DESCRIPTION | ||
| - | If called as " | ||
| - | Script that will use a 3rd party TTS system to generate an ulaw | ||
| - | encoded voice stream from plain text. Text is taken from stdin. | ||
| - | Resulting audio is compatible with vbox3 and written to stdout. | ||
| - | If called as " | ||
| - | Script will work as above, but instead of converting the resulting | ||
| - | voice stream to vbox3-Format, | ||
| - | player to send it directly to the sound card. | ||
| - | |||
| - | USAGE | ||
| - | $BASENAME [OPTIONS] | ||
| - | |||
| - | PARAMETERS | ||
| - | -h Display this screen and exit | ||
| - | -p Will remove any newline characters from pipe and add breathe | ||
| - | pause at punctuation marks (use pipefilt). | ||
| - | -n Speak digits as full numbers (use numfilt). | ||
| - | -a Replace some default abbreviations with full text | ||
| - | (use preproc). | ||
| - | -v xxx Use Mbrola voice xxx for synthesis (default: $VOICE). | ||
| - | -l n If another instance of �$BASENAME -l� is running, wait max. n sec. | ||
| - | for it to finish, then exit. Prevents more than one $BASENAME talking | ||
| - | at the same time. | ||
| - | |||
| - | NOTES | ||
| - | - Options are order sensitve. I.e., if you specify "-n -a" then first numbers | ||
| - | will be filtered, then abbreviation. $BASENAME therefore will not say | ||
| - | dates correctly. Instead, specify "-a -n". | ||
| - | EOF | ||
| - | exit | ||
| - | ;; | ||
| - | esac | ||
| - | done | ||
| - | |||
| - | # Check for txt2pho config files | ||
| - | [ -r "/ | ||
| - | echo " | ||
| - | echo " | ||
| - | exit 1 | ||
| - | } | ||
| - | |||
| - | # Replace the input sample rate based on selected voice. | ||
| - | for i in $RATES; do | ||
| - | v=`echo $i | cut -d ':' | ||
| - | r=`echo $i | cut -d ':' | ||
| - | | ||
| - | [ " | ||
| - | done | ||
| - | [ -z " | ||
| - | |||
| - | # Based on name of script, decide what postprocessor to use | ||
| - | case " | ||
| - | mkulawmsg) | ||
| - | PP=$SOX | ||
| - | PP_PARAMS=`echo $SOXPARAMS | sed -e " | ||
| - | unset CACHE | ||
| - | ;; | ||
| - | speak) | ||
| - | PP=$PLAY | ||
| - | PP_PARAMS=`echo $PLAYPARAMS | sed -e " | ||
| - | ;; | ||
| - | esac | ||
| - | |||
| - | # check for lock file... | ||
| - | [ -z " | ||
| - | # check if lockfile is stale... | ||
| - | [ -e " | ||
| - | ps -p `cat " | ||
| - | echo " | ||
| - | rm -f " | ||
| - | } | ||
| - | } | ||
| - | | ||
| - | # wait for lockfile to be removed by other instance... | ||
| - | while [ -e " | ||
| - | sleep 1 | ||
| - | count=$(($count + 1)) | ||
| - | [ " | ||
| - | echo " | ||
| - | echo " | ||
| - | exit 1 | ||
| - | } | ||
| - | done | ||
| - | } | ||
| - | |||
| - | [ -z " | ||
| - | |||
| - | |||
| - | # use the cache, is set | ||
| - | if [ -z " | ||
| - | # Assemble the final command without cache and execute it | ||
| - | cmd=" | ||
| - | $MBROLA ${VOICEPATH}/ | ||
| - | | ||
| - | eval $cmd | ||
| - | else | ||
| - | # create cache dir if neccessary | ||
| - | [ -d " | ||
| - | | ||
| - | # Assemble the final command with cache and execute it | ||
| - | cmd=" | ||
| - | $MBROLA ${VOICEPATH}/ | ||
| - | $PP $PP_PARAMS $CACHE/ | ||
| - | | ||
| - | eval $cmd | ||
| - | | ||
| - | # remove cache | ||
| - | rm -rf " | ||
| - | fi | ||
| - | |||
| - | [ -z " | ||
| - | |||
| - | exit | ||
| - | </ | ||
speak.sh.1298450726.txt.gz · Zuletzt geändert: von admin
