Skip to content

Instantly share code, notes, and snippets.

@Hadevs
Created January 11, 2019 14:54
Show Gist options
  • Save Hadevs/00673642f935102d511b1b06ff708a0f to your computer and use it in GitHub Desktop.
Save Hadevs/00673642f935102d511b1b06ff708a0f to your computer and use it in GitHub Desktop.
voice.swift
import AVFoundation
func speak(text: String) {
let speechSynthesizer = AVSpeechSynthesizer()
let utterance = AVSpeechUtterance(string: text)
utterance.pitchMultiplier = 1
utterance.rate = AVSpeechUtteranceDefaultSpeechRate
utterance.volume = 1
utterance.voice = AVSpeechSynthesisVoice.speechVoices().randomElement() // Тут ты можешь выбрать проиграеваемый голос
speechSynthesizer.speak(utterance)
}
speak(text: "Hello, Swift tips!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment