Ejemplo n.º 1
0
        public void EnableRecognition(SupportedLanguage language)
        {
            _language = language;
            _session  = PXCMSession.CreateInstance();
            var audioSource = FindAudioSource();

            _session.CreateImpl(out _speechRecognition);
            for (int i = 0; ; i++)
            {
                PXCMSpeechRecognition.ProfileInfo profile;
                if (_speechRecognition.QueryProfile(i, out profile) != RealSenseCamera.NoError)
                {
                    break;
                }
                var languageLabel             = profile.language.ToString();
                SupportedLanguage sdkLanguage = SupportedLanguageMapper.FromString(languageLabel);
                if (sdkLanguage != SupportedLanguage.NotSpecified)
                {
                    _recognitionProfiles.Add(sdkLanguage, profile);
                }
            }
            if (language == SupportedLanguage.NotSpecified)
            {
                language = _recognitionProfiles.Keys.First();
            }
            if (!_recognitionProfiles.ContainsKey(language))
            {
                throw new LanguageNotSupportedException(language);
            }
            _speechRecognition.SetProfile(_recognitionProfiles[language]);
            _speechRecognition.SetDictation();
            _speechRecognition.StartRec(audioSource, _speechRecognitionHandler);
        }
Ejemplo n.º 2
0
 private void EnsureSynthesisModule()
 {
     if (_synthesisModule != null)
     {
         return;
     }
     _session.CreateImpl(out _synthesisModule);
     for (int i = 0;; i++)
     {
         PXCMSpeechSynthesis.ProfileInfo profile;
         if (_synthesisModule.QueryProfile(i, out profile) != RealSenseCamera.NoError)
         {
             break;
         }
         var languageLabel          = profile.language.ToString();
         SupportedLanguage language = SupportedLanguageMapper.FromString(languageLabel);
         if (language != SupportedLanguage.NotSpecified)
         {
             _synthesisProfiles.Add(language, profile);
         }
     }
 }