開不了口的告白 & 我們一起學貓叫

沒有什麼特別要請siri幫忙說的,但若SIRI說話能讓狗狗聽懂好像很厲害…….什麼奇怪的邏輯? 鑽研看看這個狗狗翻譯機,也許狗狗聽久了會聽得懂我說什麼….?

APP畫面如及程式碼如下

import UIKitimport AVFoundationclass ViewController: UIViewController {@IBOutlet weak var sayWhat: UITextField!@IBOutlet weak var sayRate: UISlider!@IBOutlet weak var sayPitch: UISlider!@IBOutlet weak var sayVolume: UISlider!override func viewDidLoad() {super.viewDidLoad()// Do any additional setup after loading the view, typically from a nib.}@IBAction func saySomething(_ sender: Any) {let peoplesay = AVSpeechUtterance(string: sayWhat.text!)peoplesay.voice=AVSpeechSynthesisVoice(language: “zh-TW”)peoplesay.rate=sayRate.valuepeoplesay.pitchMultiplier=sayPitch.valuepeoplesay.volume=sayVolume.valuelet mouth=AVSpeechSynthesizer()mouth.speak(peoplesay)}@IBAction func dogwoof(_ sender: Any) {let dogwoof = AVSpeechUtterance(string: “wang,wang”+sayWhat.text!)dogwoof.voice=AVSpeechSynthesisVoice(language: “zh-TW”)dogwoof.rate=sayRate.valuedogwoof.pitchMultiplier=sayPitch.valuedogwoof.volume=sayVolume.valuelet dogmouth=AVSpeechSynthesizer()dogmouth.speak(dogwoof)}}

https://github.com/tkotw1988g/sayWhat

--

--