Core Subsystem: TextToSpeechSubsystem — MRTK3
Note
For general information on subsystems in MRTK3, see here.
The Core Definitions package ships TextToSpeechSubsystem
, a base implementation of MRTKSubsystem
and ITextToSpeechSubsystem
that serves as the base of subsystems responsible for text to speech in MRTK3. Concrete implementation shipped as part of MRTK such as WindowsTextToSpeechSubsystem
and other potential text to speech subsystems you might build should all be based on this class. Subsystems inheriting from TextToSpeechSubsystem
have the capability to synthesize and speak a text phrase.
For more specific information, refer to the documentation of the concrete TextToSpeechSubsystem
implementation you want to use.
Setup
Note
This guide provides steps to enable a speech subsystem in a new MRTK project (with other basic non-speech related setup in place). If you're using our sample project you might notice that some steps have been performed for you.
1. Enable the speech subsystem
Go to Project Settings > MRTK3 Available MRTK Subsystems and then enable the text to speech subsystem you'd like to use.
2. Assign a configuration asset (for certain subsystems)
For certain subsystems, a configuration asset is required in order for it to perform normally.
- Click the subsystem you enabled in Setup 1.
- Check to see if an empty
Configuration Asset
slot shows up under Subsystem Details on the right. If so, create a new config by selecting Assets -> Create MRTK > Subsystems > [name of your subsystem] Config and then dragging the created config onto the slot. - After making sure the config slot is populated, change the settings in the newly created config for your specific project. Remember to save the project when you're finished.
3. Ensure the proper capabilities are set in Player Settings
Different implementations of TextToSpeechSubsystem
have different required capabilities. For more information, refer to the documentation of the subsystem you want to use.
4. Running the scene on device/in editor
The project should now be ready to run on device or in editor.
Using TextToSpeechSubsystem
To use TextToSpeechSubsystem
in script, call TrySpeak
. Note that you need to pass in an AudioSource
.
// Get the first running text to speech subsystem.
TextToSpeechSubsystem textToSpeechSubsystem = XRSubsystemHelpers.GetFirstRunningSubsystem<TextToSpeechSubsystem>();
// If we found one...
if (textToSpeechSubsystem != null)
{
// Speak message
textToSpeechSubsystem.TrySpeak("This is a test!", myAudioSource);
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for