public IEnumerator <object> MakeAnalysisRequest(byte[] bytes) { var headers = new Dictionary <string, string>() { { "Ocp-Apim-Subscription-Key", Constants.MCS_COMPUTERVISIONKEY }, { "Content-Type", "application/octet-stream" } }; string requestParameters = "?visualFeatures=Description&language=en"; string uri = Constants.MCS_BASEURL + "/vision/v3.0/analyze" + requestParameters; //if ((bytes != null) && (bytes.Length > 0)) //{ WWW www = new WWW(uri, bytes, headers); yield return(www); if (www.error != null) { Debug.Log(www.error); } else { ODResults results = JsonUtility.FromJson <ODResults>(www.text); PlayVoiceMessage.Instance.PlayTextToSpeechMessage(results); } //} }
public void PlayTextToSpeechMessage(ODResults result) { string message = string.Empty; if (string.IsNullOrEmpty(result.ToString())) { message = "I couldn't analyze the scene."; } else { message = (result.description.captions[0].confidence > 0.85f) ? string.Format("The scene is likely, {0}", result.ToString()) : string.Format("The scene might be, {0}", result.ToString()); } // Try and get a TTS Manager TextToSpeech tts = null; if (photoCaptureManagerGmObj != null) { tts = photoCaptureManagerGmObj.GetComponent <TextToSpeech>(); } if (tts != null) { //Play voice message tts.StartSpeaking(message); } }