Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
vilicvane committed Dec 18, 2018
2 parents 3f927dd + b9a4a0b commit a34f1d8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/ios/CDVTTS.m
Expand Up @@ -61,6 +61,13 @@ - (void)speak:(CDVInvokedUrlCommand*)command {

[synthesizer stopSpeakingAtBoundary:AVSpeechBoundaryImmediate];

NSDictionary* options = [command.arguments objectAtIndex:0];

NSString* text = [options objectForKey:@"text"];
NSString* locale = [options objectForKey:@"locale"];
double rate = [[options objectForKey:@"rate"] doubleValue];
double pitch = [[options objectForKey:@"pitch"] doubleValue];

if (!locale || (id)locale == [NSNull null]) {
locale = @"en-US";
}
Expand All @@ -69,6 +76,10 @@ - (void)speak:(CDVInvokedUrlCommand*)command {
rate = 1.0;
}

if (!pitch) {
pitch = 1.2;
}

AVSpeechUtterance* utterance = [[AVSpeechUtterance new] initWithString:text];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:locale];
// Rate expression adjusted manually for a closer match to other platform.
Expand All @@ -78,7 +89,7 @@ - (void)speak:(CDVInvokedUrlCommand*)command {
utterance.rate = utterance.rate * 2;
// see http://stackoverflow.com/questions/26097725/avspeechuterrance-speed-in-ios-8
}
utterance.pitchMultiplier = 1.2;
utterance.pitchMultiplier = pitch;
[synthesizer speakUtterance:utterance];
}

Expand Down

0 comments on commit a34f1d8

Please sign in to comment.