home *** CD-ROM | disk | FTP | other *** search
/ CLIX - Fazer Clix Custa Nix / CLIX-CD.cdr / mac / lib / Mac / Speech.pm < prev    next >
Text File  |  1998-04-17  |  4KB  |  192 lines

  1. =head1 NAME
  2.  
  3. Mac::Speech - Provide interface to PlainTalk (Speech Manager)
  4.  
  5. =head1 SYNOPSIS
  6.  
  7.     use Mac::Speech;
  8.  
  9. =head1 DESCRIPTION
  10.  
  11. Access to Inside Macintosh is essential for proper use of these functions.
  12. Explanations of terms, processes and procedures are provided there.
  13. Any attempt to use these functions without guidance can cause severe errors in 
  14. your machine, including corruption of data. B<You have been warned.>
  15.  
  16. =cut
  17.  
  18. use strict;
  19.  
  20. package Mac::Speech;
  21.  
  22. BEGIN {
  23.     use Exporter   ();
  24.     use DynaLoader ();
  25.     
  26.     use vars qw(@ISA @EXPORT %Voice);
  27.     
  28.     @ISA = qw(Exporter DynaLoader);
  29.     @EXPORT = qw(
  30.         SpeechManagerVersion
  31.         CountVoices
  32.         GetIndVoice
  33.         GetVoiceDescription
  34.         NewSpeechChannel
  35.         DisposeSpeechChannel
  36.         SpeakString
  37.         SpeakText
  38.         SpeakBuffer
  39.         StopSpeech
  40.         StopSpeechAt
  41.         PauseSpeechAt
  42.         ContinueSpeech
  43.         SpeechBusy
  44.         SpeechBusySystemWide
  45.         SetSpeechRate
  46.         GetSpeechRate
  47.         GetSpeechPitch
  48.         SetSpeechPitch
  49.         
  50.         kTextToSpeechSynthType
  51.         kTextToSpeechVoiceType
  52.         kTextToSpeechVoiceFileType
  53.         kTextToSpeechVoiceBundleType
  54.         kNoEndingProsody
  55.         kNoSpeechInterrupt
  56.         kPreflightThenPause
  57.         kImmediate
  58.         kEndOfWord
  59.         kEndOfSentence
  60.         kNeuter
  61.         kMale
  62.         kFemale
  63.  
  64.       %Voice
  65.     );
  66. }
  67.  
  68. package Mac::Speech::_VoiceHash;
  69.  
  70. BEGIN {
  71.     use Tie::Hash ();
  72.     use vars qw(@ISA %VoiceDesc);
  73.     @ISA = qw(Tie::StdHash);
  74. }
  75.  
  76. sub FETCH {
  77.     my($self,$voice) = @_;
  78.     if (!%VoiceDesc) {
  79.       foreach my $i (@{[1..Mac::Speech::CountVoices()]}) {
  80.           my $voicet = Mac::Speech::GetIndVoice($i);
  81.           my $voiced = ${Mac::Speech::GetVoiceDescription($voicet)};
  82.           $VoiceDesc{$voiced} = $voicet;
  83.       }
  84.     }
  85.   if (!$self->{$voice}) {
  86.       foreach my $i (keys %VoiceDesc) {
  87.           if ($i =~ /\Q$voice\E/) {
  88.               $self->{$voice} = $VoiceDesc{$i};
  89.               last;
  90.           }
  91.       }
  92.   }
  93.   $self->{$voice};
  94. }
  95.  
  96. package Mac::Speech;
  97.  
  98. =head2 Variables
  99.  
  100. =over 4
  101.  
  102. =item %Voice
  103.  
  104. The C<%Voice> hash will return the index to the first voice matching
  105. the given text.
  106.  
  107. =back
  108.  
  109. =cut
  110.  
  111. tie %Voice, q(Mac::Speech::_VoiceHash);
  112.  
  113. bootstrap Mac::Speech;
  114.  
  115. =head2 Constants
  116.  
  117. =over 4
  118.  
  119. =item kTextToSpeechSynthType
  120.  
  121. =item kTextToSpeechVoiceType
  122.  
  123. =item kTextToSpeechVoiceFileType
  124.  
  125. =item kTextToSpeechVoiceBundleType
  126.  
  127. Speech Types.
  128.  
  129. =cut
  130. sub kTextToSpeechSynthType ()      {     'ttsc'; }
  131. sub kTextToSpeechVoiceType ()      {     'ttvd'; }
  132. sub kTextToSpeechVoiceFileType ()  {     'ttvf'; }
  133. sub kTextToSpeechVoiceBundleType () {     'ttvb'; }
  134.  
  135.  
  136. =item kNoEndingProsody
  137.  
  138. =item kNoSpeechInterrupt
  139.  
  140. =item kPreflightThenPause
  141.  
  142. Synthesizer flags.
  143.  
  144. =cut
  145. sub kNoEndingProsody ()            {          1; }
  146. sub kNoSpeechInterrupt ()          {          2; }
  147. sub kPreflightThenPause ()         {          4; }
  148.  
  149.  
  150. =item kImmediate
  151.  
  152. =item kEndOfWord
  153.  
  154. =item kEndOfSentence
  155.  
  156. Where to stop.
  157.  
  158. =cut
  159. sub kImmediate ()                  {          0; }
  160. sub kEndOfWord ()                  {          1; }
  161. sub kEndOfSentence ()              {          2; }
  162.  
  163.  
  164. =item kNeuter
  165.  
  166. =item kMale
  167.  
  168. =item kFemale
  169.  
  170. Genders.
  171.  
  172. =cut
  173. sub kNeuter ()                     {          0; }
  174. sub kMale ()                       {          1; }
  175. sub kFemale ()                     {          2; }
  176.  
  177. =back
  178.  
  179. =include Speech.xs
  180.  
  181. =head1 BUGS/LIMITATIONS
  182.  
  183. =head1 AUTHOR(S)
  184.  
  185. Matthias Ulrich Neeracher <neeri@iis.ee.ethz.ch> Author
  186.  
  187. =cut
  188.  
  189. 1;
  190.  
  191. __END__
  192.