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

Enumera as vozes instaladas e chama o método apontado por *callback* para cada voz.

## Sintaxe

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

### Parâmetros

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

Uma variável especificada pelo usuário que será passada para a função de retorno de chamada para permitir que o chamador recupere dados específicos do chamador.

*callback*   \_In\_\
Tipo: [XSpeechSynthesizerInstalledVoicesCallback](/pt-BR/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerinstalledvoicescallback)\*

Um ponteiro para o método que será chamado uma vez por voz instalada.

### Valor retornado

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

Retorna **S\_OK** se for bem-sucedida; caso contrário, retorna um código de erro. Para obter uma lista de códigos de erro, consulte [Códigos de erro](/pt-BR/reference/errorcodes).

## Comentários

<Note>Não é seguro chamar esta função em um thread sensível ao tempo. Para obter mais informações, consulte [Threads sensíveis ao tempo](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).</Note>

Esta função enumera os mecanismos de síntese de fala, ou *vozes*, instalados no dispositivo. A função invoca a função de retorno de chamada [XSpeechSynthesizerInstalledVoicesCallback](/pt-BR/reference/system/xspeechsynthesizer/functions/xspeechsynthesizerinstalledvoicescallback) especificada em *callback* uma vez para cada voz instalada e passa uma estrutura [XSpeechSynthesizerVoiceInformation](/pt-BR/reference/system/xspeechsynthesizer/structs/xspeechsynthesizervoiceinformation) que contém informações sobre essa voz.

O exemplo a seguir demonstra como chamar a função **XSpeechSynthesizerEnumerateInstalledVoices** para enumerar as vozes instaladas no dispositivo. O exemplo invoca a função de retorno de chamada **XSpeechSynthesizerInstalledVoicesCallback** para (1) contar o número de vozes instaladas no dispositivo e (2) enviar ao depurador informações sobre cada voz instalada a partir da estrutura **XSpeechSynthesizerVoiceInformation**.

```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;
}
```

## Requisitos

**Cabeçalho:** XSpeechSynthesizer.h

**Biblioteca:** xgameruntime.lib

**Plataformas com suporte:** Windows, consoles da família XBOX One e consoles XBOX Series

## Documentação conceitual

* [Threads sensíveis ao tempo](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## Confira também

[XAccessibility](/pt-BR/reference/system/xaccessibility/xaccessibility_members)\
[XSpeechSynthesizerSetCustomVoice](/pt-BR/reference/system/xspeechsynthesizer/functions/xspeechsynthesizersetcustomvoice)\
[XSpeechSynthesizer](/pt-BR/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)
