Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift AVSpeechSynthesizer的两个语音通道_Swift_Avaudiosession_Avspeechsynthesizer - Fatal编程技术网

Swift AVSpeechSynthesizer的两个语音通道

Swift AVSpeechSynthesizer的两个语音通道,swift,avaudiosession,avspeechsynthesizer,Swift,Avaudiosession,Avspeechsynthesizer,使用iOS-10.12.2、Swift-3.0.2、Xcode-8.2.1、 我正在尝试使用AVSpeechSynthesis让两种声音同时说话 事实上,有两种文本作为基础,两种声音应同时以两种不同的声音(同一种语言)合成这两种文本 对于一个语音这样做很简单(请参见下面的代码) 但是我如何为这两种声音设置两个音频通道呢 使用AVSpeechSynthesizer我的愿望可以实现吗 这里有一个代码例外,用于对一次文本和一个语音进行文本到语音转换: // ... @IBOutlet weak var

使用iOS-10.12.2、Swift-3.0.2、Xcode-8.2.1、

我正在尝试使用AVSpeechSynthesis让两种声音同时说话

事实上,有两种文本作为基础,两种声音应同时以两种不同的声音(同一种语言)合成这两种文本

对于一个语音这样做很简单(请参见下面的代码)

但是我如何为这两种声音设置两个音频通道呢

使用AVSpeechSynthesizer我的愿望可以实现吗

这里有一个代码例外,用于对一次文本和一个语音进行文本到语音转换:

// ...
@IBOutlet weak var textView: UITextView!

let synth = AVSpeechSynthesizer()
var myUtterance = AVSpeechUtterance(string: "")
// var channelNames = [AVAudioSessionChannelDescription]()

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

@IBAction func textToSpeachButtonPressed(_ sender: Any) {

    self.myUtterance = AVSpeechUtterance(string: textView.text)
    self.myUtterance.rate = 0.4
    self.myUtterance.volume = 1.0

    self.speakWithVoiceOfPerson(person: "Anna")

}

func speakWithVoiceOfPerson(person: String) {
    for voice in AVSpeechSynthesisVoice.speechVoices() {
        print(voice.name)
        if #available(iOS 9.0, *) {
            if voice.name == person {
                self.myUtterance.voice = voice
            }
        }
    }
    synth.speak(self.myUtterance)
}
我正在尝试使用AVSpeechSynthesis让两种声音同时说话

这在iOS 12中绝对不可能,一次只能对一个语音合成进行语音处理


不过,你可以和语音合成一起玩。

我还没有时间测试这个(低优先级)@iKK:不需要测试任何东西,这是苹果自己提供的解决方案;o)