アプリで音声合成できないかなーとと思っていろいろ調べていたら、iOS7で標準搭載になったAVSpeechSynthesizer使えば簡単にできそうだったので試してみました。
Swift
AVFoundationを追加します。
import AVFoundation
あとは読み上げをしたいコントローラーに下記のように、読み上げる言葉と音声を指定してあげればOKです
let speech = AVSpeechSynthesizer()
let utterance = AVSpeechUtterance(string: "こんにちは")
utterance.voice = AVSpeechSynthesisVoice(language: "ja-JP")
utterance.rate = 0.3
speech.speakUtterance(utterance)
ちゃんと漢字混じりでも発音してくれます。これは簡単に使えますね。
RubyMotion
app.frameworks += ['AVFoundation']
speech = AVSpeechSynthesizer.alloc.init
utterance = AVSpeechUtterance.speechUtteranceWithString("こんにちは")
utterance.voice = AVSpeechSynthesisVoice.voiceWithLanguage("ja-JP")
utterance.rate = 0.2
speech.speakUtterance(utterance)