Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSSpeechSynthesizer not calling delegate methods

NSSpeechSynthesizer not calling delegate methods
Thread Tools
skotskot
Fresh-Faced Recruit
Join Date: Nov 2011
Status: Offline
Reply With Quote
Nov 9, 2011, 08:36 PM
 
Anybody had any luck using an NSSpeechSynthesizerDelegate? None of my delegate methods are being called. Here's the code:

Code:
// main.m #import <Foundation/Foundation.h> #import <AppKit/AppKit.h> @interface SynthesizerDelegate : NSObject <NSSpeechSynthesizerDelegate> @end @implementation SynthesizerDelegate - (void)speechSynthesizer:(NSSpeechSynthesizer *)sender willSpeakWord:(NSRange)characterRange ofString:(NSString *)string { printf("speaking word "); printf("%s \n", [[string substringWithRange:characterRange] UTF8String]); } - (void)speechSynthesizer:(NSSpeechSynthesizer *)sender didFinishSpeaking:(BOOL)finishedSpeaking { printf("finished speaking\n"); } @end int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSString *input = @"I am not an animal. I am a man."; NSSpeechSynthesizer *synthesizer = [[NSSpeechSynthesizer alloc] init]; SynthesizerDelegate *delegate = [[SynthesizerDelegate alloc] init]; [synthesizer setDelegate:delegate]; [synthesizer startSpeakingString:input]; while ([synthesizer isSpeaking]) { sleep(1); } [synthesizer release]; [delegate release]; [pool drain]; return 0; }
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 01:55 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,