Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. import AVFoundation
  2.  
  3. class TextToSpeech {
  4.  
  5. static func sendAudioFeedback(text: String) {
  6. var speechSynthesizer = AVSpeechSynthesizer()
  7. var speechUtterance = AVSpeechUtterance(string: text)
  8. speechUtterance.rate = AVSpeechUtteranceMaximumSpeechRate / 2.5 //You can customize
  9. speechUtterance.voice = AVSpeechSynthesisVoice(language: "en-US")
  10. speechSynthesizer.speak(speechUtterance)
  11. }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement