• 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
puzzled about speech synthesis
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

puzzled about speech synthesis


  • Subject: puzzled about speech synthesis
  • From: Daniel Richman <email@hidden>
  • Date: Thu, 22 Jan 2009 16:49:49 -0800

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];
}
}



When I use the debugger:

- The voice (Alex, in this case) is correctly recognized from the text.
- The speech synthesizer is set to the correct voice.
- "partOfLineToSpeak" is set correctly (to "This is a test.")
- When I get to the "start speaking" command, I get two long (wrapped to several lines each) lines of blather about what I think is the audio driver, but no voice. (Although I tested this on another app I wrote to synthesize a line the user types in, and the same thing happens: blather, but no voice when using gdb.)


So I'm stumped. Why is the wrong line spoken (w/o the debugger), but, with the debugger, the correct line is used?

Thanks,
Daniel

P.S. my init code is below in case you want to refer to that.

- (id)init {
[super init];
play = @"Alex: This is a test.\nBruce: One two.\nFred: This is another test.";
separatedPlay = (NSMutableArray *) [play componentsSeparatedByString:@"\n"];
speechSynthesizer = [[NSSpeechSynthesizer alloc] initWithVoice:nil];
[speechSynthesizer setDelegate:self];
return self;
}


-
_______________________________________________

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


  • Prev by Date: Re: Receiving user events from within an NSTimer callback
  • Next by Date: Re: puzzled about speech synthesis [SOLVED]
  • Previous by thread: Re: What does errAuthorizationToolEnvironmentError mean?
  • Next by thread: Re: puzzled about speech synthesis [SOLVED]
  • Index(es):
    • Date
    • Thread