1

iOS10 앱은 텍스트 음성 변환 및 음성 인식을 수행합니다. 이런 일이 발생하면 다른 앱의 오디오를 일시 중지하고 ASR/TTS가 끝나면 오디오를 다시 시작할 수 있도록 다른 사람에게 알립니다. iPhone5 및 6에서 모든 기능이 완벽하게 작동합니다.iPhone7에서만 AVSpeechSynthesizer (Text to Speech) 재생 음량이 증가합니다.

문제는 iPhone7s에서 발생합니다. 처음에는 구어의 양이 매우 적고 구의 끝으로 갈수록 커집니다. 왜?

iOS 버그처럼 보이기 때문에 필자의 경우 일부 코드 만 제공합니다.

오디오 세션 코드 :

-(AVAudioSessionCategoryOptions)indigoAudioBehaviorOptions:(AVAudioSession *)s{ 
    AVAudioSessionCategoryOptions audioIOoptions = [s categoryOptions]; 
    audioIOoptions |= AVAudioSessionCategoryOptionDefaultToSpeaker; 
    audioIOoptions |= AVAudioSessionCategoryOptionAllowBluetooth; 
    audioIOoptions |= AVAudioSessionCategoryOptionAllowBluetoothA2DP; 
    return audioIOoptions; 
} 
-(void)notifyIOSthatOtherAppsCanResumeAudioPlayback{ 
    NSError *err; 
    [myAudioSession setActive: NO 
        withOptions: AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation 
         error: &err]; 
    if(err!=nil){ 
     NSLog(@"audioIsFreeNotificationForIOS ERROR: %@",err.description); 
    } 
} 


myAudioSession = [AVAudioSession sharedInstance]; 
NSError *err; 
[myAudioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions: [self indigoAudioBehaviorOptions:indigoAudioSession] error:&err]; 

텍스트 음성 변환 코드 :

nativeVocalizer = [[AVSpeechSynthesizer alloc] init]; 
nativeVocalizer.delegate = self; 
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:stringToSpeak]; 
[utterance setVoice:[AVSpeechSynthesisVoice voiceWithLanguage:lang]]; 
[nativeVocalizer speakUtterance:utterance]; 

답변