相关疑难解决方法(0)

swift 3一起使用语音识别和AVFoundation

我成功地能够使用语音(语音识别),我可以使用AVFoundation在Xcode 8/IOS 10中播放wav文件.我不能同时使用它们.我有工作语音识别代码,我导入语音.当我将AVFoundation导入同一个应用程序并使用以下代码时,没有声音,也没有生成错误:

var audioPlayer: AVAudioPlayer!
func playAudio()  {
        let path = Bundle.main.path(forResource: "file.wav", ofType: nil)!
    let url = URL(fileURLWithPath: path)

    do {
        let sound = try AVAudioPlayer(contentsOf: url)
        audioPlayer = sound
        sound.play()
    } catch {
        //handle error
    }

}
Run Code Online (Sandbox Code Playgroud)

我认为这是因为两者都使用音频.任何人都可以建议如何在同一个应用程序中使用它们?我还发现我不能在同一个应用程序中一起使用语音识别和文本到语音.

speech-recognition avaudioplayer ios swift3

8
推荐指数
3
解决办法
2067
查看次数

标签 统计

avaudioplayer ×1

ios ×1

speech-recognition ×1

swift3 ×1