1

iOS10アプリは、テキストと音声の認識を行います。この間、他のアプリからの音声を一時停止し、ASR/TTSが終了したときに他のアプリに音声を再開できるように通知します。 すべてがiPhone5と6で完璧に機能します。AVSpeechSynthesizer(Text to Speech)再生の音量は、iPhone7のみで増加します。

問題は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]; 

答えて

0

これが起こる可能性があるため、アクティブなオーディオセッションにAVAudioSessionモード。

モードAVAudioSessionModeMeasurementを使用しているときにこの動作が発生していない唯一のモードがありました。