Mac::Speech - Provide interface to PlainTalk (Speech Manager)


Mac-Carbon documentation Contained in the Mac-Carbon distribution.

Index


Code Index:

NAME

Top

Mac::Speech - Provide interface to PlainTalk (Speech Manager)

SYNOPSIS

Top

    use Mac::Speech;

DESCRIPTION

Top

Access to Inside Macintosh is essential for proper use of these functions. Explanations of terms, processes and procedures are provided there. Any attempt to use these functions without guidance can cause severe errors in your machine, including corruption of data. You have been warned.

Variables

%Voice

The %Voice hash will return the index to the first voice whose name matches the given text.

Constants

kTextToSpeechSynthType
kTextToSpeechVoiceType
kTextToSpeechVoiceFileType
kTextToSpeechVoiceBundleType

Speech Types.

kNoEndingProsody
kNoSpeechInterrupt
kPreflightThenPause

Synthesizer flags.

kImmediate
kEndOfWord
kEndOfSentence

Where to stop.

kNeuter
kMale
kFemale

Genders.

AUTHOR

Top

Written by Matthias Ulrich Neeracher <neeracher@mac.com>. Currently maintained by Chris Nandor <pudge@pobox.com>.


Mac-Carbon documentation Contained in the Mac-Carbon distribution.
use strict;

package Mac::Speech;

BEGIN {
	use Exporter   ();
	use DynaLoader ();
	
	use vars qw($VERSION @ISA @EXPORT %Voice);
	$VERSION = '1.05';
	@ISA = qw(Exporter DynaLoader);
	@EXPORT = qw(
		SpeechManagerVersion
		CountVoices
		GetIndVoice
		GetVoiceDescription
		NewSpeechChannel
		DisposeSpeechChannel
		SpeakString
		SpeakText
		SpeakBuffer
		StopSpeech
		StopSpeechAt
		PauseSpeechAt
		ContinueSpeech
		SpeechBusy
		SpeechBusySystemWide
		SetSpeechRate
		GetSpeechRate
		GetSpeechPitch
		SetSpeechPitch
		TextToPhonemes
		SpeechToFile
		
		kTextToSpeechSynthType
		kTextToSpeechVoiceType
		kTextToSpeechVoiceFileType
		kTextToSpeechVoiceBundleType
		kNoEndingProsody
		kNoSpeechInterrupt
		kPreflightThenPause
		kImmediate
		kEndOfWord
		kEndOfSentence
		kNeuter
		kMale
		kFemale

		%Voice
	);
}

package Mac::Speech::_VoiceHash;

BEGIN {
    use Tie::Hash ();
    use vars qw(@ISA %VoiceDesc);
    @ISA = qw(Tie::StdHash);
}

sub FETCH {
	my($self, $voice) = @_;
	if (! %VoiceDesc) {
		foreach my $i (1 .. Mac::Speech::CountVoices()) {
			my $voicet = Mac::Speech::GetIndVoice($i);
			my $voiced = Mac::Speech::GetVoiceDescription($voicet);
			$VoiceDesc{$voiced->name} = $voicet;
		}
		$VoiceDesc{undef} = $VoiceDesc{Mac::Speech::GetVoiceDescription()->name};
	}
	return $VoiceDesc{undef} unless $voice;
	if (!$self->{$voice}) {
		foreach my $i (keys %VoiceDesc) {
			if ($i =~ /\Q$voice\E/i) {
				$self->{$voice} = $VoiceDesc{$i};
				last;
			}
		}
	}
	$self->{$voice};
}

package Mac::Speech;

tie %Voice, q(Mac::Speech::_VoiceHash);

bootstrap Mac::Speech;

sub kTextToSpeechSynthType ()      {     'ttsc'; }
sub kTextToSpeechVoiceType ()      {     'ttvd'; }
sub kTextToSpeechVoiceFileType ()  {     'ttvf'; }
sub kTextToSpeechVoiceBundleType () {     'ttvb'; }


sub kNoEndingProsody ()            {          1; }
sub kNoSpeechInterrupt ()          {          2; }
sub kPreflightThenPause ()         {          4; }


sub kImmediate ()                  {          0; }
sub kEndOfWord ()                  {          1; }
sub kEndOfSentence ()              {          2; }


sub kNeuter ()                     {          0; }
sub kMale ()                       {          1; }
sub kFemale ()                     {          2; }

1;

__END__