Text to Speech

Text-to-Speech (TTS) is a process where written text is converted into spoken voice output. TTS technologies allow applications to "read" text aloud, providing an auditory version of written materials. This is particularly useful in applications requiring auditory feedback, such as navigational aids, accessibility features for visually impaired users, or interactive voice responses in games and apps.

For a deep dive into the technical details and options available for these requests, refer to the Speech API Reference.

Sample Code for Speech Requests:

SpeechRequest request = new SpeechRequest.Builder()
    .SetPrompt("Hello, welcome to our Unity application.")
    .SetVoice(VoiceActor.Alloy) // You can choose from 6 voice actors as of now
    .Build();

try
{
    AudioClip speechClip = await request.ExecuteAsync();
    // Play the AudioClip using an AudioSource component
}
catch (Exception e)
{
    Debug.LogError($"Error generating speech: {e.Message}");
}

Last updated