Stamatis Pap asked in a forum thread how to use a Speech API ISpVoice with a non-default audio deviceThis MSDN article shows how to use SpEnumTokens to list all the currently active audio outputs, but the number and order of audio outputs is subject to change as things come and go, or as the default audio device changes.

I spent some time poking around the Speech API documentation and discovered that each audio output object has a DeviceId string value which is the WASAPI endpoint ID; this is the way to recognize a given audio output rather than relying on enumeration order.

As part of figuring this out, as a side effect I created a command-line tool to dump all the speech objects and all of their properties.

Source and binaries attached.

Pseudocode:


for each object category in
    (audio outputs; audio inputs; voices; recognizers; etc.)
    SpEnumTokens(category)
    ISpEnumTokens::GetCount();

    for each token
        ISpEnumTokens::Next(1);

        SpGetDescription(ISpObjectToken);
        Log the description

        the ISpObjectToken is also an ISpDataKey
        the ISpDataKey may also contain subkeys
        log all subkeys and their values recursively
            using ISpDataKey::EnumKeys and ISpDataKey::OpenKey
        for each subkey including this one
            log all values in the ISpDataKey
                using ISpDataKey::EnumValues and ISpDataKey::GetStringValue

Here's the output on my system.  Note the audio output has a DeviceId string value which matches the WASAPI endpoint ID.

>speech-attributes.exe

-- SPCAT_AUDIOOUT --
  #1: [[Speakers] ([High Definition Audio Device])]
    Attributes
      Vendor = Microsoft
      Technology = MMSys
    (default) = [[Speakers] ([High Definition Audio Device])]
    CLSID = {A8C680EB-3D32-11D2-9EE7-00C04F797396}
    DeviceName = [[Speakers] ([High Definition Audio Device])]
    DeviceId = {0.0.0.00000000}.{c2cbdacb-a70d-4629-8368-542a00f5a4b0}

-- SPCAT_AUDIOIN --

-- SPCAT_VOICES --
  #1: Microsoft Zira Desktop - English (United States)
    Attributes
      Version = 10.4
      Language = 409
      Gender = Female
      Age = Adult
      SharedPronunciation =
      Name = Microsoft Zira Desktop
      Vendor = Microsoft
    (default) = Microsoft Zira Desktop - English (United States)
    LangDataPath = C:\Windows\Speech\Engines\TTS\en-US\MSTTSLocEnUS.dat
    VoicePath = C:\Windows\Speech\Engines\TTS\en-US\M1033ZIR
    409 = Microsoft Zira Desktop - English (United States)
    CLSID = {C64501F6-E6E6-451f-A150-25D0839BC510}

-- SPCAT_RECOGNIZERS --

-- SPCAT_APPLEXICONS --

-- SPCAT_PHONECONVERTERS --
  #1: Simplified Chinese Phone Converter
    Attributes
      Language = 804
    (default) = Simplified Chinese Phone Converter
    PhoneMap = (lengthy value redacted)
    CLSID = {9185F743-1143-4C28-86B5-BFF14F20E5C8}
  #2: English Phone Converter
    Attributes
      Language = 409
    (default) = English Phone Converter
    PhoneMap = (lengthy value redacted)
    CLSID = {9185F743-1143-4C28-86B5-BFF14F20E5C8}
  #3: French Phone Converter
    Attributes
      Language = 40C
    (default) = French Phone Converter
    PhoneMap = (lengthy value redacted)
    CLSID = {9185F743-1143-4C28-86B5-BFF14F20E5C8}
  #4: German Phone Converter
    Attributes
      Language = 407
    (default) = German Phone Converter
    PhoneMap = (lengthy value redacted)
    CLSID = {9185F743-1143-4C28-86B5-BFF14F20E5C8}
  #5: Japanese Phone Converter
    Attributes
      Language = 411
      NumericPhones =
      NoDelimiter =
    (default) = Japanese Phone Converter
    PhoneMap = (lengthy value redacted)
    CLSID = {9185F743-1143-4C28-86B5-BFF14F20E5C8}
  #6: Spanish Phone Converter
    Attributes
      Language = 40A;C0A
    (default) = Spanish Phone Converter
    PhoneMap = (lengthy value redacted)
    CLSID = {9185F743-1143-4C28-86B5-BFF14F20E5C8}
  #7: Traditional Chinese Phone Converter
    Attributes
      Language = 404
      NumericPhones =
      NoDelimiter =
    (default) = Traditional Chinese Phone Converter
    PhoneMap = (lengthy value redacted)
    CLSID = {9185F743-1143-4C28-86B5-BFF14F20E5C8}
  #8: Universal Phone Converter
    Attributes
      Language = (lengthy value redacted)
    (default) = Universal Phone Converter
    PhoneMap = (lengthy value redacted)
    CLSID = {9185F743-1143-4C28-86B5-BFF14F20E5C8}

-- SPCAT_RECOPROFILES --
  None found.