Created
January 11, 2019 14:54
-
-
Save Hadevs/00673642f935102d511b1b06ff708a0f to your computer and use it in GitHub Desktop.
voice.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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