> ## 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.

# XSpeechSynthesizerEnumerateInstalledVoices

> XSpeechSynthesizerEnumerateInstalledVoices

# XSpeechSynthesizerEnumerateInstalledVoices

Énumère les voix installées et appelle la méthode désignée par *callback* pour chaque voix.

## Syntaxe

```cpp theme={null}
HRESULT XSpeechSynthesizerEnumerateInstalledVoices(  
         void* context,  
         XSpeechSynthesizerInstalledVoicesCallback* callback  
)  
```

### Paramètres

*context*   \_In\_opt\_\
Type : void\*

Variable spécifiée par l'utilisateur qui est transmise à la fonction de rappel pour permettre à l'appelant de récupérer des données qui lui sont propres.

*callback*   \_In\_\
Type : [XSpeechSynthesizerInstalledVoicesCallback](/fr/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerinstalledvoicescallback)\*

Pointeur vers la méthode qui est appelée une fois par voix installée.

### Valeur de retour

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

Retourne **S\_OK** en cas de réussite ; sinon, retourne un code d'erreur. Pour obtenir la liste des codes d'erreur, consultez [Codes d'erreur](/fr/reference/errorcodes).

## Remarques

<Note>Il n'est pas sûr d'appeler cette fonction sur un thread sensible au temps. Pour plus d'informations, consultez [Threads sensibles au temps](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).</Note>

Cette fonction énumère les moteurs de synthèse vocale, ou *voix*, installés sur l'appareil. La fonction appelle la fonction de rappel [XSpeechSynthesizerInstalledVoicesCallback](/fr/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerinstalledvoicescallback) spécifiée dans *callback* une fois pour chaque voix installée, et lui transmet une structure [XSpeechSynthesizerVoiceInformation](/fr/reference/system/xspeechsynthesizer/structs/xspeechsynthesizervoiceinformation) qui contient des informations sur cette voix.

L'exemple suivant montre comment appeler la fonction **XSpeechSynthesizerEnumerateInstalledVoices** pour énumérer les voix installées sur l'appareil. L'exemple appelle la fonction de rappel **XSpeechSynthesizerInstalledVoicesCallback** pour (1) compter le nombre de voix installées sur l'appareil et (2) envoyer au débogueur les informations de la structure **XSpeechSynthesizerVoiceInformation** pour chaque voix installée.

```cpp theme={null}
int Game::CountInstalledVoices()
{
    HRESULT hr = S_OK;
    int* voiceCount = new int();
    // Call XSpeechSynthesizerEnumerateInstalledVoices with a callback function
    // defined as a lambda expression that increments the count of installed voices 
    // each time it's invoked, and outputs information about each voice to the 
    // debugger for display.
    hr = XSpeechSynthesizerEnumerateInstalledVoices(voiceCount,
        [](
            _In_ const XSpeechSynthesizerVoiceInformation* information,
            _In_ void* context
            ) -> bool 
        {
        // Increment and update the count of installed voices.
        int* voiceCount = (int*)context;
        *voiceCount = *voiceCount + 1;
        CopyMemory(context, voiceCount, sizeof(int));

        // Output information about the current installed voice
        // to the debugger for display.
        char buffer[1000];
        int bufferLen;
        bufferLen = sprintf(buffer, "(%s) %s - %s, %s\n",
            information->VoiceId,
            information->Description,
            information->Gender == XSpeechSynthesizerVoiceGender::Male ? "Male" : "Female",
            information->Language);
        OutputDebugStringA(buffer);
      
        // Continue iterating through installed voices.
        // If this was set to false, the calling function would stop
        // enumerating installed voices.
        return true;
        }
    );

    // Return the count of installed voices.
    return *voiceCount;
}
```

## Configuration requise

**En-tête :** XSpeechSynthesizer.h

**Bibliothèque :** xgameruntime.lib

**Plateformes prises en charge :** Windows, consoles de la famille XBOX One et consoles XBOX Series

## Documentation conceptuelle

* [Threads sensibles au temps](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## Voir aussi

[XAccessibility](/fr/reference/system/xaccessibility/xaccessibility_members)\
[XSpeechSynthesizerSetCustomVoice](/fr/reference/system/xspeechsynthesizer/functions/xspeechsynthesizersetcustomvoice)\
[XSpeechSynthesizer](/fr/reference/system/xspeechsynthesizer/xspeechsynthesizer_members)


## Related topics

- [XSpeechSynthesizerEnumerateInstalledVoices](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerenumerateinstalledvoices.md)
- [XSpeechSynthesizerInstalledVoicesCallback](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerinstalledvoicescallback.md)
- [XSpeechSynthesizerVoiceGender](/reference/system/xspeechsynthesizer/enums/xspeechsynthesizervoicegender.md)
- [XSpeechSynthesizer](/reference/system/xspeechsynthesizer/xspeechsynthesizer_members.md)
- [XSpeechSynthesizerSetDefaultVoice](/reference/system/xspeechsynthesizer/functions/xspeechsynthesizersetdefaultvoice.md)
