• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: puzzled about speech synthesis [SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: puzzled about speech synthesis [SOLVED]


  • Subject: Re: puzzled about speech synthesis [SOLVED]
  • From: Daniel Richman <email@hidden>
  • Date: Thu, 22 Jan 2009 17:02:51 -0800

I think this is it. Thank you so much.

Daniel



Roland King wrote:
Daniel Richman wrote:

Hi all,

I am trying to write an app that has a hard-coded NSString, formatted like this:

@"Alex: This is a test.\nBruce: One two.\nFred: This is another test."

The idea is that the lines in the text are spoken using the indicated voice. In the example above, line one is Alex, line two is Bruce, and line three is Fred.

I'm puzzled, however, because what ends up happening is that only the last line ("This is another test") is spoken. Furthermore, the voice used is the first one in the list (Alex). I've tested this with multiple last lines and voices.

So, I set breakpoints in my code:

(IBAction)speakPlay:(id)sender
{
NSLog(@"Starting to speak play");
[isSpeakingField setStringValue:@"Speaking"];
for (NSString *line in separatedPlay) {
// set the speaker for this line
NSUInteger locationOfFirstColonInLine = [line rangeOfString:@":"].location;
NSString *characterForLine = [line substringToIndex:locationOfFirstColonInLine];
[speechSynthesizer setVoice:
[NSString stringWithFormat:@"com.apple.speech.synthesis.voice.%@", characterForLine]];
NSString *partOfLineToSpeak = [line substringFromIndex:(locationOfFirstColonInLine + 2)];
// speak the part of the line after the character
[speechSynthesizer startSpeakingString:partOfLineToSpeak];
}
}



does the speech synthesizer 'queue up' requests like that? Seems more likely that you're ripping through your for loop setting the voice and the line to speak 3 times, each one just overriding the one before so you just get the last line. I would think you need to wait for a delegate callback telling you one line is finished before enqueing the next
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >puzzled about speech synthesis (From: Daniel Richman <email@hidden>)

  • Prev by Date: puzzled about speech synthesis
  • Next by Date: Re: Using the security framework
  • Previous by thread: puzzled about speech synthesis
  • Next by thread: Problem assigning image to button under garbage collection
  • Index(es):
    • Date
    • Thread