Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import AVFoundation
- class TextToSpeech {
- static func sendAudioFeedback(text: String) {
- var speechSynthesizer = AVSpeechSynthesizer()
- var speechUtterance = AVSpeechUtterance(string: text)
- speechUtterance.rate = AVSpeechUtteranceMaximumSpeechRate / 2.5 //You can customize
- speechUtterance.voice = AVSpeechSynthesisVoice(language: "en-US")
- speechSynthesizer.speak(speechUtterance)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement