[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Search]

Emacspeak eSpeak with American English



Hi,

I'm using emacspeak with eSpeak. I like it a lot but unfortunately it
uses British English by default and I would like to use American
English instead.
How can I force it to use American English.
I'm able to force espeak to use American English when running it from
command line as follows:
espeak -v en-us "Hi there"

I'm not able to configure emacspeak to use espeak with american english.
I'm using Emacspeak in Ubuntu 16.04. I've installed it from a standard
distro package. I did not modify the configuration.
My Emacspeak is launched as follows:

emacs24 -l /usr/share/emacs24/site-lisp/emacspeak/lisp/emacspeak-setup.el
/usr/bin/tclsh /usr/share/emacs24/site-lisp/emacspeak/servers/espeak

I use the following ubuntu packages:
emacs24 - 24.5+1-6ubuntu1.1
emacspeak - 41.0+dfsg-2
emacspeak-espeak-server - 41.0+dfsg-2
espeak - 1.48.04+dfsg-2

Below is the listing of the following 2 files:
/usr/share/emacs24/site-lisp/emacspeak/lisp/emacspeak-setup.el
/usr/bin/tclsh /usr/share/emacs24/site-lisp/emacspeak/servers/espeak

Please help me to use American English language.
Great thanks in advance.
Pawel

################################# emacspeak-setup.el

;;; emacspeak-setup.el --- Setup Emacspeak environment --loaded to
start Emacspeak
;;; $Id: emacspeak-setup.el 9594 2014-11-26 01:17:48Z tv.raman.tv $
;;; $Author: tv.raman.tv $
;;; Description:  File for setting up and starting Emacspeak
;;; Keywords: Emacspeak, Setup, Spoken Output
;;{{{  LCD Archive entry:
;;; LCD Archive Entry:
;;; emacspeak| T. V. Raman |raman@xxxxxxxxxxx
;;; A speech interface to Emacs |
;;; $Date: 2008-06-06 19:00:23 -0700 (Fri, 06 Jun 2008) $ |
;;;  $Revision: 4532 $ |
;;; Location undetermined
;;;

;;}}}
;;{{{  Copyright:

;;;Copyright (C) 1995 -- 2011, T. V. Raman
;;; Copyright (c) 1994, 1995 by Digital Equipment Corporation.
;;; All Rights Reserved.
;;;
;;; This file is not part of GNU Emacs, but the same permissions apply.
;;;
;;; GNU Emacs is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2, or (at your option)
;;; any later version.
;;;
;;; GNU Emacs is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Emacs; see the file COPYING.  If not, write to
;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

;;}}}
;;{{{ Introduction

;;; Commentary:
;;; Entry point for Emacspeak.

;;; Code:

;;}}}
;;{{{ Required Modules

(eval-when-compile (require 'cl))
(declaim  (optimize  (safety 0) (speed 3)))
(require 'custom)
(eval-when (compile)
  (require 'emacspeak-preamble))

;;}}}
;;{{{  Define locations

;;;###autoload
(defvar emacspeak-directory
  (expand-file-name "../" (file-name-directory load-file-name))
  "Directory where emacspeak is installed. ")
;;;###autoload
(defvar emacspeak-lisp-directory
  (expand-file-name  "lisp/" emacspeak-directory)
  "Directory where emacspeak lisp files are  installed. ")
;;;###autoload
(defvar emacspeak-sounds-directory
  (expand-file-name  "sounds/" emacspeak-directory)
  "Directory containing auditory icons for Emacspeak.")
;;;###autoload
(defvar emacspeak-xslt-directory
  (expand-file-name "xsl/" emacspeak-directory)
  "Directory holding XSL transformations.")

;;;###autoload
(defvar emacspeak-etc-directory
  (expand-file-name  "etc/" emacspeak-directory)
  "Directory containing miscellaneous files  for
  Emacspeak.")
;;;###autoload
(defvar emacspeak-servers-directory
  (expand-file-name  "servers/" emacspeak-directory)
  "Directory containing speech servers  for
  Emacspeak.")
;;;###autoload
(defvar emacspeak-info-directory
  (expand-file-name  "info/" emacspeak-directory)
  "Directory containing  Emacspeak info files.")
;;;###autoload
(defvar emacspeak-resource-directory (expand-file-name "~/.emacspeak/")
  "Directory where Emacspeak resource files such as
pronunciation dictionaries are stored. ")
;;;###autoload
(defvar emacspeak-readme-file
  (expand-file-name "README"
                    emacspeak-directory)
  "README file from where we get SVN revision number.")

;;;###autoload
(defconst emacspeak-codename
  "NiceDog"
  "Code name of present release.")

;;;###autoload
(defconst emacspeak-version
  (format
   "41.0 %s:  %s"
   emacspeak-codename
   (cond
    ((file-exists-p emacspeak-readme-file)
     (let ((buffer (find-file-noselect emacspeak-readme-file))
           (revision nil))
       (save-current-buffer
         (set-buffer buffer)
         (goto-char (point-min))
         (setq revision
               (format "Revision %s"
                       (or
                        (nth 2 (split-string
                                (buffer-substring-no-properties
                                 (line-beginning-position)
                                 (line-end-position))))
                        "unknown"))))
       (kill-buffer buffer)
       revision))
    (t "")))
  "Version number for Emacspeak.")

;;}}}
;;{{{ speech rate

;;;###autoload
(defcustom outloud-default-speech-rate 50
  "Default speech rate for outloud."
  :group 'tts
  :type 'integer)

;;;###autoload
(defcustom mac-default-speech-rate 225
  "Default speech rate for mac."
  :group 'tts
  :type 'integer)

;;;###autoload
(defcustom multispeech-default-speech-rate 225
  "Default speech rate for multispeech."
  :group 'tts
  :type 'integer)
;;;###autoload
(defcustom dectalk-default-speech-rate 225
  "*Default speech rate at which TTS is started. "
  :group 'tts
  :type 'integer)
;;;###autoload
(defcustom espeak-default-speech-rate 175
  "Default speech rate for eSpeak."
  :group 'tts
  :type 'integer)

;;}}}
;;{{{ Hooks

(add-to-list 'load-path emacspeak-lisp-directory )
(add-to-list 'load-path (expand-file-name "g-client" emacspeak-lisp-directory ))

(load-library "emacspeak")

(defvar dtk-startup-hook nil)
;;;###autoload
(defun emacspeak-tts-startup-hook ()
  "Default hook function run after TTS is started."
  (declare (special tts-default-speech-rate))
  (tts-configure-synthesis-setup)
  (dtk-set-rate tts-default-speech-rate t)
  (dtk-interp-sync))

(add-hook 'dtk-startup-hook 'emacspeak-tts-startup-hook)

(defvar emacspeak-startup-hook nil)
(defun emacspeak-setup-header-line ()
  "Set up Emacspeak to show a default header line."
  (declare (special emacspeak-use-header-line
                    header-line-format
                    emacspeak-header-line-format))
  (when emacspeak-use-header-line
    (setq header-line-format
          emacspeak-header-line-format)))

(defun emacspeak-tvr-startup-hook ()
  "Emacspeak startup hook that I use."
  (load-library "emacspeak-alsaplayer")
  (load-library "emacspeak-webspace")
  (load-library "emacspeak-dbus"))

(add-hook 'emacspeak-startup-hook 'emacspeak-setup-header-line)
(add-hook 'emacspeak-startup-hook 'emacspeak-tvr-startup-hook)

;;}}}
(emacspeak)
(provide 'emacspeak-setup)
;;{{{  emacs local variables

;;; local variables:
;;; major-mode: emacs-lisp-mode
;;; folded-file: t
;;; end:

;;}}}

################################## espeak
#!/usr/bin/tclsh
# Keywords: Emacspeak, eSpeak , TCL
# {{{ LCD Entry:

# LCD Archive Entry:
# emacspeak| T. V. Raman |raman@xxxxxxxxxxx
# A speech interface to Emacs |
# $Date: 2006-08-11 21:11:17 +0200 (ven, 11 aoű 2006) $ |
#  $Revision: 4047 $ |
# Location undetermined
#

# }}}
# {{{ Copyright:
#Copyright (C) 1995 -- 2001, T. V. Raman
#All Rights Reserved
#
# This file is not part of GNU Emacs, but the same permissions apply.
#
# GNU Emacs is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# GNU Emacs is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Emacs; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

# }}}
# {{{source common code

package require Tclx
set wd [file dirname $argv0]
source $wd/tts-lib.tcl

# }}}

# {{{ procedures

# Language switching
#
# langsynth: available languages of the voice synthesis
# This variable is set by atcleci
# For example: langsynth(0)=3
# 3 is the atcleci code for the finnish language

# langsynth(current): current synthesis language,
# Gives the code of the current synth language.
# This variable is set by the application
# For example: langsynth(current)=3
# means finnish is the current language

# langsynth(top): max available index.
# For example, if there are three available languages:
# langsynth(top)=2

# langlabel: what will be announced
# e.g. langlabel(0)="finnish"
# This variable is set by tclespeak

# langcode: language identifier
# e.g. langcode(0)="fi"
# This variable is set by tclespeak

# langalias converts a code language ("en", "en_GB",...) to its index
in the langsynth array.
# e.g. langalias(fi)=3 could mean "fi_FI" will be used if "fi" is required.

set langsynth(0) 0
set langsynth(current) 0
set langsynth(top) 0
set langlabel(0) "english"
set langcode(0) "en-uk"
set langcode(current) "en-uk"
set mswindows [expr { $tcl_platform(platform) == "windows" } ]

# select the next synth language
proc set_next_lang {say_it} {
    global langsynth
    global langalias
    global langlabel
    global langcode

    set langsynthkey 0
    set index 0
    while { $index <= $langsynth(top) } {
    if { $langsynth($index) == $langsynth(current) } {
        set langsynthkey $index
        break
    }
    incr index
    }

    if { $langsynthkey >= $langsynth(top) } {
    set langsynthkey 0
    } else {
    incr langsynthkey
    }

    set langsynth(current) $langsynth($langsynthkey)
    set langcode(current) $langcode($langsynthkey)

    setLanguage $langsynth(current)
    if { [info exists say_it]} {
    tts_say "$langlabel($langsynthkey) "
    }
}

# select the previous synth language
proc set_previous_lang {say_it} {
    global langsynth
    global langalias
    global langlabel
    global langcode

    set langsynthkey 0
    set index 0
    while { $index <= $langsynth(top) } {
    if { $langsynth($index) == $langsynth(current) } {
        set langsynthkey $index
        break
    }
    incr index
    }

    if { $langsynthkey <= 0 } {
    set langsynthkey $langsynth(top)
    } else {
    incr langsynthkey -1
    }

    set langsynth(current) $langsynth($langsynthkey)
    set langcode(current) $langcode($langsynthkey)
    setLanguage $langsynth(current)
    if { [info exists say_it]} {
    tts_say "$langlabel($langsynthkey) "
    }
}

# select a new synth language
# set_lang "en"
proc set_lang {{name "en"} {say_it "nil"}} {
    global langsynth
    global langalias
    global langcode
global langlabel
     if { ![info exists langalias($name)]} {
    return
     }

     if { $langalias($name) == $langsynth(current) } {
    return
     }

    set langsynth(current) $langalias($name)
    set langcode(current) $langcode($langsynthkey)
    setLanguage $langsynth(current)

    set langsynthkey 0
    set index 0
    while { $index <= $langsynth(top) } {
    if { $langsynth($index) == $langsynth(current) } {
        set langsynthkey $index
        break
    }
    incr index
    }

    if { $say_it == "t"} {
    tts_say "$langlabel($langsynthkey) "
    }
}

# set_preferred_lang "en" "en_GB"
proc set_preferred_lang {alias lang} {
    global langsynth
    global langalias

    if { ![info exists langalias($lang)]} {
    return
    }
    set langalias($alias) $langalias($lang)
}

#debug
proc list_lang {} {
    global langsynth
    echo [ array get langsynth ]
}

proc list_langalias {} {
    global langalias
    echo [ array get langalias ]
}


proc version {} {

    SHOW "proc version"

    q " eSpeak [ttsVersion]"
    d
}

proc tts_set_punctuations {mode} {
    global tts

    set tts(punctuations) $mode
    punct $mode
    service
    return ""
}

proc tts_set_speech_rate {rate} {
    global tts

    set factor $tts(char_factor)
    set tts(speech_rate) $rate
    setRate 0 $rate
    service
    return ""
}

proc tts_set_character_scale {factor} {
    global tts

    set tts(say_rate) [round \
                           [expr $tts(speech_rate) * $factor ]]
    set tts(char_factor) $factor
    service
    return ""
}

proc tts_say {text} {
    global    tts
    global langcode
    global langsynth

    service
    set la $langcode(current)

    set prefix "<voice xml:lang=\"$la\" gender=\"male\" variant=\"1\">"
    regsub -all {\[\*\]} $text { } text
    synth " $prefix $text"
    service
    return ""
}

proc l {text} {
    global tts
    global langcode
    global langsynth

    set la $langcode(current)
    set prefix "<voice xml:lang=\"$la\" gender=\"male\" variant=\"1\">"
    if {[regexp  {[A-Z]} $text]} {
    # pitch instead of 80%, high which could be 75%.
        set prefix "$prefix <prosody pitch=\"high\">"
    }
    set tts(not_stopped) 1
    # TBD: say-as, format attribute: instead of characters/glyphs, define "word"
    synth "$prefix <say-as interpret-as=\"characters\"
format=\"characters\">$text"
    service
    return ""
}

proc d {} {
    service
    speech_task
}

proc tts_resume  {} {
    resume
    return ""
}
proc tts_pause {} {
    pause
    return ""
}

proc s {} {
    global tts


    if {$tts(not_stopped) == 1} {


        set tts(not_stopped) 0
        stop
        queue_clear
    } else {
        puts stderr StopNoOp
    }
}



proc t  {{pitch 440} {duration 50}} {
    global tts queue
    if {$tts(beep)} {
        b $pitch $duration
        return ""
    }
    service
}

proc sh  {{duration 50}} {
    global tts queue


    set silence "<break time=\"$duration ms\"/>"
    set queue($tts(q_tail)) [list t $silence]
    incr tts(q_tail)
    service
    return ""
}

# Caps: this driver currently offers either
# - announcing each capitals (tts_split_caps)
# - or highering pitch (tts_capitalize)
# - or beeping (tts_allcaps_beep)
#
proc tts_split_caps {flag} {
    global tts

    set tts(split_caps) $flag
    if { $flag == 1 } {
    set tts(allcaps_beep) 0
    set tts(capitalize) 0
    caps "spelling"
    } else {
    if { ( $tts(capitalize) == 0 ) && ( $tts(allcaps_beep) == 0 ) } {
        caps "none"
    }
    }
    service
    return ""
}

proc tts_capitalize {flag} {
    global tts

    set tts(capitalize) $flag

    if { $flag == 1 } {
    set tts(split_caps) 0
    set tts(allcaps_beep) 0
    caps "pitch"
    } else {
    if { ( $tts(split_caps) == 0 ) && ( $tts(allcaps_beep) == 0 ) } {
        caps "none"
    }
    }

    service
    return ""
}

proc tts_allcaps_beep {flag} {
    global tts

    set tts(allcaps_beep) $flag

    if { $flag == 1 } {
    set tts(split_caps) 0
    set tts(capitalize) 0
    caps "tone"
    } else {
    if { ( $tts(split_caps) == 0 ) && ( $tts(capitalize) == 0 ) } {
        caps "none"
    }
    }
    service
    return ""
}

proc tts_reset {} {
    global tts
    #synth  -reset

    queue_clear
    synth "Resetting engine to factory defaults."
}

proc r {rate} {
    global queue  tts

    set queue($tts(q_tail)) [list r  $rate]
    incr tts(q_tail)
    return ""
}

proc useStereoOutput {} {
    global tts


    setOutput buffer
}

# }}}
# {{{ speech task

proc trackIndex {index} {
    global tts

    set tts(last_index) $index
}

proc stdin_readable_handler {} {
  global stdin_is_readable
  global timer_or_stdin_breaks
  set stdin_is_readable 1
  set timer_or_stdin_breaks 1
}
if $mswindows { fileevent stdin readable stdin_readable_handler }

proc timer_handler {} {
  global timer_ticks
  global timer_or_stdin_breaks
  after 200 timer_handler
  set timer_ticks 1
  incr timer_or_stdin_breaks
}
if $mswindows { after 0 timer_handler }

proc service {} {
    global tts
    global stdin_is_readable # used only by mswindows

    set talking [speakingP]
    set stdin_is_readable 0
    while {$talking == 1} {
        if $::mswindows {
            # need to workaround lack of "select stdin" on windows
            # set status to 1 if input is available at stdin
            # if input is not available, timer will cause an exit from vwait
            set status -1
            vwait timer_or_stdin_breaks
            if { $stdin_is_readable > 0 } {
                set status 1
            }
        } else {
            set status   [lsearch [select [list  stdin]  {} {} 0.02] stdin]
        }

        if { $status >= 0} {
            set tts(talking?) 0
            set talking 0
            break
        } else {
            set talking [speakingP]
        }
    }
    return $talking
}

proc speech_task {} {
    global queue tts
    global langcode
    global langsynth

    set tts(talking?) 1
    set tts(not_stopped) 1
    set length [queue_length]
    set la $langcode(current)

    #set prefix "<voice xml:lang=\"$la\" gender=\"male\"
    #variant=\"1\">"
    set prefix ""
    loop index 0 $length {

        set event   [queue_remove]
        set event_type [lindex $event 0]
        switch  -exact -- $event_type {
            s {

                set text [clean [lindex $event 1]]
                synth " $prefix $text"
                set retval [service]
            }
            c {
                set text  [lindex $event 1]
                synth "$text"
                set retval ""
            }
            a {

                set sound [lindex $event 1]
                exec $tts(play) $sound >/dev/null   &
            }
            b {

                if {$tts(beep)} {
                    lvarpop event
                    eval beep $event
                }
            }
            r {

# The first argument to setRate is ignored.
                setRate 0 [lindex  $event 1]
            }
        }
        if {$tts(talking?) == 0} {break;}
    }


    set tts(talking?) 0
    service
    return ""
}

# }}}
# {{{clean

#preprocess element before sending it out:
proc clean {element} {
    global queue tts


# The text conversion is expected to be done by eSpeak.
# For example, the * symbol will be said according to the selected language.
#
# If relying on eSpeak is too optimitisc for text conversion, you may
# perhaps propose to the eSpeak author a new feature.
#
    return $element
}

# }}}
# {{{ Initialize and set state.

#do not die if you see a control-c
signal ignore {sigint}

# Set input encoding to utf-8
fconfigure stdin -encoding utf-8

#initialize eSpeak
tts_initialize
set tts(speech_rate)  225
beep_initialize
set tts(input) stdin
if {[info exists server_p]} {
    set tts(input) sock0
}
load /usr/lib/emacspeak/tclespeak.so
if {[file exists /proc/asound]} {
    set tts(play) /usr/bin/aplay
}
synth {<voice xml:lang="en" variant="1">eSpeak.}

service

#Start the main command loop:

if $mswindows {
  # there is a bug on windows, interactive -on does not work
  # https://sourceforge.net/p/tclx/bugs/81/
  commandloop -interactive off
} else {
  commandloop
}

# }}}
# {{{ Emacs local variables

### Local variables:
### major-mode: tcl-mode
### voice-lock-mode: t
### folded-file: t
### End:

# }}}



|May 1995 - Last Year |Current Year|


If you have questions about this archive or had problems using it, please contact us.

Contact Info Page