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.

Revisions

  1. ArtBIT revised this gist Jun 19, 2019. 1 changed file with 18 additions and 12 deletions.
    30 changes: 18 additions & 12 deletions glados.sh
    Original file line number Diff line number Diff line change
    @@ -5,15 +5,12 @@ random_pitch() {
    }

    glados() {
    local text=${1:-Hello, and, again, welcome to the Aperture Science Computer-aided Enrichment Center}
    local prosody_data=""
    shift 1


    pitch=70
    speed=180
    lang=en
    voice=f3
    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 )
    @@ -32,23 +29,32 @@ glados() {
    speed="$2"
    shift 2
    ;;
    -o | --output)
    output="-w $2"
    shift 2
    ;;
    -- )
    shift
    break
    ;;
    * )
    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
    echo espeak "${prosody_data}" "${espeak_options}"
    espeak "${prosody_data}" -m -p $pitch -s $speed -v"${lang}+${voice}" "$@"

    espeak "${prosody_data}" -m -p ${pitch} -s ${speed} -v "${lang}+${voice}" ${output}
    }

    glados "$@"
  2. ArtBIT created this gist Jun 19, 2019.
    54 changes: 54 additions & 0 deletions glados.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    random_pitch() {
    local delta=${1:-50}
    local value=$(( ($RANDOM % $delta) - $delta/2 ))
    echo "+${value}" | sed 's/+-/-/'
    }

    glados() {
    local text=${1:-Hello, and, again, welcome to the Aperture Science Computer-aided Enrichment Center}
    local prosody_data=""
    shift 1


    pitch=70
    speed=180
    lang=en
    voice=f3
    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
    ;;
    -- )
    shift
    break
    ;;
    * )
    break
    ;;
    esac
    done

    local word_pitch=0
    for word in $text; do
    word_pitch=$(random_pitch 50)
    prosody_data="${prosody_data}<prosody pitch=\"${word_pitch}\">${word}</prosody>";
    done
    echo espeak "${prosody_data}" "${espeak_options}"
    espeak "${prosody_data}" -m -p $pitch -s $speed -v"${lang}+${voice}" "$@"
    }

    glados "$@"