RSDSpeechSynthesizer

open class RSDSpeechSynthesizer : NSObject, RSDVoiceBox, AVSpeechSynthesizerDelegate

RSDSpeechSynthesizer is a concrete implementation of the RSDVoiceBox protocol that uses the AVSpeechSynthesizer to synthesize text to sound.

  • A singleton instance of the voice box.

    Declaration

    Swift

    public static var shared: RSDVoiceBox
  • Is the voice box currently speaking? The default implementation will return true if the AVSpeechSynthesizer is speaking.

    Declaration

    Swift

    open var isSpeaking: Bool { get }
  • Command the voice box to speak the given text. The default implementation will create an AVSpeechUtterance and call the speech synthesizer with the utterance.

    Declaration

    Swift

    open func speak(text: String, completion: RSDVoiceBoxCompletionHandler?)

    Parameters

    text

    The text to speak.

    completion

    The completion handler to call after the text has finished.

  • Command the voice box to stop speaking.

    Declaration

    Swift

    open func stopTalking()
  • Called when the text is synthesizer is finished.

    Declaration

    Swift

    open func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didFinish utterance: AVSpeechUtterance)
  • Called when the text is synthesizer is cancelled.

    Declaration

    Swift

    open func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didCancel utterance: AVSpeechUtterance)