none
Why SpFindBestToken returns error SPERR_NOT_FOUND RRS feed

  • Question

  • Hi,
    I have tried the C++ programing of Speech Recognition using the microphone array of Kinect.
    But, SpFindBestToken() returns Error of SPERR_NOT_FOUND in my program.
    Why this error code does returns?

    Thanks,

    This is my program source code : 

    /* Omit */

    // Initialize INuiSensor* pSensor; HRESULT hResult = S_OK; hResult = NuiCreateSensorByIndex( 0, &pSensor ); if( FAILED( hResult ) ){ std::cerr << "Error : NuiCreateSensorByIndex" << std::endl; return -1; } hResult = pSensor->NuiInitialize( NUI_INITIALIZE_FLAG_USES_AUDIO ); if( FAILED( hResult ) ){ std::cerr << "Error : NuiInitialize" << std::endl; return -1; } // InitializeAudioStream INuiAudioBeam* pNuiAudioSource; hResult = pSensor->NuiGetAudioSource( &pNuiAudioSource ); if( FAILED( hResult ) ){ std::cerr << "Error : NuiGetAudioSource" << std::endl; return -1; } IMediaObject* pMediaObject = nullptr; hResult = pNuiAudioSource->QueryInterface( IID_IMediaObject, reinterpret_cast<void**>( &pMediaObject ) ); if( FAILED( hResult ) ){ std::cerr << "Error : QueryInterface( pMediaObject )" << std::endl; return -1; } IPropertyStore* pPropertyStore = nullptr; hResult = pNuiAudioSource->QueryInterface( IID_IPropertyStore, reinterpret_cast<void**>( &pPropertyStore ) ); if( FAILED( hResult ) ){ std::cerr << "Error : QueryInterface( pPropertyStore )" << std::endl; return -1; } PROPVARIANT propvariant; PropVariantInit( &propvariant ); propvariant.vt = VT_I4; propvariant.lVal = static_cast<LONG>( 4 ); pPropertyStore->SetValue( MFPKEY_WMAAECMA_SYSTEM_MODE, propvariant ); PropVariantClear( &propvariant ); WAVEFORMATEX waveFormat = { AudioFormat, AudioChannels, AudioSamplesPerSecond, AudioAverageBytesPerSecond, AudioBlockAlign, AudioBitsPerSample, 0 }; DMO_MEDIA_TYPE mediaType = { 0 }; MoInitMediaType( &mediaType, sizeof( WAVEFORMATEX ) ); mediaType.majortype = MEDIATYPE_Audio; mediaType.subtype = MEDIASUBTYPE_PCM; mediaType.lSampleSize = 0; mediaType.bFixedSizeSamples = true; mediaType.bTemporalCompression = false; mediaType.formattype = FORMAT_WaveFormatEx; memcpy( mediaType.pbFormat, &waveFormat, sizeof( WAVEFORMATEX ) ); pMediaObject->SetOutputType( 0, &mediaType, 0 ); KinectAudioStream* audioStream = new KinectAudioStream( pMediaObject ); IStream* pStream = nullptr; hResult = audioStream->QueryInterface( IID_IStream, reinterpret_cast<void**>( &pStream ) ); if( FAILED( hResult ) ){ std::cerr << "Error : QueryInterface( pStream )" << std::endl; return -1; } CoInitialize( nullptr ); ISpStream* pSpeechStream = nullptr; hResult = CoCreateInstance( CLSID_SpStream, NULL, CLSCTX_INPROC_SERVER, __uuidof(ISpStream), reinterpret_cast<void**>( &pSpeechStream ) ); if( FAILED( hResult ) ){ std::cerr << "Error : CoCreateInstance" << std::endl; return -1; } hResult = pSpeechStream->SetBaseStream( pStream, SPDFID_WaveFormatEx, &waveFormat ); if( FAILED( hResult ) ){ std::cerr << "Error : SetBaseStream" << std::endl; return -1; } MoFreeMediaType( &mediaType ); pStream->Release(); pPropertyStore->Release(); pMediaObject->Release(); pNuiAudioSource->Release(); // CreateSpeechRecognizer ISpRecognizer* pSpeechRecognizer; hResult = CoCreateInstance( CLSID_SpInprocRecognizer, nullptr, CLSCTX_INPROC_SERVER, __uuidof(ISpRecognizer), reinterpret_cast<void**>( &pSpeechRecognizer ) ); if( FAILED( hResult ) ){ std::cerr << "Error : CoCreateInstance" << std::endl; return -1; } pSpeechRecognizer->SetInput( pSpeechStream, false ); ISpObjectToken* pEngineToken = NULL; hResult = SpFindBestToken( SPCAT_RECOGNIZERS, L"Language=409;Kinect=True", NULL, &pEngineToken ); if( hResult == SPERR_NOT_FOUND ){ /* Error here... */ std::cerr << "Error : SpFindBestToken( SPERR_NOT_FOUND )" << std::endl; return -1; } if( FAILED( hResult ) ){ std::cerr << "Error : SpFindBestToken" << std::endl; return -1; }

    /* Omit */


    Thursday, September 5, 2013 4:55 PM

Answers

  • Thank you everyone!
    I was rebuild the development environment (from Re-install of OS).
    My program has running successfully!
    I think the cause is failed installed of Speech SDK probably.

    Many Thanks to Carmine Sirignano that gave a lot of advice.
    • Marked as answer by T.Sugiura Friday, September 6, 2013 5:32 PM
    Friday, September 6, 2013 5:32 PM

All replies

  • That is a public API from the Microsoft Speech Platform that you may need to engage with them to get further details of the error. Based on the information available, there might be an issue with the installation of the speech components or the sensor state. Are you having issues with both the SpeechBasics sample and your application or just your application?

    Developer Support (SAPI 5.4)
    http://msdn.microsoft.com/en-us/library/ee431825(v=vs.85).aspx

    While not an error, you might want to check your initialization and not make assumptions about the sensor. You should always check the Status of the sensor: NuiCreateSensorByIndex( 0, &pSensor );

    http://msdn.microsoft.com/en-us/library/hh973099.aspx

    I don't think that is the issue here. The point of failure seems to be a problem where you are loading the necessary speech language components. You could also try Sysinternals Process Monitor and check for errors in log that is collected.


    Carmine Sirignano - MSFT

    Thursday, September 5, 2013 6:36 PM
  • Hi, Carmine Sirignano
    Thank you for the quick reply!

    I have confirmed that the sample program ( Speech Basics-D2D ) to work correctly.
    And, I has confirmed that INuiSensor::NuiStatus() returns S_OK.

    I was monitored the my program using process monitor of Sysinternals.
    But, I don't know how to interpret the log.
    This is the log file ( Logfile.PML ) of monitoring.
    Please check the log file!

    Thursday, September 5, 2013 8:48 PM
  • I'm having this problem as well, I figured it was related to http://social.msdn.microsoft.com/Forums/en-US/b56c8dab-8f4d-4f84-bc6f-2b9ab4e9f914/sapi-loaddictation . Are you running on Windows 8?

    Thursday, September 5, 2013 9:05 PM
  • Hi, Mark Barrett
    Thank you for the reply!

    My development environment is Windows 7 Pro 64bit and Visual Studio 2010 Pro.
    Thursday, September 5, 2013 10:26 PM
  • Can you check to see if you have both of these installed:
    "Microsoft Server Speech Platform Runtime (x64)"
    and
    "Microsoft Server Speech Platform Runtime (x86)"

    You can try and re-download and install these again:
    http://www.microsoft.com/en-us/download/details.aspx?id=27226

    Based on the logfile, it is looking up token values in the registry and there is an ACCESS DENIED:
    1:09:52.9919125 PM Audio2.exe 7716 RegOpenKey HKLM\SOFTWARE\Microsoft\Speech\Recognizers\Tokens\MS-1041-80-DESK ACCESS DENIED Desired Access: Read/Write

    For the sample to work and not your code, looking at the differences in the 2 project settings will be key. Are you compiling for x86 or x64?


    Carmine Sirignano - MSFT


    Thursday, September 5, 2013 10:50 PM
  • I compiled x64.
    Speech Platform SDK x64 is installed.
    Speech Platform Runtime (x86) and Speech Platform Runtime (x64) is installed.
    I tried also Re-installed but does not work...

    I'll try to Re-install of the OS.
    Try again with a clean environment.
    (Sorry, It will take one day.)
    Thursday, September 5, 2013 11:59 PM
  • Thank you everyone!
    I was rebuild the development environment (from Re-install of OS).
    My program has running successfully!
    I think the cause is failed installed of Speech SDK probably.

    Many Thanks to Carmine Sirignano that gave a lot of advice.
    • Marked as answer by T.Sugiura Friday, September 6, 2013 5:32 PM
    Friday, September 6, 2013 5:32 PM