本文介绍了如何以编程方式使用IOS语音合成器? (文字转语音)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS设备已经嵌入式语音合成器辅助的VoiceOver功能。有没有一种方法可以使用​​这些合成编程生成基于文本的声音?

iOS devices have embedded voice synthesizers for Accessibility's VoiceOver feature. Is there a way you can use these synthesizers programmatically to generate text-based sounds?

我的问题是:我正在一个简单的应用程序供孩子们学习颜色而非记录颜色的名字在我想要支持的每种语言并将其存储音频文件,我宁愿生成的声音在一些文字到语音功能运行。

My problem is: I'm working on a simple app for kids to learn colors and rather than recording the names of the colors in each language i want to support and storing them as audio files, i'd rather generate the sounds at runtime with some text-to-speech feature.

感谢

推荐答案

从iOS的7起,苹果提供这个 API。

Starting from iOS 7, Apple provides this API.

请参阅答案。

的Objective-C

#import <AVFoundation/AVFoundation.h>
…
AVSpeechUtterance *utterance = [AVSpeechUtterance
                            speechUtteranceWithString:@"Hello World!"];
AVSpeechSynthesizer *synth = [[AVSpeechSynthesizer alloc] init];
[synth speakUtterance:utterance];

斯威夫特

import AVFoundation
…
let utterance = AVSpeechUtterance(string: "Hello World!")
let synth = AVSpeechSynthesizer()
synth.speakUtterance(utterance)

这篇关于如何以编程方式使用IOS语音合成器? (文字转语音)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 15:40