예, outputChannels
속성을 AVSpeechSynthesizer
으로 사용하면됩니다. 애플은 이것에 대한 어떤 문서도 게시하지 않았지만, channelAssignments
속성은 AVAudioPlayer
과 같은 방식으로 작동합니다. 다음과 같이 사람이 읽을 수있는 사용 가능한 채널 목록을 반환합니다.
- (NSArray *)getAudioChannelNames {
// return the name of each channel in each connected audio port
// examples: Headphones Left/Right, Speaker, DUO-CAPTURE 1/2
AVAudioSession *session = [AVAudioSession sharedInstance];
AVAudioSessionRouteDescription *route = [session currentRoute];
NSArray *outputPorts = [route outputs];
NSMutableArray *channels = [NSMutableArray array];
for (AVAudioSessionPortDescription *outputPort in outputPorts) {
for (AVAudioSessionChannelDescription *channel in outputPort.channels) {
[channels addObject:channel.channelName];
}
}
return channels;
}
사용자 또는 사용자가 사용할 채널 이름을 선택할 수 있습니다.
- (void)setSpeechSynthesizer:(AVSpeechSynthesizer *)speechSynthesizer toChannels:(NSArray *)channelNames {
AVAudioSession *session = [AVAudioSession sharedInstance];
AVAudioSessionRouteDescription *route = [session currentRoute];
NSArray *outputPorts = [route outputs];
NSMutableArray *channelDescriptions = [NSMutableArray array];
for (NSString *channelName in channelNames) {
for (AVAudioSessionPortDescription *outputPort in outputPorts) {
for (AVAudioSessionChannelDescription *channel in outputPort.channels) {
if ([channel.channelName isEqualToString:channelName]) {
[channelDescriptions addObject:channel];
}
}
}
}
if ([channelDescriptions count]) {
speechSynthesizer.outputChannels = channelDescriptions;
}
}
speechSynthesizer.outputChannels이 * 아이폰 OS 8.0 – Sridhar
난 출력 채널을 설정할 때마다에 채널의 배열이 항상 것을 같은 것을 할 수있는 옵션이 있습니까 아이폰 OS 10에서 지원 : 그런 다음이 해당 채널을 사용하도록
AVSpeechSynthesizer
을 설정 빈. 어떤 단서가? (나는 Swift와 Ios 10을 사용한다) –@zo_chu'getAudioChannelNames'의 결과가 비어 있음을 의미합니까? 오디오 세션에'AVAudioSessionCategoryMultiRoute'을 사용하고 있습니까? 나는 그 밖의 무엇을 제안해야할지 모른다. – arlomedia