Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions ios/TextToSpeech/TextToSpeech.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ -(instancetype)init
return self;
}

+ (BOOL)requiresMainQueueSetup
+ (bool)requiresMainQueueSetup
{
return YES;
return true;
}

RCT_EXPORT_METHOD(speak:(NSString *)text
Expand Down Expand Up @@ -94,7 +94,7 @@ + (BOOL)requiresMainQueueSetup
resolve([NSNumber numberWithUnsignedLong:utterance.hash]);
}

RCT_EXPORT_METHOD(stop:(BOOL *)onWordBoundary resolve:(RCTPromiseResolveBlock)resolve reject:(__unused RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(stop:(bool *)onWordBoundary resolve:(RCTPromiseResolveBlock)resolve reject:(__unused RCTPromiseRejectBlock)reject)
{
AVSpeechBoundary boundary;

Expand All @@ -104,12 +104,12 @@ + (BOOL)requiresMainQueueSetup
boundary = AVSpeechBoundaryImmediate;
}

BOOL stopped = [self.synthesizer stopSpeakingAtBoundary:boundary];
bool stopped = [self.synthesizer stopSpeakingAtBoundary:boundary];

resolve([NSNumber numberWithBool:stopped]);
}

RCT_EXPORT_METHOD(pause:(BOOL *)onWordBoundary resolve:(RCTPromiseResolveBlock)resolve reject:(__unused RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(pause:(bool *)onWordBoundary resolve:(RCTPromiseResolveBlock)resolve reject:(__unused RCTPromiseRejectBlock)reject)
{
AVSpeechBoundary boundary;

Expand All @@ -119,20 +119,20 @@ + (BOOL)requiresMainQueueSetup
boundary = AVSpeechBoundaryImmediate;
}

BOOL paused = [self.synthesizer pauseSpeakingAtBoundary:boundary];
bool paused = [self.synthesizer pauseSpeakingAtBoundary:boundary];

resolve([NSNumber numberWithBool:paused]);
}

RCT_EXPORT_METHOD(resume:(RCTPromiseResolveBlock)resolve reject:(__unused RCTPromiseRejectBlock)reject)
{
BOOL continued = [self.synthesizer continueSpeaking];
bool continued = [self.synthesizer continueSpeaking];

resolve([NSNumber numberWithBool:continued]);
}


RCT_EXPORT_METHOD(setDucking:(BOOL *)ducking
RCT_EXPORT_METHOD(setDucking:(bool *)ducking
resolve:(RCTPromiseResolveBlock)resolve
reject:(__unused RCTPromiseRejectBlock)reject)
{
Expand Down Expand Up @@ -178,7 +178,7 @@ + (BOOL)requiresMainQueueSetup
}

RCT_EXPORT_METHOD(setDefaultRate:(float)rate
skipTransform:(BOOL *)skipTransform // not used, compatibility with Android native module signature
skipTransform:(bool *)skipTransform // not used, compatibility with Android native module signature
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)
{
Expand Down Expand Up @@ -232,7 +232,7 @@ + (BOOL)requiresMainQueueSetup
-(void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didStartSpeechUtterance:(AVSpeechUtterance *)utterance
{
if(_ducking) {
[[AVAudioSession sharedInstance] setActive:YES error:nil];
[[AVAudioSession sharedInstance] setActive:true error:nil];
}

[self sendEventWithName:@"tts-start" body:@{@"utteranceId":[NSNumber numberWithUnsignedLong:utterance.hash]}];
Expand All @@ -241,7 +241,7 @@ -(void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didStartSpeechUttera
-(void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didFinishSpeechUtterance:(AVSpeechUtterance *)utterance
{
if(_ducking) {
[[AVAudioSession sharedInstance] setActive:NO error:nil];
[[AVAudioSession sharedInstance] setActive:false error:nil];
}

[self sendEventWithName:@"tts-finish" body:@{@"utteranceId":[NSNumber numberWithUnsignedLong:utterance.hash]}];
Expand All @@ -250,7 +250,7 @@ -(void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didFinishSpeechUtter
-(void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didPauseSpeechUtterance:(AVSpeechUtterance *)utterance
{
if(_ducking) {
[[AVAudioSession sharedInstance] setActive:NO error:nil];
[[AVAudioSession sharedInstance] setActive:false error:nil];
}

[self sendEventWithName:@"tts-pause" body:@{@"utteranceId":[NSNumber numberWithUnsignedLong:utterance.hash]}];
Expand All @@ -259,7 +259,7 @@ -(void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didPauseSpeechUttera
-(void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didContinueSpeechUtterance:(AVSpeechUtterance *)utterance
{
if(_ducking) {
[[AVAudioSession sharedInstance] setActive:YES error:nil];
[[AVAudioSession sharedInstance] setActive:true error:nil];
}

[self sendEventWithName:@"tts-resume" body:@{@"utteranceId":[NSNumber numberWithUnsignedLong:utterance.hash]}];
Expand All @@ -276,7 +276,7 @@ -(void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer willSpeakRangeOfSpee
-(void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didCancelSpeechUtterance:(AVSpeechUtterance *)utterance
{
if(_ducking) {
[[AVAudioSession sharedInstance] setActive:NO error:nil];
[[AVAudioSession sharedInstance] setActive:false error:nil];
}

[self sendEventWithName:@"tts-cancel" body:@{@"utteranceId":[NSNumber numberWithUnsignedLong:utterance.hash]}];
Expand Down