0
아래 코드는 AVSpeechSynthesizer를 사용하여 방향 목록을 가져 와서 읽습니다. 완료되면 사용자는 다양한 시간을 선택할 수있게되며 앱은 시간 범위에 맞게 지침을 읽습니다.AVSpeechSynthesizer postUtteranceDelay 타이밍 문제
문제는 재생 버튼을 누르면 길 찾기 간의 지연 시간이 예상보다 길다는 것입니다. 2 분 동안 대신에 하드 코딩을했는데 3 분이 걸립니다. 나는 모든 postUtteranceDelays의 값을 기록했고 제대로 합산했다. postUtteranceDelay를 0으로 설정하면 길 찾기간에 일시 중지가 없으므로 처리 시간으로 인한 것이 아닙니다. 무슨 일이 일어나고 있는지 잘 모르겠습니다.
- (IBAction)play:(UIButton *)sender {
[sender setTitle:@"Showering" forState:UIControlStateNormal];
Shower *shower = [[SpecificShower alloc] init];
NSUInteger totalRatio = [shower calculateTotalRatio:shower];
NSNumber *offset = @18.0; // estimated time to speak instructions combined
NSNumber *seconds = @120.0; // hard coded but just for testing
int totalSeconds = seconds.intValue - offset.intValue;
self.synthesizer = [[AVSpeechSynthesizer alloc] init];
for (NSDictionary* direction in shower.directions) {
AVSpeechUtterance *aDirection = [[AVSpeechUtterance alloc] initWithString:direction[@"text"]];
NSNumber *directionLength = direction[@"length"];
aDirection.rate = .3;
aDirection.preUtteranceDelay = 0;
// totalRatio is calculated by adding all the lengths together
// then the individual direction length is divided by totalRatio
// and that fraction is multiplied by total number of seconds
// to come up with the postUtteranceDelay for each direction
aDirection.postUtteranceDelay = totalSeconds * [directionLength floatValue]/totalRatio;
NSLog(@"%f", aDirection.postUtteranceDelay);
[self.synthesizer speakUtterance:aDirection];
}
}
postUtteranceDelay = 0.3으로 설정했을 때 비슷한 문제가 발생했습니다. 때때로 didStartSpeechUtterance가 더 이상 발생하지 않으며 postUtteranceDelay = 0으로 설정하면 모든 문제가 해결됩니다. 이것은 iOS8에서만 발생합니다 – ikzjfr0
OP는 지연 문제에 대해 질문하고 멈추는 발언 문제는 묻지 않습니다. – technophyle