private void RecognitionSuccessEventHandler(RecognitionResponse obj, long requestIndex) { if (!_isRuntimeDetectionToggle.isOn) { _startRecordButton.interactable = true; _speechRecognitionState.color = Color.green; } if (obj != null && obj.results.Length > 0) { _speechRecognitionResult.text = "Speech Recognition succeeded! Detected Most useful: " + obj.results[0].alternatives[0].transcript; string other = "\nDetected alternative: "; foreach (var result in obj.results) { foreach (var alternative in result.alternatives) { if (obj.results[0].alternatives[0] != alternative) { other += alternative.transcript + ", "; } } } _speechRecognitionResult.text += other; } else { _speechRecognitionResult.text = "Speech Recognition succeeded! Words are no detected."; } }
private void SpeechRecognizedSuccessEventHandler(RecognitionResponse obj) { _startRecordButton.interactable = true; if (obj != null && obj.results.Length > 0) { string bestMatch = obj.results[0].alternatives[0].transcript; _speechRecognitionResult.text = "You said: " + bestMatch; changePose(bestMatch); string other = "\nOr: "; foreach (var result in obj.results) { foreach (var alternative in result.alternatives) { if (obj.results[0].alternatives[0] != alternative) { other += alternative.transcript + ", "; } } } _speechRecognitionResult.text += other; } else { _speechRecognitionResult.text = "Speech Recognition succeeded! Words are no detected."; } }
private void SpeechRecognizedSuccessEventHandler(RecognitionResponse obj) { if (obj != null && obj.results.Length > 0) { //Get the first result from recognizer wordRecognized = obj.results[0].alternatives[0].transcript; Debug.Log(wordRecognized + " it's said."); } else { Debug.Log("Words are no detected"); } /* _startRecordButton.interactable = true; * * _speechRecognitionState.color = Color.green; * * if (obj != null && obj.results.Length > 0) * { * tentativas--; * _speechRecognitionResult.text = "Speech Recognition succeeded! Detected Most useful: " + obj.results[0].alternatives[0].transcript; * palavraFalada = obj.results[0].alternatives[0].transcript; * descobrirFonemas(); //descobrir os fonemas da palavra sendo pronunciada * testarPronuncia(); * } * else * { * _speechRecognitionResult.text = "Speech Recognition succeeded! Words are no detected."; * //tentativas++; * * }*/ }
public void Action(RecognitionResponse obj) { string text = obj.results[0].alternatives[0].transcript; //RaycastHit hit; //if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit)) //{ // Instantiate(TextObject, hit.point, Quaternion.identity); //} if (text.IndexOf("爆発") != -1) { GenerateTextObject(text, TextBombObject); } else { GenerateTextObject(text, TextObject); } if (text.IndexOf("最高") != -1) { reactionAudioSource.Play(); } }
void SpeechRecognizedSuccess(RecognitionResponse obj, long txt) { if (pointState == PointState.highPoint) { sumScore += 3; } else if (pointState == PointState.highPoint) { sumScore += 1; } Debug.Log("current sumScore = " + sumScore); }
private void RecognitionSuccessEventHandler(RecognitionResponse obj, long requestIndex) { Debug.Log("RecognitionSuccessEventHandler: " + obj); if (obj != null && obj.results.Length > 0) { Debug.Log("Speech Recognition succeeded! Detected Most useful: " + obj.results[0].alternatives[0].transcript); _result = obj.results[0].alternatives[0].transcript; //SendSTT2Server(obj.results[0].alternatives[0].transcript); } else { Debug.Log("Speech Recognition succeeded! Words are no detected."); } }
//display converted speech to text private void InsertRecognitionResponseInfo(RecognitionResponse recognitionResponse) { //if the player didn't say anything or his voice was too low - assign //a message asking to try again to _resultText //else assign the player's answer if (recognitionResponse == null || recognitionResponse.results.Length == 0) { _answerText.text = "Couldn't hear you. \nPlease, try again!"; return; } else { _resultText.text += "\n" + recognitionResponse.results[0].alternatives[0].transcript; } }
private void RecognitionSuccessEventHandler(RecognitionResponse obj, long requestIndex) { Debug.Log("RecognitionSuccessEventHandler"); if (!_isRuntimeDetectionToggle.isOn) { _startRecordButton.interactable = true; _speechRecognitionState.color = Color.green; } if (obj != null && obj.results.Length > 0) { _speechRecognitionResult.text = "Speech Recognition succeeded! Detected Most useful: " + obj.results[0].alternatives[0].transcript; var words = obj.results[0].alternatives[0].words; if (words != null) { string times = string.Empty; foreach (var item in obj.results[0].alternatives[0].words) { times += "<color=green>" + item.word + "</color> - start: " + item.startTime + "; end: " + item.endTime + "\n"; } _speechRecognitionResult.text += "\n" + times; } string other = "\nDetected alternative: "; foreach (var result in obj.results) { foreach (var alternative in result.alternatives) { if (obj.results[0].alternatives[0] != alternative) { other += alternative.transcript + ", "; } } } _speechRecognitionResult.text += other; } else { _speechRecognitionResult.text = "Speech Recognition succeeded! Words are no detected."; } }
private void InsertRecognitionResponseInfo(RecognitionResponse recognitionResponse) { if (recognitionResponse == null || recognitionResponse.results.Length == 0) { _resultText.text = "\nWords not detected."; return; } _resultText.text += "\n" + recognitionResponse.results[0].alternatives[0].transcript; var words = recognitionResponse.results[0].alternatives[0].words; if (words != null) { string times = string.Empty; foreach (var item in recognitionResponse.results[0].alternatives[0].words) { //times += "<color=green>" + item.word + "</color> - start: " + item.startTime + "; end: " + item.endTime + "\n"; times += item.word; } _resultText.text += "\n" + times; var fileName = "NLP_TEST.txt"; var sr = File.CreateText(fileName); sr.WriteLine(_resultText.text); sr.Close(); } string other = "\nDetected alternatives: "; foreach (var result in recognitionResponse.results) { foreach (var alternative in result.alternatives) { if (recognitionResponse.results[0].alternatives[0] != alternative) { other += alternative.transcript + ", "; } } } _resultText.text += other; }
private void SpeechRecognizedSuccessEventHandler(RecognitionResponse obj) { //_startRecordButton.interactable = true; //_speechRecognitionState.color = Color.green; if (obj != null && obj.results.Length > 0) { _speechRecognitionResult = "Speech Recognition succeeded! Detected Most useful: " + obj.results[0].alternatives[0].transcript; string other = "\nDetected alternative: "; foreach (var result in obj.results) { foreach (var alternative in result.alternatives) { if (obj.results[0].alternatives[0] != alternative) { other += alternative.transcript + ", "; } } } _speechRecognitionResult += other; List <string> contextWordsDetected = new List <string>(); foreach (var contextWord in ContextPhrases) { if (obj.results[0].alternatives[0].transcript.Contains(contextWord)) { _speechContextHits += contextWord + ", "; contextWordsDetected.Add(contextWord); } } if (contextWordsDetected.Count > 0 && null != OnContextSpeechDetected) { OnContextSpeechDetected(contextWordsDetected); } } else { _speechRecognitionResult = "Speech Recognition succeeded! Words are now detected."; } }
private void SpeechRecognizedSuccessEventHandler(RecognitionResponse obj, long requestIndex) { if (obj != null && obj.results.Length > 0) { string transcript = obj.results[0].alternatives[0].transcript; Debug.Log(transcript + " 이 맞느냐?"); AudioClip _latest = _speech.LatestVoice; if (_latest != null && IsTranscriptInSpellKeyword(transcript)) { _source.clip = _latest; _source.Play(); } } else { Debug.Log("믿음이 부족하구나!"); } }
private void SpeechRecognizedSuccessEventHandler(RecognitionResponse obj) { Debug.Log("Success + " + obj); if (obj != null && obj.results.Length > 0) { //Get the first result from recognizer wordRecognized = obj.results[0].alternatives[0].transcript; Debug.Log("'" + wordRecognized + "' it's said."); //Check if the recognized is equal the word checkWord(); } else { Debug.Log("Words are no detected"); } record.interactable = true; //wordText.text = wordRecognized; }
private void SpeechRecognizedSuccessEventHandler(RecognitionResponse obj) { _startRecordButton.interactable = true; _speechRecognitionState.color = Color.green; if (obj != null && obj.results.Length > 0) { tentativas--; _speechRecognitionResult.text = "Speech Recognition succeeded! Detected Most useful: " + obj.results[0].alternatives[0].transcript; palavraFalada = obj.results [0].alternatives [0].transcript; descobrirFonemas(); //descobrir os fonemas da palavra sendo pronunciada testarPronuncia(); } else { _speechRecognitionResult.text = "Speech Recognition succeeded! Words are no detected."; //tentativas++; } }
private void RecognizeSuccessEventHandler(RecognitionResponse recognitionResponse) { _resultText.text = "Detected: "; string[] commands = _commandsInputField.text.Split(','); foreach (var result in recognitionResponse.results) { foreach (var alternative in result.alternatives) { foreach (var command in commands) { if (command.ToLowerInvariant() == alternative.transcript.ToLowerInvariant()) { _resultText.text += command + "; "; // debug result command DoCommand(command.ToLowerInvariant()); } } } } }
private void RecognitionSuccessEventHandler(RecognitionResponse obj, long requestIndex) { /* if (true) * { * _startRecordButton.interactable = true; * * _startRecordButton.GetComponentInChildren<Text>().text = "Start Recording"; * speechState = "notRecording"; * * _startRecordButton.GetComponent<Image>().color = Color.white; * * } */ if (obj != null && obj.results.Length > 0) { Debug.Log("Speech successful"); _speechRecognitionResult.text = obj.results[0].alternatives[0].transcript; List <String> otherS = new List <string>(); foreach (var result in obj.results) { foreach (var alternative in result.alternatives) { otherS.Add(alternative.transcript); } } GameObject.Find("Manager").GetComponent <SingleCharacterDemo>().HandleSpeech(_speechRecognitionResult.text, otherS); // _speechRecognitionResult.text += other; } else { Debug.Log("No words detected"); _speechRecognitionResult.text = "Speech Recognition succeeded! Words are no detected."; } }
private void RecognitionSuccessEventHandler(RecognitionResponse obj, long requestIndex) { isWaiting = false; if (obj != null && obj.results.Length > 0) { string bestFit = obj.results[0].alternatives[0].transcript; //_speechRecognitionResult.text = "Word heard: " + bestFit; //Debug.Log("Called RecognitionSuccessHandler"); //loopCount++; //loopText.text = loopCount.ToString(); if (shareRecognitionEvent != null) { shareRecognitionEvent(bestFit); } } else { // _speechRecognitionResult.text = "Speech Recognition succeeded! But no words recognised... :( "; } }
public void SpeechRecognizedSuccessEventHandler(RecognitionResponse obj, long l) { if (obj != null && obj.results.Length > 0) { // InformationMesh.text = "Speech Recognition succeeded! Detected Most useful: " + obj.results[0].alternatives[0].transcript; InformationMesh.text = "" + obj.results[0].alternatives[0].transcript; /* * string other = "\nDetected alternative: "; * * foreach (var result in obj.results) * { * foreach (var alternative in result.alternatives) * { * if (obj.results[0].alternatives[0] != alternative) * other += alternative.transcript + ", "; * } * } * * InformationMesh.text += other; */ Str = obj.results[0].alternatives[0].transcript; SpeechReaction(obj); } else { InformationMesh.text = "Speech Recognition succeeded! Words are no detected."; _audioSource.clip = FailSound; _audioSource.Play(); } Status = State.Stop; pStatus = 0; //Str = ""; //Str = null; }
private void SpeechReaction(RecognitionResponse obj) { //_reactionManager.Action(obj); }
private void RecognizeSuccessEventHandler(RecognitionResponse recognitionResponse) { _answerText.text = "Your answer: "; InsertRecognitionResponseInfo(recognitionResponse); }
private void RecognizeSuccessEventHandler(RecognitionResponse recognitionResponse) { _resultText.text = "Recognize Success."; InsertRecognitionResponseInfo(recognitionResponse); }
public void OnSuccess(RecognitionResponse response, long index) { Debug.Log("3"); if (response != null && response.results.Length > 0) { var text = response.results[0].alternatives[0].transcript; if (isCommandMode) { var successCommand = false; var values = "바비디/바비디/바비 d/바비 디/밥 ed/밥이 d/밥 이디/바비/바 bd/바디/밥이 디".Split('/'); foreach (var command in values) { var target = command.Trim().Replace(@" ", ""); Debug.Log(target + "@" + text + "@" + text.Replace(@" ", "").Contains(target)); if (text.Replace(@" ", "").Contains(target)) { successCommand = true; break; } } if (successCommand || Input.GetKey(KeyCode.Z)) { retry = false; StartCoroutine(FinalScene()); } else { retry = true; finalPanel.GetComponentInChildren <Text>().text = "마음을 가다듬고 <color=\"#f8e71c\">다시한번</color> 시도해주세요!"; finalPanel.GetComponent <Animator>().Play("ReInitFinal"); StartCommand(); } return; } var contain = false; foreach (var member in ThingsManager.members) { var values = member.nameValues.Split('/'); foreach (var searchName in values) { var targetName = searchName.Trim().Replace(@" ", ""); Debug.Log(targetName + "@" + text + "@" + text.Replace(@" ", "").Contains(targetName)); if (text.Replace(@" ", "").Contains(targetName)) { contain = true; text = member.name; break; } } } if (!contain) { OnFailed(); return; } resultText.text = "<color=\"#F8E71C\">" + text + "</color>가 맞나요?"; selectedMember = text; result.SetActive(true); guide.SetActive(false); } else { OnFailed(); } }
void Update() { TriggerUp = OVRInput.GetUp(OVRInput.Button.PrimaryIndexTrigger); TriggerDown = OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger); if (TriggerDown) { uiText.text = "I'm listening..."; goAudioSource.clip = Microphone.Start(null, true, 7, maxFreq); } if (TriggerUp) { Microphone.End(null); uiText.text = "processing..."; float filenameRand = UnityEngine.Random.Range(0.0f, 10.0f); string filename = "testing" + filenameRand; if (!filename.ToLower().EndsWith(".wav")) { filename += ".wav"; } var filePath = Path.Combine("testing/", filename); filePath = Path.Combine(Application.persistentDataPath, filePath); Debug.Log("Created filepath string: " + filePath); // Make sure directory exists if user is saving to sub dir. Directory.CreateDirectory(Path.GetDirectoryName(filePath)); SavWav.Save(filePath, goAudioSource.clip); //Save a temporary Wav File Debug.Log("Saving @ " + filePath); RecognitionConfig recognitionConfig = new RecognitionConfig(); recognitionConfig.sampleRateHertz = maxFreq; recognitionConfig.languageCode = "en-US"; //Encode audio to bytes for transmission to google cloud Byte[] bytes = File.ReadAllBytes(filePath); String fileContent = Convert.ToBase64String(bytes); RecognitionAudio recognitionAudio = new RecognitionAudio(); recognitionAudio.content = fileContent; RecognitionRequest recognitionRequest = new RecognitionRequest(); recognitionRequest.config = recognitionConfig; recognitionRequest.audio = recognitionAudio; string recognitionRequestJSON = JsonConvert.SerializeObject(recognitionRequest); Debug.Log("Making request to " + apiUrl); HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(apiUrl); webRequest.ContentType = "application/json"; webRequest.Method = "POST"; webRequest.KeepAlive = true; using (var streamWriter = new StreamWriter(webRequest.GetRequestStream())) { streamWriter.Write(recognitionRequestJSON); streamWriter.Flush(); streamWriter.Close(); } var webResponse = (HttpWebResponse)webRequest.GetResponse(); using (var reader = new StreamReader(webResponse.GetResponseStream())) { var response_text = reader.ReadToEnd(); Debug.Log(response_text); Response = JsonConvert.DeserializeObject <RecognitionResponse>(response_text); } Debug.Log("Response:"); Debug.Log(Response.ToString()); var guess = Response.results[0].alternatives[0].transcript; uiText.text = guess; goAudioSource.PlayOneShot((AudioClip)Resources.Load("imsorrydave")); } }
private void RecognitionSuccessEventHandler(RecognitionResponse obj, long requestIndex) { if (!_isRuntimeDetectionToggle.isOn) { _startRecordButton.interactable = true; _speechRecognitionState.color = Color.green; } //음성인식 응용 if (obj != null) { foreach (var item in obj.results) { foreach (var alternative in item.alternatives) { //내 위치에서 플러스 if (alternative.transcript.ToLower().Equals("앞으로")) { Debug.Log("앞으로 갔습니다."); Forward(); } if (alternative.transcript.ToLower().Equals("뒤로가")) { Debug.Log("뒤로 갔습니다."); Back(); } if (alternative.transcript.ToLower().Equals("위로")) { Debug.Log("위로 갔습니다."); Up(); } if (alternative.transcript.ToLower().Equals("아래로")) { Debug.Log("아래로 갔습니다."); Down(); } if (alternative.transcript.ToLower().Equals("오른쪽으로")) { Debug.Log("오른쪽으로 갔습니다."); // Right(); } if (alternative.transcript.ToLower().Equals("왼쪽으로")) { Debug.Log("왼쪽으로 갔습니다."); Left(); } // //애니메이션 if (alternative.transcript.ToLower().Equals("귀여워")) { Debug.Log("귀여워."); Cute(); } if (alternative.transcript.ToLower().Equals("기분 어때")) { Debug.Log("기분을 나타냅니다."); PlaySE(); } if (alternative.transcript.ToLower().Equals("노래 틀어 줘")) { Debug.Log("아모르파티."); PlayMusic(); } if (alternative.transcript.ToLower().Equals("조용히 해")) { Debug.Log("소리를 끕니다."); Mute(); } if (alternative.transcript.ToLower().Equals("체조 하자")) { Debug.Log("체조를합니다."); PlayGym(); } if (alternative.transcript.ToLower().Contains("귀여") || alternative.transcript.ToLower().Contains("귀엽")) { Debug.Log("귀여워."); Cute(); } if (alternative.transcript.ToLower().Contains("기분 어때") || alternative.transcript.ToLower().Contains("상태 어때")) { Debug.Log("기분을 나타냅니다."); PlaySE(); } if (alternative.transcript.ToLower().Contains("노래")) { Debug.Log("아모르파티."); PlayMusic(); } if (alternative.transcript.ToLower().Contains("조용") || alternative.transcript.ToLower().Contains("닥쳐")) { Debug.Log("소리를 끕니다."); Mute(); } if (alternative.transcript.ToLower().Contains("체조")) { Debug.Log("체조를합니다."); PlayGym(); } if (alternative.transcript.ToLower().Contains("안녕") || alternative.transcript.ToLower().Contains("반가")) { for (int t = 10; t <= 15; t++) { String time = t + ""; if (DateTime.Now.ToString("HH") == time) { Debug.Log("점심인사를 합니다."); Hi(); Hi_Voice_lunch(); } } for (int t = 16; t <= 20; t++) { String time = t + ""; if (DateTime.Now.ToString("HH") == time) { Debug.Log("저녁인사를 합니다."); Hi(); Hi_Voice_dinner(); } } for (int t = 21; t <= 24; t++) { String time = t + ""; if (DateTime.Now.ToString("HH") == time) { Debug.Log("밤인사를 합니다."); Hi(); Hi_Voice_night(); } } for (int t = 0; t <= 2; t++) { String time = "0" + t; if (DateTime.Now.ToString("HH") == time) { Debug.Log("밤인사를 합니다."); Hi(); Hi_Voice_night(); } } for (int t = 5; t <= 9; t++) { String time = "0" + t; if (DateTime.Now.ToString("HH") == time) { Debug.Log("아침인사를 합니다."); Hi(); Hi_Voice_monning(); } } } if (alternative.transcript.ToLower().Contains("농담") || alternative.transcript.ToLower().Contains("재밌는 얘기") || alternative.transcript.ToLower().Contains("재미있는 얘기") || alternative.transcript.ToLower().Contains("재미있는 이야기") || alternative.transcript.ToLower().Contains("재밌는 이야기")) { Debug.Log("농담합니다"); PlayJoke(); } if (alternative.transcript.ToLower().Contains("메뉴") || alternative.transcript.ToLower().Contains("뭐 먹지")) { Debug.Log("메뉴추천"); PlayMenu(); } if (alternative.transcript.ToLower().Contains("외롭") || alternative.transcript.ToLower().Contains("외로")) { Debug.Log("외로움을 달랩니다"); PlayAlone(); } if (alternative.transcript.ToLower().Contains("예뻐") || alternative.transcript.ToLower().Contains("예쁘")) { Debug.Log("예쁘다"); PlayPretty(); } if (alternative.transcript.ToLower().Contains("사랑")) { Debug.Log("사랑해"); PlayLove(); } if (alternative.transcript.ToLower().Contains("왔어") || alternative.transcript.ToLower().Contains("왔다")) { Debug.Log("나왔어"); PlayComein(); } if (alternative.transcript.ToLower().Contains("갈게") || alternative.transcript.ToLower().Contains("다녀올게") || alternative.transcript.ToLower().Contains("갔다 올게")) { Debug.Log("다녀올게"); PlayComeout(); } if (alternative.transcript.ToLower().Contains("뭐 해") || alternative.transcript.ToLower().Contains("뭐 하")) { Debug.Log("뭐하고있었어"); PlayDoing(); } if (alternative.transcript.ToLower().Contains("놀아") || alternative.transcript.ToLower().Contains("놀자")) { Debug.Log("놀아주기"); PlayPlaying(); } if (alternative.transcript.ToLower().Contains("뭐 하지") || alternative.transcript.ToLower().Contains("할 거")) { Debug.Log("놀아주기"); PlayWhattodo(); } if (alternative.transcript.ToLower().Contains("뭐 입지") || alternative.transcript.ToLower().Contains("옷 추천") || alternative.transcript.ToLower().Contains("옷 좀 추천")) { Debug.Log("옷고르기"); PlayClothes(); } if (alternative.transcript.ToLower().Contains("소망")) { Debug.Log("소망아"); PlayHope(); } if (alternative.transcript.ToLower().Contains("움직") || alternative.transcript.ToLower().Contains("이동")) { Debug.Log("와리가리"); PlayAnyWhere(); } // } } } // if (obj != null && obj.results.Length > 0) { _speechRecognitionResult.text = "Speech Recognition succeeded! Detected Most useful: " + obj.results[0].alternatives[0].transcript; var words = obj.results[0].alternatives[0].words; if (words != null) { string times = string.Empty; foreach (var item in obj.results[0].alternatives[0].words) { times += "<color=green>" + item.word + "</color> - start: " + item.startTime + "; end: " + item.endTime + "\n"; } _speechRecognitionResult.text += "\n" + times; } string other = "\nDetected alternative: "; foreach (var result in obj.results) { foreach (var alternative in result.alternatives) { if (obj.results[0].alternatives[0] != alternative) { other += alternative.transcript + ", "; } } } _speechRecognitionResult.text += other; } else { _speechRecognitionResult.text = "Speech Recognition succeeded! Words are no detected."; } }
public TranscriptionEventArgs(string results) { Response = JsonConvert.DeserializeObject <RecognitionResponse>(results); }