Last active
December 1, 2018 23:14
-
-
Save Koze/6036c1dbda277ba2c6daf77d552537c2 to your computer and use it in GitHub Desktop.
AVSpeechSynthesizer on swift playground.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import AVFoundation | |
import XCPlayground | |
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
let string = "あのイーハトーヴォのすきとおった風、夏でも底に冷たさをもつ青いそら、うつくしい森で飾られたモーリオ市、郊外のぎらぎらひかる草の波。またそのなかでいっしょになったたくさんのひとたち、ファゼーロとロザーロ、羊飼のミーロや、顔の赤いこどもたち、地主のテーモ、山猫博士のボーガント・テストゥパーゴなど、いまこの暗い巨きな石の建物のなかで考えていると、みんなむかし風のなつかしい青い幻燈のように思われます。" | |
let synthesizer = AVSpeechSynthesizer() | |
let voice = AVSpeechSynthesisVoice(language: "ja_JP") | |
let utterance = AVSpeechUtterance(string: string) | |
utterance.voice = voice | |
synthesizer.speakUtterance(utterance) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment