AVSpeechSynthesizer IOS into codename one [TTS]

44 views
Skip to first unread message

zayan...@gmail.com

unread,
Dec 11, 2014, 5:26:03 AM12/11/14
to codenameone...@googlegroups.com
Hi everyone,

I'm trying to use AVSpeechsynthesizer in my application. I have already coded my app to use the native android TTS and it's working very well. but I want to implement this functionality in IOS too. Since It's the first time I'm coding with objective-c, I'm totally lost and nothing is working.

somebody already have already developed an application with AVSpeechsynthesizer?

I've tried to do something with this tutorial :

http://www.devfright.com/quick-look-avspeechsynthesizer-class/

but I can't do anything with it...

help please !

thanks

Karim

Shai Almog

unread,
Dec 11, 2014, 9:44:05 AM12/11/14
to codenameone...@googlegroups.com, zayan...@gmail.com
Hi,
did you try something?
Take a look at some of the native code projects in the cn1libs here http://codenameone.com/cn1libs.html
Also at the native demo, the ZXing demo etc.

zayan...@gmail.com

unread,
Dec 16, 2014, 9:25:44 AM12/16/14
to codenameone...@googlegroups.com, zayan...@gmail.com
Hi Shai,

Yes I've tried this :

.h:
#import <Foundation/Foundation.h>

@interface userclasses_NativeCallsImpl : NSObject {
}

-(void)speakString:(NSString*)param param1:(NSString*)param1;
-(BOOL)isSupported;
@end

.m :
#import "userclasses_NativeCallsImpl.h"

@implementation userclasses_NativeCallsImpl

-(void)speakString:(NSString*)texte param1:(NSString*)language{

AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:self.textToSpeak.texte];

        utterance.rate = 0.25;

        utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"fr-FR"];

        [self.synthesizer speakUtterance:utterance];

}

-(BOOL)isSupported{
    return YES;
}

@end

Shai Almog

unread,
Dec 16, 2014, 12:02:37 PM12/16/14
to codenameone...@googlegroups.com, zayan...@gmail.com
Hi,
and did you get an error when trying to compile? Can you attach the file?
Reply all
Reply to author
Forward
0 new messages