相关疑难解决方法(0)

AVSpeechSynthesizer的问题,有任何解决方法吗?

我正在使用AVSpeechSynthesizer播放文本.我有一系列的话语可以玩.

    NSMutableArray *utterances = [[NSMutableArray alloc] init];
    for (NSString *text in textArray) {
        AVSpeechUtterance *welcome = [[AVSpeechUtterance alloc] initWithString:text];
        welcome.rate = 0.25;
        welcome.voice = voice;
        welcome.pitchMultiplier = 1.2;
        welcome.postUtteranceDelay = 0.25;
        [utterances addObject:welcome];
    }
    lastUtterance = [utterances lastObject];
    for (AVSpeechUtterance *utterance in utterances) {
        [speech speakUtterance:utterance];
    }
Run Code Online (Sandbox Code Playgroud)

我有一个取消按钮停止说话.当我说出第一个话语时单击取消按钮时,语音停止并清除队列中的所有话语.如果我在说出第一个话语(即第二个话语)后按下取消按钮,则停止讲话不会刷新话语队列.我正在使用的代码是:

  [speech stopSpeakingAtBoundary:AVSpeechBoundaryImmediate];
Run Code Online (Sandbox Code Playgroud)

有人可以确认这是API中的错误还是我错误地使用了API?如果是错误,是否有解决此问题的解决方法?

xcode cocoa-touch ios

9
推荐指数
3
解决办法
9596
查看次数

标签 统计

cocoa-touch ×1

ios ×1

xcode ×1