Platforms to show: All Mac Windows Linux Cross-Platform
AVSpeechSynthesizerMBS class
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | Speech | MBS AVFoundation Plugin | 24.1 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
To speak some text, create an AVSpeechUtteranceMBS instance that contains the text and pass it to speakUtterance on a speech synthesizer instance. You can optionally also retrieve an AVSpeechSynthesisVoiceMBS and set it on the utterance’s voice property to have the speech synthesizer use that voice when speaking the utterance’s text.
The speech synthesizer maintains a queue of utterances that it speaks. If the synthesizer isn’t speaking, calling speakUtterance: begins speaking that utterance either immediately or after pausing for its preUtteranceDelay, if necessary. If the synthesizer is speaking, the synthesizer adds utterances to a queue and speaks them in the order it receives them.
After speech begins, you can use the synthesizer object to pause or stop speech. After pausing, you can resume the speech from its paused point or stop the speech entirely and remove all remaining utterances in the queue.
You can monitor the speech synthesizer by examining its speaking and paused properties, or by adding events.
An AVSpeechSynthesizerMBS also controls the route where the speech plays. For more information, see Directing speech output.
The system doesn’t automatically retain the speech synthesizer, so you need to manually retain it until speech concludes.
- 11 events
- event availableVoicesDidChange
- event didCancelSpeechUtterance(utterance as AVSpeechUtteranceMBS)
- event didContinueSpeechUtterance(utterance as AVSpeechUtteranceMBS)
- event didFinishSpeechUtterance(utterance as AVSpeechUtteranceMBS)
- event didPauseSpeechUtterance(utterance as AVSpeechUtteranceMBS)
- event didStartSpeechUtterance(utterance as AVSpeechUtteranceMBS)
- event requestPersonalVoiceAuthorizationCompleted(status as Integer)
- event SpeechSynthesizerBuffer(buffer as AVAudioBufferMBS)
- event SpeechSynthesizerMarker(markers() as AVSpeechSynthesisMarkerMBS)
- event willSpeakMarker(marker as AVSpeechSynthesisMarkerMBS, utterance as AVSpeechUtteranceMBS)
- event willSpeakRangeOfSpeechString(characterRange as NSRangeMBS, utterance as AVSpeechUtteranceMBS)
- 5 properties
- property Handle as Integer
- property isPaused as Boolean
- property isSpeaking as Boolean
- property mixToTelephonyUplink as Boolean
- property usesApplicationAudioSession as Boolean
- shared property personalVoiceAuthorizationStatus as Integer
- 8 methods
- method Constructor
- method continueSpeaking as Boolean
- method Destructor
- method pauseSpeakingAtBoundary(SpeechBoundary as Integer) as Boolean
- method requestPersonalVoiceAuthorization
- method speakUtterance(utterance as AVSpeechUtteranceMBS)
- method stopSpeakingAtBoundary(SpeechBoundary as Integer) as Boolean
- method writeUtterance(utterance as AVSpeechUtteranceMBS)
- shared method IPANotationAttribute as String
- 6 constants
Speech Boundaries
Constant | Value | Description |
---|---|---|
SpeechBoundaryImmediate | 0 |
Indicates to pause or stop speech immediately. |
SpeechBoundaryWord | 1 |
Indicates to pause or stop speech after the synthesizer finishes speaking the current word. |
Authorization Status
Constant | Value | Description |
---|---|---|
SpeechSynthesisPersonalVoiceAuthorizationStatusAuthorized | 3 |
The user granted your app’s request to use personal voices. |
SpeechSynthesisPersonalVoiceAuthorizationStatusDenied | 1 |
The user denied your app’s request to use personal voices. |
SpeechSynthesisPersonalVoiceAuthorizationStatusNotDetermined | 0 |
The app hasn’t requested authorization to use personal voices. |
SpeechSynthesisPersonalVoiceAuthorizationStatusUnsupported | 2 |
The device doesn’t support personal voices. |
This class has no sub classes.
Blog Entries
- MBS Xojo Plugins, version 25.1pr3
- News from the MBS Xojo Plugins Version 24.1
- MonkeyBread Software Releases the MBS Xojo Plugins in version 24.1
- MBS Xojo Plugins, version 24.1pr2
Release notes
- Version 25.1
- Added check to AVSpeechSynthesizerMBS class to raise an exception if you try to use on an older macOS version before 14.0.
- Version 24.1
- Added AVSpeechSynthesizerMBS and related classes.
Some examples using this class:
Some related classes:
- class AVAudioBufferMBS
- class AVSpeechSynthesisMarkerMBS
- class AVSpeechSynthesisVoiceMBS
- class AVSpeechUtteranceMBS
- class NSRangeMBS
The items on this page are in the following plugins: MBS AVFoundation Plugin.
AVSpeechSynthesisVoiceMBS - AVSpeechUtteranceMBS
