diff --git a/Assets/Plugins.meta b/Assets/Plugins.meta new file mode 100644 index 0000000..072bbaa --- /dev/null +++ b/Assets/Plugins.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e4abf5bfb7b83394ebf0c88fc54759f9 +folderAsset: yes +timeCreated: 1442947850 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Android.meta b/Assets/Plugins/Android.meta new file mode 100644 index 0000000..9861c99 --- /dev/null +++ b/Assets/Plugins/Android.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c09545e387c50874db2086d6b06b2a1c +folderAsset: yes +timeCreated: 1442947850 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Android/AndroidManifest.xml b/Assets/Plugins/Android/AndroidManifest.xml new file mode 100644 index 0000000..c80f70b --- /dev/null +++ b/Assets/Plugins/Android/AndroidManifest.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Assets/Plugins/Android/AndroidManifest.xml.meta b/Assets/Plugins/Android/AndroidManifest.xml.meta new file mode 100644 index 0000000..8d86a5d --- /dev/null +++ b/Assets/Plugins/Android/AndroidManifest.xml.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9a462ece95f547e47a1b71267f63d924 +timeCreated: 1442947850 +licenseType: Free +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Android/AndroidPlugin.jar b/Assets/Plugins/Android/AndroidPlugin.jar new file mode 100644 index 0000000..2974412 Binary files /dev/null and b/Assets/Plugins/Android/AndroidPlugin.jar differ diff --git a/Assets/Plugins/Android/AndroidPlugin.jar.meta b/Assets/Plugins/Android/AndroidPlugin.jar.meta new file mode 100644 index 0000000..0666d77 --- /dev/null +++ b/Assets/Plugins/Android/AndroidPlugin.jar.meta @@ -0,0 +1,16 @@ +fileFormatVersion: 2 +guid: 8b1e3c1800d04fb4b84e214cb8276ed1 +timeCreated: 1442947850 +licenseType: Free +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index ce781d5..833e92d 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -102,6 +102,10 @@ Prefab: propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size value: 1 objectReference: {fileID: 0} + - target: {fileID: 11466268, guid: 6506218ed7927bf45b508ebbec0c1222, type: 2} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size + value: 1 + objectReference: {fileID: 0} - target: {fileID: 22463624, guid: 6506218ed7927bf45b508ebbec0c1222, type: 2} propertyPath: m_LocalPosition.x value: 0 @@ -510,6 +514,18 @@ Prefab: propertyPath: m_Colors.m_NormalColor.b value: 1 objectReference: {fileID: 0} + - target: {fileID: 11466268, guid: 6506218ed7927bf45b508ebbec0c1222, type: 2} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 11466268, guid: 6506218ed7927bf45b508ebbec0c1222, type: 2} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_CallState + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 11466268, guid: 6506218ed7927bf45b508ebbec0c1222, type: 2} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target + value: + objectReference: {fileID: 578311380} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 6506218ed7927bf45b508ebbec0c1222, type: 2} m_IsPrefabParent: 0 diff --git a/Assets/Scripts/GenericPlayerManager.cs b/Assets/Scripts/GenericPlayerManager.cs index 7f2823f..77e9a6b 100644 --- a/Assets/Scripts/GenericPlayerManager.cs +++ b/Assets/Scripts/GenericPlayerManager.cs @@ -85,12 +85,15 @@ public abstract class GenericPlayerManager : MonoBehaviour { protected bool playing = false; protected bool paused = false; + protected VoiceRecognition voiceRecognizer; + public virtual void Start() { AVATAR = GameObject.FindGameObjectWithTag("avatar");//referencia para o avatar COMPONENT_ANIMATION = AVATAR.GetComponent();//referencia para o componente animador do avatar AVATAR_COLLIDER = GameObject.FindGameObjectWithTag("avatar").GetComponent(); Application.ExternalCall("onLoadPlayer");//var onLoadPlayer = function(){} + voiceRecognizer = new VoiceRecognition(); } public void SetAvatarCollider(bool isActive) diff --git a/Assets/Scripts/PlayerManager.cs b/Assets/Scripts/PlayerManager.cs index 61ce718..72b61b7 100644 --- a/Assets/Scripts/PlayerManager.cs +++ b/Assets/Scripts/PlayerManager.cs @@ -10,19 +10,21 @@ using System.IO; using System.Text; using System.Runtime.InteropServices; using UnityEngine.UI; -using System.Threading; public class PlayerManager : GenericPlayerManager { - -#if UNITY_IPHONE + +#if UNITY_EDITOR + private const string BASE_URL = "http://150.165.205.9/anims/ANDROID/"; +#endif + +#if UNITY_IPHONE && !UNITY_EDITOR private const string BASE_URL = "http://150.165.205.9/anims/IOS/"; #endif -#if UNITY_ANDROID +#if UNITY_ANDROID && !UNITY_EDITOR private const string BASE_URL = "http://150.165.205.9/anims/ANDROID/"; #endif - - private const string SERVER_URL = "http://vlibras.lavid.ufpb.br:5000/glosa?texto="; + private const string SERVER_URL = "http://vlibras.lavid.ufpb.br/glosa?texto="; public GameObject loading_snippet; @@ -93,7 +95,7 @@ public class PlayerManager : GenericPlayerManager { } } - protected string getGlosaFromServer(string str) + /*protected string getGlosaFromServer(string str) { string strToServer = ""; @@ -114,7 +116,7 @@ public class PlayerManager : GenericPlayerManager { Debug.Log("returned from server -> " + www.text); return www.text; - } + }*/ protected IEnumerator waitForRequest(WWW www) { @@ -126,4 +128,16 @@ public class PlayerManager : GenericPlayerManager { else Debug.Log("WWW Error: "+ www.error); } + + // Called from microphone icon at main interface + public void callVoiceRecognizer() + { + base.stop_animations(); + base.glosa = base.voiceRecognizer.callRecognition(); + + if(!base.glosa.Equals("")) + { + StartCoroutine(translate ()); + } + } } diff --git a/Assets/Scripts/VoiceRecognition.cs b/Assets/Scripts/VoiceRecognition.cs new file mode 100644 index 0000000..7adb3ae --- /dev/null +++ b/Assets/Scripts/VoiceRecognition.cs @@ -0,0 +1,81 @@ +/********************** +********LAVID********** +***VLibras Project***** +*------------------------------------------------------------------------ +*Description: +* +*This class needs an android plugin to call Google Speech API +*Before recognition, it verifies if there is internect connection. +*If there is no connection, the application doesn't run and shows an error message. +* +*--------------------------------------------------------------------------- +*Plugin directory: +* - Assets/Plugins/Android +*References: +* - http://docs.unity3d.com/ScriptReference/AndroidJavaClass.html +* - https://msdn.microsoft.com/pt-br/library/system.net.webclient(v=vs.110).aspx +* +*------------------------------------------------------------------------ +*Author: Claudiomar Araujo +*claudiomar.araujo@lavid.ufpb.br +***********************/ + +using UnityEngine; +using System.Collections; +using UnityEngine.UI; +using System.Net; +using System.IO; +using System; + +public class VoiceRecognition{ + + AndroidJavaClass unity; + AndroidJavaObject currentActivity; + WebClient client; + Stream stream; + string voiceText = ""; + + // Constructor + public VoiceRecognition() + { + #if !UNITY_EDITOR + unity = new AndroidJavaClass ("com.unity3d.player.UnityPlayer"); + + currentActivity = unity.GetStatic ("currentActivity"); + #endif + } + + // Calls Google Speech from plugin method and returns recognized text + public string callRecognition() + { + if (checkConnection()) { // Runs only with internet connection + voiceText = currentActivity.Call ("callGoogleSpeech"); + } + return voiceText; + } + + // Tries a requisition with an specific url + public bool checkConnection() + { + client = new WebClient(); + stream = client.OpenRead("http://www.google.com"); + + return closeConnection (); + } + + // Returns the result of checkConnection's requisition + bool closeConnection() + { + // Requisition OK + if (stream != null) + { + stream.Close (); + client = null; + return true; + } + else // Requisition NOT OK + { + return false; + } + } +} diff --git a/Assets/Scripts/VoiceRecognition.cs.meta b/Assets/Scripts/VoiceRecognition.cs.meta new file mode 100644 index 0000000..35d4502 --- /dev/null +++ b/Assets/Scripts/VoiceRecognition.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c7b25ca3c0524de4d9528663de8bb2e3 +timeCreated: 1442945000 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 8c353d8..78b2941 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 5.1.2f1 +m_EditorVersion: 5.1.1f1 m_StandardAssetsVersion: 0 -- libgit2 0.21.2