> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XSpeechSynthesizerSetCustomVoice

> XSpeechSynthesizerSetCustomVoice

# XSpeechSynthesizerSetCustomVoice

Specifies that the speech synthesizer is to use the specified custom voice.

## Syntax

```cpp theme={null}
HRESULT XSpeechSynthesizerSetCustomVoice(  
         XSpeechSynthesizerHandle speechSynthesizer,  
         const char* voiceId  
)  
```

### Parameters

*speechSynthesizer*   \_In\_\
Type: XSpeechSynthesizerHandle

Specifies the speech synthesizer that will be using the custom voice.

*voiceId*   \_In\_z\_\
Type: char\*

A voice ID in an [XSpeechSynthesizerVoiceInformation](/reference/system/xspeechsynthesizer/structs/xspeechsynthesizervoiceinformation) structure, returned in the [XSpeechSynthesizerInstalledVoicesCallback](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerinstalledvoicescallback) function.

### Return value

Type: [HRESULT](https://learn.microsoft.com/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a)

Returns **S\_OK** if successful; otherwise, returns an error code. For a list of error codes, see [Error Codes](/reference/errorcodes).

## Remarks

<Note>This function isn't safe to call on a time-sensitive thread. For more information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).</Note>

* For each installed voice, the [XSpeechSynthesizerVoiceInformation](/reference/system/xspeechsynthesizer/structs/xspeechsynthesizervoiceinformation) structure provides the voice ID, description, display text, gender, language, and other information.

* To enumerate over and get information about the voices installed on the current device, use the [XSpeechSynthesizerEnumerateInstalledVoices](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerenumerateinstalledvoices) function along with the [XSpeechSynthesizerInstalledVoicesCallback](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerinstalledvoicescallback) callback function.

* To use the current system voice for the specified speech synthesizer, call [XSpeechSynthesizerSetDefaultVoice](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizersetdefaultvoice).

* For an example that demonstrates how to use the **XSpeechSynthesizerSetCustomVoice** function, see [XSpeechSynthesizerCreate](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreate).

## Requirements

**Header:** XSpeechSynthesizer.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Text-to-speech](/build/console-features/text-to-speech/text-to-speech)
* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XAccessibility](/reference/system/xaccessibility/xaccessibility_members)\
[XSpeechSynthesizerCreateStreamFromText](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizercreatestreamfromtext)\
[XSpeechSynthesizer](/reference/system/xspeechsynthesizer/xspeechsynthesizer_members)


## Related topics

- [XSpeechSynthesizerEnumerateInstalledVoices](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerenumerateinstalledvoices.md)
- [XSpeechSynthesizerInstalledVoicesCallback](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerinstalledvoicescallback.md)
- [XSpeechSynthesizerVoiceInformation](/reference/system/xspeechsynthesizer/structs/xspeechsynthesizervoiceinformation.md)
- [XSpeechSynthesizerSetDefaultVoice](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizersetdefaultvoice.md)
- [XSpeechSynthesizer](/reference/system/xspeechsynthesizer/xspeechsynthesizer_members.md)
