[futurebasic] Re: [FB] Text to speech - Voice selection

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2009 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Thu, 11 Jun 2009 14:28:44 +1200
andy@... wrote:

> The Alex voice in Leopard is really good.
> Does anyone know what are the controls to ensure a particular voice  
> and speed are used in Text to Speech?

FB4/5 demo below.
Robert P.

'-------------
include "Tlbx SpeechSynthesis.incl"

dim as SpeechChannel @ myChan
dim as VoiceSpec voiceSpec
dim as VoiceDescription description
dim as Str255 s
dim as OSErr err
dim as short j, alexVoice, @ nVoices
dim as Fixed @ rate

s = "Hello Andy"

fn CountVoices( @nVoices )
alexVoice = 0
for j = 1 to nVoices
fn GetIndVoice( j, @voiceSpec )
fn GetVoiceDescription( voiceSpec, @description,  
sizeof( VoiceDescription ) )
if ( description.name == "Alex" ) then alexVoice = j
next j

fn GetIndVoice( alexVoice, @voiceSpec )
fn NewSpeechChannel( voiceSpec, @myChan )
fn SpeakText( myChan, @s + 1, s[0] )
while ( fn SpeechBusy() )
delay 60
wend
fn DisposeSpeechChannel( myChan )

fn NewSpeechChannel( voiceSpec, @myChan )
fn GetSpeechRate( myChan, @rate )
fn SetSpeechRate( myChan, rate*2 )
fn SpeakText( myChan, @s + 1, s[0] )
while ( fn SpeechBusy() )
delay 60
wend
fn DisposeSpeechChannel( myChan )

fn NewSpeechChannel( voiceSpec, @myChan )
fn GetSpeechRate( myChan, @rate )
fn SetSpeechRate( myChan, rate/3 )
fn SpeakText( myChan, @s + 1, s[0] )
while ( fn SpeechBusy() )
delay 60
wend
fn DisposeSpeechChannel( myChan )
stop
'---------------