加入2个不同的标签以进行文本到语音的转换(swift3) [英] Join 2 different labels for text to speech conversion (swift3)

查看:121
本文介绍了加入2个不同的标签以进行文本到语音的转换(swift3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用语音转文字功能,我可以轻松说出一个标签.但我希望将话语2与话语结合起来.我希望先说出话语,然后说完话语之后再说完话.

Using the speech to text feature I can easily get one label to be spoken. But I want utterance2 to be joined to utterance. I want utterance to be spoken first then when it is finished for utterance2 to be spoken right after.

     let utterance = AVSpeechUtterance(string: dptext.text!)
     let utterance2 = AVSpeechUtterance(string: dptext2.text!)

     let synthesizer = AVSpeechSynthesizer()
     synthesizer.speak(utterance)

推荐答案

我认为处理这种情况的最简单方法是将两个字符串与space组合在一起.

I think the simplest way to handle this situation is to combine the two string with space.

let combineString = dptext.text! + " " + dptext2.text!
let utterance = AVSpeechUtterance(string: combineString)
let synthesizer = AVSpeechSynthesizer()
synthesizer.speak(utterance)

这篇关于加入2个不同的标签以进行文本到语音的转换(swift3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆