Permalink
Browse files

Update Asset

- Google Cloud Speech Recognition 3.0
  • Loading branch information...
m2wasabi committed Jul 16, 2017
1 parent 2416b44 commit 6d1824a659f05baa8d7e136f65419b9fc096f7d5
Showing with 13 additions and 27 deletions.
  1. +1 −1 Assets/RotCube/Scripts/ReactionManager.cs
  2. +12 −26 Assets/RotCube/Scripts/speech.cs
@@ -1,7 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using FrostweepGames.Plugins.GoogleCloud.SpeechRecognition;
using UnityEngine;
using FrostweepGames.SpeechRecognition.Google.Cloud;
using HoloToolkit.Unity;
public class ReactionManager : Singleton<ReactionManager>
@@ -2,15 +2,14 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using FrostweepGames.SpeechRecognition.Utilites;
using FrostweepGames.SpeechRecognition.Google.Cloud;
using FrostweepGames.Plugins.GoogleCloud.SpeechRecognition;
using UnityEngine.VR.WSA.Input;
using System;
public class speech : MonoBehaviour
{
public TextMesh InformationMesh;
private ILowLevelSpeechRecognition _speechRecognition;
private GCSpeechRecognition _speechRecognition;
//private InputField _contextPhrases;
private ReactionManager _reactionManager;
@@ -56,9 +55,10 @@ private void InputActionRecognizer_HoldCompletedEvent(InteractionSourceKind sour
// Use this for initialization
void Start()
{
_speechRecognition = SpeechRecognitionModule.Instance;
_speechRecognition.SpeechRecognizedSuccessEvent += SpeechRecognizedSuccessEventHandler;
_speechRecognition.SpeechRecognizedFailedEvent += SpeechRecognizedFailedEventHandler;
_speechRecognition = GCSpeechRecognition.Instance;
_speechRecognition.SetLanguage(Enumerators.LanguageCode.JA);
_speechRecognition.RecognitionSuccessEvent += SpeechRecognizedSuccessEventHandler;
_speechRecognition.RecognitionFailedEvent += SpeechRecognizedFailedEventHandler;
_reactionManager = ReactionManager.Instance;
@@ -83,14 +83,8 @@ void Update()
private void OnDestroy()
{
_speechRecognition.SpeechRecognizedSuccessEvent -= SpeechRecognizedSuccessEventHandler;
_speechRecognition.SpeechRecognizedFailedEvent -= SpeechRecognizedFailedEventHandler;
}
private void IsRuntimeDetectionOnValueChangedHandler(bool value)
{
StopRuntimeDetectionButtonOnClickHandler();
(_speechRecognition as SpeechRecognitionModule).isRuntimeDetection = value;
_speechRecognition.RecognitionSuccessEvent -= SpeechRecognizedSuccessEventHandler;
_speechRecognition.RecognitionFailedEvent -= SpeechRecognizedFailedEventHandler;
}
//private void ApplySpeechContextPhrases()
@@ -101,15 +95,15 @@ private void IsRuntimeDetectionOnValueChangedHandler(bool value)
// _speechRecognition.SetSpeechContext(phrases);
//}
private void SpeechRecognizedFailedEventHandler(string obj)
private void SpeechRecognizedFailedEventHandler(string obj, long l)
{
InformationMesh.text = "Speech Recognition failed with error: " + obj;
_audioSource.clip = FailSound;
_audioSource.Play();
Status = State.Stop;
}
private void SpeechRecognizedSuccessEventHandler(RecognitionResponse obj)
private void SpeechRecognizedSuccessEventHandler(RecognitionResponse obj, long l)
{
if (obj != null && obj.results.Length > 0)
{
@@ -146,17 +140,9 @@ private void SpeechReaction(RecognitionResponse obj)
_reactionManager.Action(obj);
}
private void StartRuntimeDetectionButtonOnClickHandler()
{
//ApplySpeechContextPhrases();
InformationMesh.text = "";
_speechRecognition.StartRuntimeRecord();
}
private void StopRuntimeDetectionButtonOnClickHandler()
{
_speechRecognition.StopRuntimeRecord();
_speechRecognition.StopRecord();
InformationMesh.text = "";
}
@@ -165,7 +151,7 @@ public void StartRecordButtonOnClickHandler()
if (Status == State.Stop)
{
InformationMesh.text = "";
_speechRecognition.StartRecord();
_speechRecognition.StartRecord(false);
Status = State.Recording;
}
}

0 comments on commit 6d1824a

Please sign in to comment.