public void Recognize(AudioClip clip, List <string[]> contexts, Enumerators.LanguageCode language) { if (_currentConfig == null) { throw new NotImplementedException("Config isn't seted! Use SetConfig method!"); } if (clip == null) { throw new NotImplementedException("AudioClip isn't seted!"); } string postData = string.Empty; string uri = string.Empty; switch (_currentConfig.recognitionType) { case Enumerators.GoogleNetworkType.SPEECH_RECOGNIZE: { if (!_gcSpeechRecognition.isUseAPIKeyFromPrefab) { uri = Constants.RECOGNIZE_REQUEST_URL + Constants.API_KEY_PARAM + Constants.GC_API_KEY; } else { uri = Constants.RECOGNIZE_REQUEST_URL + Constants.API_KEY_PARAM + _gcSpeechRecognition.apiKey; } postData = JsonUtility.ToJson(GenerateRecognizeRequest( AudioConvert.Convert(clip, _currentConfig.audioEncoding, _currentConfig.useVolumeMultiplier, _currentConfig.audioVolumeMultiplier), contexts, language)); } break; case Enumerators.GoogleNetworkType.SPEECH_LONGRECOGNIZE: { if (!_gcSpeechRecognition.isUseAPIKeyFromPrefab) { uri = Constants.LONG_RECOGNIZE_REQUEST_URL + Constants.API_KEY_PARAM + Constants.GC_API_KEY; } else { uri = Constants.LONG_RECOGNIZE_REQUEST_URL + Constants.API_KEY_PARAM + _gcSpeechRecognition.apiKey; } postData = JsonUtility.ToJson(GenerateRecognizeRequest( AudioConvert.Convert(clip, _currentConfig.audioEncoding, _currentConfig.useVolumeMultiplier, _currentConfig.audioVolumeMultiplier), contexts, language)); } break; default: throw new NotSupportedException(_currentConfig.recognitionType + " doesn't supported!"); } _networking.SendRequest(uri, postData, _currentConfig.recognitionType); }
public void Recognize(AudioClip clip, List <string[]> contexts, Enumerators.LanguageCode language) { if (_currentConfig == null) { throw new NotImplementedException("Config isn't seted! Use SetConfig method!"); } if (clip == null) { throw new NotImplementedException("AudioClip isn't seted!"); } string postData = string.Empty; string uri = string.Empty; switch (_currentConfig.recognitionType) { case Enumerators.SpeechRecognitionType.SYNC: { uri = Constants.RECOGNIZE_REQUEST_URL + Constants.API_KEY_PARAM + Constants.GC_API_KEY; postData = JsonUtility.ToJson(GenerateSyncRequest( AudioConvert.Convert(clip, _currentConfig.audioEncoding, _currentConfig.useVolumeMultiplier, _currentConfig.audioVolumeMultiplier), contexts, language)); } break; case Enumerators.SpeechRecognitionType.ASYNC: { Debug.Log("Async(Long) speech recognition isn't fully implemented!"); uri = Constants.LONG_RECOGNIZE_REQUEST_URL + Constants.API_KEY_PARAM + Constants.GC_API_KEY; postData = JsonUtility.ToJson(GenerateSyncRequest( AudioConvert.Convert(clip, _currentConfig.audioEncoding, _currentConfig.useVolumeMultiplier, _currentConfig.audioVolumeMultiplier), contexts, language)); } break; default: throw new NotSupportedException(_currentConfig.recognitionType + " doesn't supported!"); } _networking.SendRequest(uri, postData); }