LoginSignup
11
13

More than 5 years have passed since last update.

Siriみたいな声でテキストを読み上げて貰う

Last updated at Posted at 2016-04-24

GetWild退勤的なセンサーアプリを簡単に作れるフレームワークを作ったのでiPhoneに歯痛を心配されたり色々する

で得た知見シリーズ

let talker = AVSpeechSynthesizer()
let utterance = AVSpeechUtterance(string: "こんにちわ")
utterance.voice = AVSpeechSynthesisVoice(language: "ja-JP")
talker.speakUtterance(utterance)

喋らせるだけなら特に難しい点は無い。iOS7以降であればAVFoundation.frameworkを追加してimportするだけで使える。languageにja-JPを設定した状態で"don't touch me"みたいに英語を渡すとちゃんと?日本語で「どんとたっちみー」と喋ってくれる。

ビルド可能なサンプル

iPhoneに顔を近づけると拒絶されるようになって悲しい。

参考にしたもの

11
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
13