Skip to main content

text-to-speech | ios-app-dev-memo

こんな感じで良さそう

swift
import AVFoundation

class SpeechUtil {
static let synthesizer = AVSpeechSynthesizer()

static func readAloud(_ message: String) {
let u = AVSpeechUtterance(string: message)
u.voice = AVSpeechSynthesisVoice(language: "en-US")
u.rate = 0.5

synthesizer.speak(u)
}
}