VDSTextToSpeech
To use VDSTextToSpeech, follow the simple steps
-
drag VDSTextToSpeech to your project.
-
create a variable for easy access to VDSTextToSpeech
let vds = VDSTextToSpeech.shared
-
give the message to be read.
vds.text = "welcome to VDS Text to speech module. Hope you enjoy"
-
speak() : to make VDSTextToSpeech read the message
stopSpeech() : to stop reading
pauseSpeech() : to pause reading (to resume call speak() again)
-
to get callbacks and progress, add VDSTextToSpeech delegate to class
eg:class ViewController: UIViewController,VDSSpeechSynthesizerDelegate { vds.speechSynthesizerDelegate = self //MARK:- VDSSpeechSynthesizerDelegate func speechSynthesizerProgress(_ progress: Float, attributedText: NSMutableAttributedString) { messageLabel.attributedText = attributedText progressView.progress = progress } func speechSynthesizerDidStart() { print("speechSynthesizerDidStart") } func speechSynthesizerDidFinish() { print("speechSynthesizerDidFinish") }