iOS文本到语音Api
我似乎在这上面找不到任何东西。iOS7中是否有任何Siri类或API允许您进行文本到语音转换?我所要做的就是如下所示:iOS文本到语音Api,ios,text-to-speech,siri,Ios,Text To Speech,Siri,我似乎在这上面找不到任何东西。iOS7中是否有任何Siri类或API允许您进行文本到语音转换?我所要做的就是如下所示: [siriInstance say:@"This is a test"]; 然后让Siri从我的应用程序中说出来 看来我们应该有能力做到这一点,不是吗?似乎是一件小事。我从来没有专门为Siri做过任何工作。我可能错了,但我认为使用私有API与Siri集成是非常困难的 我想看看IOS的openears框架。我以前做过一些基本的工作,包括离线语音识别和合成语音/文本到语音 希望对
[siriInstance say:@"This is a test"];
然后让Siri从我的应用程序中说出来
看来我们应该有能力做到这一点,不是吗?似乎是一件小事。我从来没有专门为Siri做过任何工作。我可能错了,但我认为使用私有API与Siri集成是非常困难的 我想看看IOS的openears框架。我以前做过一些基本的工作,包括离线语音识别和合成语音/文本到语音
希望对您有所帮助。自从iOS 7以来,您有了一个新的TTS Api 在目标C中
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"Some text"];
[utterance setRate:0.2f];
[synthesizer speakUtterance:utterance];
在Swift中
let synthesizer = AVSpeechSynthesizer()
let utterance = AVSpeechUtterance(string: "Some text")
utterance.rate = 0.2
您也可以这样更改声音:
utterance.voice = AVSpeechSynthesisVoice(language: "fr-FR")
然后斯佩克
- 在Swift 2中
synthesis.speakoutrance(话语)
- 在Swift 3中
合成器。说话(发声)
- (BOOL)pauseSpeakingAtBoundary:(AVSpeechBoundary)boundary;
- (BOOL)stopSpeakingAtBoundary:(AVSpeechBoundary)boundary;
AVSpeechBoundary
指示语音应该立即暂停或停止(avspeechboundaryinterment
),还是应该在当前正在讲话的单词之后暂停或停止(AVSpeechBoundaryWord
)
检查你会发现一个基于的文本到语音(TTS)示例应用程序(Objective-C)。这是阿里·阿巴斯在操场上使用的答案:
import UIKit
import AVKit
import AVFoundation
import PlaygroundSupport
var str = "Hello, playground"
let synthesizer = AVSpeechSynthesizer()
let utterance = AVSpeechUtterance(string: str)
utterance.rate = 0.4
utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
//for playground only
let playerViewController = AVPlayerViewController()
PlaygroundPage.current.liveView = playerViewController.view
//
synthesizer.speak(utterance)
没有SiriThis的API答案节省了我的时间,谢谢。所有这些都可以封装到一个帮助器类中,用于进行TTS:@vijayst是的,为什么不:-)你能用openears添加新的声音吗?