import UIKit import AVFoundation class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let synthesizer = AVSpeechSynthesizer() // 読み上げる文字列を指定する let utterance = AVSpeechUtterance(string: "kaka") // 読み上げの速度を指定する utterance.rate = AVSpeechUtteranceMinimumSpeechRate // 声の高さを指定する utterance.pitchMultiplier = 1 // 声のボリュームを指定する utterance.volume = 1.0 let voice = AVSpeechSynthesisVoice() utterance.voice = voice // 読み上げる //エラー回避後 synthesizer.speak(utterance) } }//参考https://dev.classmethod.jp/smartphone/iphone/swfit-avspeechsynthesizer/
このコードをボタンをタッチしたら鳴らすようにしたいです。
回答2件
あなたの回答
tips
プレビュー