  The Linux Text-To-Speech mini-HOWTO
  Author: Rhandeev Singh rhandeev@comp.nus.edu.sg
  <mailto:rhandeev@comp.nus.edu.sg>
  Version 0.02, Last update: 99/05/14
  Hideki Shirafuji, shirafuji@mail.com <mailto:shira-
  fuji@mail.com>
  Version 0.02 : 2000/08/03

  ̕ł RedHat 6.0 ̃VXe Festival  MBROLA găeLX
  gǂݏグuݒ肷@Ă܂B
  <http://leb.net/pub/blinux/doc/blinux/my-tts-linux.txt>ɂ܂B
  ______________________________________________________________________

  ڎ

  1. Cg_NV
  2. \tgEFA̓
  3. CXg[
  4. ݒƃeXg
     4.1 {ݒ
     4.2 X^C̃T|[g
     4.3 XNvg̒ŉ̎ς
     4.4 o͑ȗI
     4.5 K[x[W RNV bZ[W̉
     4.6 ƍv

  5. t^
     5.1 A.1.  /usr/lib/festival/lib/siteinit.scm p̃ev[g
     5.2 A.2.  /etc/festival.conf p̃ev[g
     5.3 A.3.  X^C̃T|[gǉXNvg

  ______________________________________________________________________

  1.  Cg_NV

  ́̕Ao͂ł Linux VXeŁAp\tgEFAɗ
  ɂ낢ȃhLgǂݏグ悤ɂ邽߁A
  ̂łB낢ȃt[̃eLXgǂݏグiTTSjVXe
  Ă݂܂A܂Œł MBROLA  Festival ̑gݍ킹
  ԗǂłB

  ܂AXs[hsb`i̍j̐ݒύXł悤ɂ̂X
  L[t@C [ : festival ̓𐧌䂷p̃XNvgt@C
  igq scmj ] ƕςAlynx ܂܂ȃtH[}bg
  ihtml, text, postscriptjǂݏグ悤ɋ@\ǉ܂B

  2.  \tgEFA̓

  Ă鎞_ł́ABlind Linux Archive ̓~[TCg
  Kvȃ\tgł܂BƂ

          ftp://leb.net/blinux/festival/cstr.mirror/Linux-1.3.1/redhat/RPMS/i386/glibc2
          ftp://leb.net/blinux/mbrola/blinux/RPMS/

  Ƃ rpmfind.net ł́F

          http://rpmfind.net/linux/RPM/Utilities_Speech.html
          http://rpmfind.net/linux/RPM/Utilities_Sound.html

  Ə񂪕KvȂ Blind Linux z[y[W ĂF

          http://leb.net/blinux/index.html

  i386 p Red Hat 6.0 ł́Aȉ RPM Kvł傤F

          festival-1.3.1-2.i386.rpm
          festlex_POSLEX-1.3.1-1.noarch.rpm
          festvox_en1-1.3.1-1.noarch.rpm
          speech_tools-libs-1.1.1-2.i386.rpm
          festlex_OALD-1.3.1-1.noarch.rpm         # for british english
          festlex_CMU-1.3.1-1.noarch.rpm          # for american english

  ܂ mbrola ƁAf[^x[XȂƂЂƂIԕKv܂B
  iueBbVECObVԐݒ肪ȒPłjF

          mbrola-3.01g1-1.i386.rpm
          mbrola-en1-2.0-1.i386.rpm               # british english
          mbrola-us1-980512-1.i386.rpm            # american (male)
          mbrola-us2-980812-1.i386.rpm            # american (female)

  ^[{[Kvȏꍇ Festival project ĂF

          http://www.cstr.ed.ac.uk/projects/festival.html

   MBROLA project ֍sĂF

          http://tcts.fpms.ac.be/synthesis/mbrola.html

  3.  CXg[

  ł́AȂ Linux ̃TEhEn[hEFA͂łɐݒ肵Ă
  ̂Ƃ܂Bݒ肵ĂȂꍇ́Athe Linux Sound-HOWTO Ă
  BɁA /dev/dsp mɓ삵ĂKv܂B

  RedHat RPMs ̃CXg[͂ƂĂȒPłF

          bash$ rpm -Uhv fest* mbrola*

  ɃueBbVECObVp̃V{bNN͂܂F

          cd /usr/lib/festival/lib/voices/english/rab_mbrola
          ln -s /usr/lib/mbrola/en1/en1
          ln -s /usr/lib/mbrola/en1/en1mrpa

  [: RedHat 6.1 p RPM ł
          cd /usr/share/festival/lib/voices/english/en1_mbrola/
          mkdir en1
          cd en1
          ln -s /usr/lib/mbrola/en1/en1
  ]

  ꂩAL "en1" ꂼ̃f[^x[XɒuāAMBROLA 
  ق diphone f[^x[XCXg[邱Ƃł܂G
  A͂ǂĂ݂Ƃ܂AɁA܂ Festival 
  ̌b悤ɐݒ肷Kvł傤B̕Ă
  _ŁAtX AhCcAXyCÂق̌
  MBROLA diphone f[^x[Xp\łBBlind Linux z[y[W
  ĂB

  4.  ݒƃeXg

  4.1.  {ݒ

  /usr/lib/festival/lib/voices.scm ɂPsǉ܂F

  [ : RedHat 6.1 p RPM ł /usr/lib/festival/ 
  /usr/share/festival/ Ɠǂݑւ ]

          (defvar default-voice-priority-list
            '(rab_mbrola                     ; <= ̍sǉ
              rab_diphone                    ; i
              ked_diphone                    ;  Z~R͂܂j

  Ăł܂B Festival ͍ŏ MBROLA gƂ܂B

  ̂悤 festival 𑖂点ƁAݒeXgł܂F

          bash$ festival
          festival> (SayText "Type any text here.  Sounds cool?")
          festival> (quit)

  낢ȃt@C`AƂ HTML Ɓuǂ݂₷v邽
  ɁAt@CO悤 Festival ݒł܂Bǂ̂悤ɐݒ
  邩 /usr/doc/festdoc-1.2.0/festival/festival.info ɂ festival
  ̃hLgĂB "Text modes" ̃ZNVɏĂ
  B

  ł́AɃeLXgOAÂǂ sed XNvg
  Ƃ܂B

  t@Cw肵 festival eLXgǂݏグ[hő点邱Ƃ
  ܂F

          festival --tts <filename>

  ܂̓Xg[邱Ƃł܂F

          lynx -dump <URL> | tee /tmp/x | festival --tts & sleep 1; less /tmp/x

  ŖłāAɂĂȂAł߂Ă܂܂B
  AƍHvĝŋΐւǂ :)

  4.2.  X^C̃T|[g

  ̃ZNVł́Asb`b̒߂ǂČ߁AI邩
  qׂ܂B

  uX^Cv̂ɕKvȍ\`邽߂ɁAt^ A.1 
  eLXg /usr/lib/festival/lib/siteinit.scm ƂO̐VKt@C
  ɕۑĂBVXeSʂ̃X^C`邽߂ɁAt^ A.2
   /etc/festival.conf ɕۑĂB

  ɁAȉ̂Ps /usr/lib/festival/lib/init.scm ̏I̕ɑ}
  ܂F

          ;;; Default voice (have to do something cute
          ;;; so autoloads still work)
          (eval (list voice_default))
          (Style style_default)           ; <= ̍sǉ
          (provide 'init)

  ̂悤 $HOME/.festivalrc ɒǉƁAftHgȊOɃ[U[
  `́uX^Cvwł܂F

          ;; [U[`X^C
          (NewStyle 'my_slow      100 24 1.0) ; 肵og̐
          (NewStyle 'my_fast      140 50 0.8) ; ei[̐

          (set! style_default 'my_slow)       ; ftHg̃X^C

  ŏ̐̓sb`iHzjӖ܂BQԖڂ̐̓sb`̕W΍
  iƂUHjŁARԖڂ̐̓XP[vfŁAقǑ
  Ȃ܂B

  4.3.  XNvg̒ŉ̎ς

  festival XNvgob`[hŎgĂꍇÁ݂uX^C
  vXNvg̒łȂӂɕς邱Ƃł܂F

          (Style 'male_faster)

  ƂΕt^ A.3 ̃XNvgĂB̃XNvg festival
  ̃eLXgǂݏグ̃R}hCEC^[tFCXɁAX^CI
  T|[gǉ܂BύXĂق̋@\ǉA
  ЎɋĂI

  4.4.  o͑ȗI

  lɂẮAMP3 TEhEn[hEFAŒȂ瓯 festival
  g悤 NCD ̃lbg[NVXeiNASjgƂIԂ
  傤B

  ̂߂ɂ́Aȉ̍s /etc/festival.conf ɑ}ĂF

          ;;; ===================
          ;;; Audio Output Method
          ;;; ===================

          (Parameter.set 'Audio_Method 'Audio_Command)
          (Parameter.set 'Audio_Required_Rate 16000)
          (Parameter.set 'Audio_Required_Format 'snd)
          (Parameter.set 'Audio_Command "/usr/X11R6/bin/auplay -volume 100 $FILE")

  4.5.  K[x[W RNV bZ[W̉

  ΘbIȐݒgAEFbuEy[W lynx ɓǂݏグĂ悤
  ꍇilynx.cfg ̒Ŏwł܂j́AK[x[W RNV bZ
  [W̉ƕ֗łB

  K[x[W RNV bZ[W̉ɂ́A/etc/festival.conf
   $USER/.festivalrc ̂ǂ炩Ɉȉ̍sǉ܂F

          (gc-status nil)

  4.6.  ƍv

   festival 𓮂Ƃɖ肪A mini-HOWTO ɉv
  ł邱Ƃ΁A̒̕҂ɐڐGĂ܂܂F

   Rhandeev Singh                   http://www.comp.nus.edu.sg/~rhandeev
   Linux User Group                 http://linux.comp.nus.edu.sg
   National University of Singapore

  5.  t^

  5.1.  A.1.  /usr/lib/festival/lib/siteinit.scm p̃ev[g

  ixFScheme code ܂GKv͂܂j

          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          ;;;  Site Initialisation file
          ;;;  This is loaded near the end of init.scm,
          ;;;  just before user initialisation file
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

          ;;; ==========================
          ;;; Style Management Functions
          ;;; ==========================

          (defvar Styles '((default 140 22 1.0))
            "Available voice styles")

          (defvar style_default 'default
            "Default voice style")

          (defvar current_style 'none
            "Current voice style")

          (define (Style selected_style)
            "(Style DEFINED_STYLE)
             Sets the pitch, pitch variance, and speed of the current voice.
             Type 'Styles' for a list of defined styles."
            (let ((style (assoc selected_style Styles)))
              (if (not style)
                  (set! style (assoc 'default Styles)))
              (let ((model_mean (cadr (assoc 'model_f0_mean  int_lr_params)))
                    (model_std  (cadr (assoc 'model_f0_std   int_lr_params)))
                    (new_mean (cadr style))
                    (new_std (cadr (cdr style)))
                    (new_stretch (cadr (cdr (cdr style)))))
                (set! int_lr_params
                      (list
                       (list 'target_f0_mean new_mean)
                       (list 'target_f0_std  new_std)
                       (list 'model_f0_mean  model_mean)
                       (list 'model_f0_std   model_std)))
                (Parameter.set 'Duration_Stretch new_stretch)
                (set! current_style (car style))
                (list (car style) new_mean new_std new_stretch)
                )
              )
            )

          (define (NewStyle style_name mean std stretch)
            "(NewStyle STYLE_NAME MEAN STD STRETCH)
             Defines a new style; MEAN and STD refer to pitch mean and variance,
             while STRETCH refers to inverse speed, 1.0 being the standard."
            (set! Styles (cons (list style_name mean std stretch) Styles)))

          (if (probe_file "/etc/festival.conf")
              (load "/etc/festival.conf"))

  5.2.  A.2.  /etc/festival.conf p̃ev[g

          ;;; =================
          ;;; Style Definitions
          ;;; =================

          (NewStyle 'male_frozen      80 10 1.5 )
          (NewStyle 'male_slow       100 22 1.1 )
          (NewStyle 'male_tenor      140 60 1.0 )
          (NewStyle 'male_baritone   100 40 1.0 )
          (NewStyle 'male_bass        70 25 1.0 )
          (NewStyle 'male_relaxed    100 24 0.95)
          (NewStyle 'male_newscaster 140 32 0.85)
          (NewStyle 'male_hurried    117 22 0.80)
          (NewStyle 'male_stressed   150 30 0.70)
          (NewStyle 'male_fast       110 22 0.70)
          (NewStyle 'male_faster     110 22 0.60)
          (NewStyle 'male_panic      170 20 0.60)
          (NewStyle 'male_fastest    110 22 0.55)
          (NewStyle 'the_flash       110 22 0.45)

  5.3.  A.3.  X^C̃T|[gǉXNvg

   festival ̃eLXgǂݏグ̃C^[tFCXɐ́uX^C
  ṽT|[gǉXNvgłBق̋@\ǉ邽߂̃e
  v[gƂĂg܂Bǉ為ЋĂB

  XNvg saytext ƂāAȒPɎgĂ܂
  B

          saytext -h              # iȂ߂jwvbZ[Wł܂

          saytext [-s <X^C>] [<t@C>]  # t@C͕W͂ǂݏグ܂

  <X^C>́Â݂Ȃ牽ł܂܂B<t@C >w
  Ȃꍇ́AW͂g܂B

                saytext -s male_baritone myfile.txt

  ĂꂪXNvg̃R[hłF

          #!/usr/lib/festival/src/main/festival --script
          ;;;  Here is a Festival script that adds voice "style"
          ;;;  support to the text-to-speech command-line interface.
          ;;;
          ;;;  Type "saytext -h" for help, including a list of available styles.
          ;;;
          ;;;  User-defined "styles" can be declared in ~/.festivalrc like this:
          ;;;
          ;;;             (NewStyle <name> <mean_pitch> <pitch_SD> <speed>)
          ;;;  E.g:       (NewStyle 'mystyle 100 23 0.9)   ; Defines a baritone
          ;;;
          ;;;  You can also set default styles:
          ;;;
          ;;;             (set! style_default 'my_style)
          ;;;
          ;;;  Styles may be selected within a script via:
          ;;;
          ;;;             (Style <name>)
          ;;;  E.g.:      (Style 'my_style)

          ;;; ==============
          ;;; INITIALIZATION
          ;;; ==============

          ;;; Because this is a --script type file I have to explicitly
          ;;; load the initfiles: init.scm and user's .festivalrc
          (load (string-append libdir "init.scm"))

          (if (probe_file (format nil "%s/.festivalrc" (getenv "HOME")))
              (load (format nil "%s/.festivalrc" (getenv "HOME"))))

          ;;; Clear rotten rendered speech from tmp
          (system "/bin/rm -f /tmp/est_*")

          ;;; Process command-line arguments

          (defvar TTS_Filename "-"
            "This variable stores the name of the file to be read,
            \"\" for stdin")

          (while argv
                 (let ((option (car argv)))
                   (set! argv (cdr argv))
                   (cond

                    ((eq? option '-s)
                     (if (length argv)
                         (let ((style (car argv)))
                           (if (not (assoc style Styles))
                               (format t "No style '%s, " style))
                           (Style style)
                           ; (format t "Using style %s\n" current_style)
                           (set! argv (cdr argv))
                           )
                         (error "Syntax error in option: -s <style>" nil)))

                    ((eq? option '-h)
                     (format t "Usage: saytext [-s <style> | -h]\n")
                     (format t "Available styles are:\n")
                     (format t " %l\n" Styles)
                     (quit))

                    (t
                     (set! TTS_Filename (string-append "" option))))))

          (tts TTS_Filename nil)

