home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Programming / amigatalk / system / Narrator.st < prev    next >
Encoding:
Text File  |  2001-02-28  |  4.5 KB  |  150 lines

  1. " ----------------------------------------------------------------------"
  2. " Narrator Class is derived from abstract Device Class.                 "
  3.  
  4. "  WARNING:  You should know what you're doing to the Amiga OS before   "
  5. "            messing with this Class, or any other System Class!        " 
  6.  
  7. " This class is a Singleton Class, meaning there can be only one 
  8.   narrator per AmigaTalk program (what would more than one narrator
  9.   talking at the same time sound like, anyway?)
  10. "
  11. " ----------------------------------------------------------------------"
  12.  
  13. Class Narrator :Device ! uniqueInstance !
  14. [
  15.   close
  16.       <primitive 230 0>
  17. |
  18.   privateOpen
  19.       "Use new method instead."
  20.       ^ <primitive 230 1>
  21. |
  22.   setVolume: newSpeakingVolume
  23.       "Range:  0 to 64 (max)"
  24.       ^ <primitive 230 2 newSpeakingVolume>
  25.   setSex: newSpeakerSex
  26.       "Female = 0, & Male = 1"
  27.       ^ <primitive 230 3 newSpeakerSex>
  28.   setPitch: newSpeakingPitch
  29.       "Range:  65 to 320Hz"
  30.       ^ <primitive 230 4 newSpeakingPitch>
  31. |
  32.   setMode: newModeString
  33.       "valid string settings are: robotic, natural & manual"
  34.       ^ <primitive 230 5 newModeString>
  35. |
  36.   setRate: newSpeakingRate
  37.       "Range: 40 to 400 words/minute"
  38.       ^ <primitive 230 6 newSpeakingRate>
  39. |
  40.   setFormant1: percentDeviation 
  41.       "Range: -100 to 100 in steps of 5, Default = 0"
  42.       ^ <primitive 230 7 1 percentDeviation>
  43. |
  44.   setFormant2: percentDeviation 
  45.       "Range: -100 to 100 in steps of 5, Default = 0"
  46.       ^ <primitive 230 7 2 percentDeviation>
  47. |
  48.   setFormant3: percentDeviation 
  49.       "Range: -100 to 100 in steps of 5, Default = 0"
  50.       ^ <primitive 230 7 3 percentDeviation>
  51.   setFormant1Amplitude: newAmplitude
  52.       "RANGE: 31 to -32 dB."
  53.       ^ <primitive 230 8 1 newAmplitude>
  54.   setFormant2Amplitude: newAmplitude
  55.       "RANGE: 31 to -32 dB."
  56.       ^ <primitive 230 8 2 newAmplitude>
  57.   setFormant3Amplitude: newAmplitude
  58.       "RANGE: 31 to -32 dB."
  59.       ^ <primitive 230 8 3 newAmplitude>
  60. |
  61.   setEnthusiasm: aFloat
  62.       "From 1/32 to 32/32 only (32/32 = default)"
  63.       ^ <primitive 230 9 aFloat>
  64. |
  65.   setPriority: newSpeakingPriority
  66.       "Range: -128 to 127, Default = 100"
  67.       ^ <primitive 230 10 newSpeakingPriority>
  68.   setPitchModulation: voiceQuiver
  69.       "Range: 0 to 255"
  70.       ^ <primitive 230 11 voiceQuiver>
  71.   setArticulation: newPercentArticulation
  72.       "Set amount of slurring of words.  Range:  0 to 255% (max)"
  73.       ^ <primitive 230 12 newPercentArticulation>
  74.   setPhoneme: phonemeString
  75.       "Used with setCentralizeValue: to change the accent of Narrator."
  76.  
  77.       "Valid strings are:"
  78.       
  79.       "IY  long  e as in beet,   eat.
  80.        IH  short i as in bit,    in.
  81.        EH  short e as in bet,    end.
  82.        AE  short a as in bat,    ad.
  83.        AA  short o as in bottle, on.
  84.        AH  short u as in but,    up.
  85.        AO  short a as in ball,   awl.
  86.        OW  long  o as in boat,   own.     (diphthong)
  87.        UH  short u as in book,   soot.
  88.        ER  short i as in bird,   early.
  89.        UW  long  u as in brew,   boolean. (diphthong)"
  90.  
  91.       "No checking is performed on your string, so get it right!" 
  92.  
  93.       ^ <primitive 230 13 phonemeString>
  94.   setCentralizeValue: newCentralizePercent
  95.       "Used with setPhoneme: to change the accent of Narrator."
  96.       "Range: 0 to 100%"
  97.       ^ <primitive 230 14 newCentralizePercent>
  98.   setFlags: newFlags 
  99.       "NDF_NEWIORB = 1, NDF_WORDSYNC = 2, NDF_SYLSYNC = 4"
  100.       ^ <primitive 230 15 newFlags>
  101.   setVoicingAmplitude: newAVBias  
  102.       "RANGE: 31 to -32 dB."
  103.       ^ <primitive 230 16 newAVBias>
  104.   setFricationAmplitude: newAFBias 
  105.       "RANGE: 31 to -32 dB."
  106.       ^ <primitive 230 17 newAFBias>
  107.   speak: normalString
  108.       ^ <primitive 230 18 normalString>
  109.   speakPhonetics: phoneticString
  110.       ^ <primitive 230 19 phoneticString>
  111.   translateText: aString
  112.       "Returns a Phonetic string representation of aString"
  113.       ^ <primitive 230 20 aString>
  114. |
  115.   new: aValue
  116.       'Cannot use new: method on Narrator class!' print.
  117.       ^ nil
  118. |
  119.   privateSetup ! check !
  120.       (uniqueInstance isNil)
  121.          ifTrue: [ check <- (self privateOpen).
  122.                    (check = 0)
  123.                       ifTrue:  [ uniqueInstance <- 'MyNarrator'.
  124.                                  ^ self
  125.                                ]
  126.                       ifFalse: [ 'Problem opening Narrator:' print.
  127.                                  <primitive 230 21 check> print.
  128.                                  ^ uniqueInstance <- nil
  129.                                ] 
  130.                  ]
  131. |
  132.   new 
  133.       ^ (self privateSetup)
  134. ]
  135.