사용자가 AVSpeechSynthesizer
을 사용하여 텍스트를들을 수있는 phonegap 용 플러그인을 만들었지 만 pauseSpeakingAtBoundary
을 사용할 수없는 것으로 보입니다.ios 전화 갭을위한 AVSpeechSynthesizer 플러그인 pauseSpeakingAtBoundary가 작동하지 않음
테스트 목적으로 현재 합성 할 텍스트 문자열 또는 'PAUSE'라고 표시된 문자열을 수신하여 음성을 일시 중지해야하는지 여부를 결정하기 위해 i f (![echo isEqual:@'PAUSE']
을 확인합니다. 말하기가 시작되고 'PAUSE'를 받았지만 합성기가 계속 말하면 기록됩니다.
나는 완전히 새롭기 때문에 내가 실수를했는지 또는 pauseSpeakingAtBoudary
에 문제가 있는지 확실하지 않습니다. 내 코드는 다음과 같습니다. 감사.
다시 말씀 드리 자면, 제가 일하러 갈 수없는 pauseSpeakingAtBoundary입니다. 음성 합성은 phonegaps 설명서에 따라 자바 스크립트 exec에서 작동합니다.
//
// Echo.h
// Plugin
//
//
//
//
#import <Cordova/CDVPlugin.h>
#import <AVFoundation/AVFoundation.h>
@interface Echo : CDVPlugin <AVSpeechSynthesizerDelegate>
@property (strong, nonatomic) AVSpeechSynthesizer *synthesizer;
- (void) echo:(NSMutableArray*)arguments;
@end
//
// Echo.m
// Plugin
//
//
//
//
#import "Echo.h"
@implementation Echo
- (void)echo:(CDVInvokedUrlCommand*)command
{
CDVPluginResult* pluginResult = nil;
NSString* echo = [command.arguments objectAtIndex:0];
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init];
synthesizer.delegate = self;
if (echo != nil && [echo length] > 0) {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:echo];
if(![echo isEqual:@"PAUSE"]) {
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:echo];
utterance.rate = 0.20;
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-gb"];
[synthesizer speakUtterance:utterance];
} else {
NSLog(@"Pausing");
[synthesizer pauseSpeakingAtBoundary:AVSpeechBoundaryImmediate];
}
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
}
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
@end