Skip to content

Instantly share code, notes, and snippets.

@ArtBIT
Last active April 13, 2021 17:12
Show Gist options
  • Select an option

  • Save ArtBIT/139504dd05c910cc82e6b5f4729702b4 to your computer and use it in GitHub Desktop.

Select an option

Save ArtBIT/139504dd05c910cc82e6b5f4729702b4 to your computer and use it in GitHub Desktop.
GLaDOS eSpeak
random_pitch() {
local delta=${1:-50}
local value=$(( ($RANDOM % $delta) - $delta/2 ))
echo "+${value}" | sed 's/+-/-/'
}
glados() {
local pitch=70
local speed=180
local lang=en
local voice=f3
local output=
local text="Hello, and, again, welcome to the Aperture Science Computer-aided Enrichment Center"
while true; do
case "$1" in
-v | --voice )
voice="$2"
shift 2
;;
-l | --language )
lang="$2"
shift 2;
;;
-p | --pitch )
pitch="$2"
shift 2;
;;
-s | --speed )
speed="$2"
shift 2
;;
-o | --output)
output="-w $2"
shift 2
;;
-- )
shift
break
;;
* )
if [ -z "$1" ]; then
break;
fi
text="$1"
shift
;;
esac
done
local word_pitch=0
local prosody_data=""
for word in $text; do
word_pitch=$(random_pitch 50)
prosody_data="${prosody_data}<prosody pitch=\"${word_pitch}\">${word}</prosody>";
done
espeak "${prosody_data}" -m -p ${pitch} -s ${speed} -v "${lang}+${voice}" ${output}
}
glados "$@"
@ArtBIT

ArtBIT commented Jun 19, 2019

Copy link
Copy Markdown
Author
# Default message https://sndup.net/8dp2
$ glados.sh

# Higher pitch and slower speed
$ glados.sh "This was a triumph!" --pitch 120 --speed 90

# Save to a wav file
$ glados.sh "Excellent. Please proceed into the chamberlock after completing each test. First, however, note the incandescent particle field across the exit. This Aperture Science Material Emancipation Grill will vaporize any unauthorized equipment that passes through it - for instance, the Aperture Science Weighted Storage Cube."" -w glados.wav

@ivin-v

ivin-v commented Dec 2, 2020

Copy link
Copy Markdown

Greetings. How to listen to an example of a synthesized voice with this script? Thanks.

@ArtBIT

ArtBIT commented Dec 2, 2020

Copy link
Copy Markdown
Author

Greetings. How to listen to an example of a synthesized voice with this script? Thanks.

The instaud.io service has been shut down, apparently. Try this https://sndup.net/8dp2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment