Commit 8222cfc99f132b59d9a757e7d9647fe37a4c7c29
1 parent
b356f6cf
Exists in
master
and in
8 other branches
Adicionado reconhecimento de voz
Showing
12 changed files
with
193 additions
and
9 deletions
Show diff stats
... | ... | @@ -0,0 +1,16 @@ |
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + package="com.lavid.vlibrasdroid" | |
4 | + android:versionCode="1" | |
5 | + android:versionName="1.0"> | |
6 | + <uses-sdk android:minSdkVersion="14" /> | |
7 | + <application android:label="@string/app_name"> | |
8 | + <activity android:name=".MainActivity" | |
9 | + android:label="@string/app_name"> | |
10 | + <intent-filter> | |
11 | + <action android:name="android.intent.action.MAIN" /> | |
12 | + <category android:name="android.intent.category.LAUNCHER" /> | |
13 | + </intent-filter> | |
14 | + </activity> | |
15 | + </application> | |
16 | +</manifest> | |
0 | 17 | \ No newline at end of file | ... | ... |
No preview for this file type
... | ... | @@ -0,0 +1,16 @@ |
1 | +fileFormatVersion: 2 | |
2 | +guid: 8b1e3c1800d04fb4b84e214cb8276ed1 | |
3 | +timeCreated: 1442947850 | |
4 | +licenseType: Free | |
5 | +PluginImporter: | |
6 | + serializedVersion: 1 | |
7 | + iconMap: {} | |
8 | + executionOrder: {} | |
9 | + isPreloaded: 0 | |
10 | + platformData: | |
11 | + Any: | |
12 | + enabled: 1 | |
13 | + settings: {} | |
14 | + userData: | |
15 | + assetBundleName: | |
16 | + assetBundleVariant: | ... | ... |
Assets/Scenes/Main.unity
... | ... | @@ -102,6 +102,10 @@ Prefab: |
102 | 102 | propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size |
103 | 103 | value: 1 |
104 | 104 | objectReference: {fileID: 0} |
105 | + - target: {fileID: 11466268, guid: 6506218ed7927bf45b508ebbec0c1222, type: 2} | |
106 | + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size | |
107 | + value: 1 | |
108 | + objectReference: {fileID: 0} | |
105 | 109 | - target: {fileID: 22463624, guid: 6506218ed7927bf45b508ebbec0c1222, type: 2} |
106 | 110 | propertyPath: m_LocalPosition.x |
107 | 111 | value: 0 |
... | ... | @@ -510,6 +514,18 @@ Prefab: |
510 | 514 | propertyPath: m_Colors.m_NormalColor.b |
511 | 515 | value: 1 |
512 | 516 | objectReference: {fileID: 0} |
517 | + - target: {fileID: 11466268, guid: 6506218ed7927bf45b508ebbec0c1222, type: 2} | |
518 | + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode | |
519 | + value: 1 | |
520 | + objectReference: {fileID: 0} | |
521 | + - target: {fileID: 11466268, guid: 6506218ed7927bf45b508ebbec0c1222, type: 2} | |
522 | + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_CallState | |
523 | + value: 2 | |
524 | + objectReference: {fileID: 0} | |
525 | + - target: {fileID: 11466268, guid: 6506218ed7927bf45b508ebbec0c1222, type: 2} | |
526 | + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target | |
527 | + value: | |
528 | + objectReference: {fileID: 578311380} | |
513 | 529 | m_RemovedComponents: [] |
514 | 530 | m_ParentPrefab: {fileID: 100100000, guid: 6506218ed7927bf45b508ebbec0c1222, type: 2} |
515 | 531 | m_IsPrefabParent: 0 | ... | ... |
Assets/Scripts/GenericPlayerManager.cs
... | ... | @@ -85,12 +85,15 @@ public abstract class GenericPlayerManager : MonoBehaviour { |
85 | 85 | protected bool playing = false; |
86 | 86 | protected bool paused = false; |
87 | 87 | |
88 | + protected VoiceRecognition voiceRecognizer; | |
89 | + | |
88 | 90 | public virtual void Start() |
89 | 91 | { |
90 | 92 | AVATAR = GameObject.FindGameObjectWithTag("avatar");//referencia para o avatar |
91 | 93 | COMPONENT_ANIMATION = AVATAR.GetComponent<Animation>();//referencia para o componente animador do avatar |
92 | 94 | AVATAR_COLLIDER = GameObject.FindGameObjectWithTag("avatar").GetComponent<BoxCollider>(); |
93 | 95 | Application.ExternalCall("onLoadPlayer");//var onLoadPlayer = function(){} |
96 | + voiceRecognizer = new VoiceRecognition(); | |
94 | 97 | } |
95 | 98 | |
96 | 99 | public void SetAvatarCollider(bool isActive) | ... | ... |
Assets/Scripts/PlayerManager.cs
... | ... | @@ -10,19 +10,21 @@ using System.IO; |
10 | 10 | using System.Text; |
11 | 11 | using System.Runtime.InteropServices; |
12 | 12 | using UnityEngine.UI; |
13 | -using System.Threading; | |
14 | 13 | |
15 | 14 | public class PlayerManager : GenericPlayerManager { |
16 | - | |
17 | -#if UNITY_IPHONE | |
15 | + | |
16 | +#if UNITY_EDITOR | |
17 | + private const string BASE_URL = "http://150.165.205.9/anims/ANDROID/"; | |
18 | +#endif | |
19 | + | |
20 | +#if UNITY_IPHONE && !UNITY_EDITOR | |
18 | 21 | private const string BASE_URL = "http://150.165.205.9/anims/IOS/"; |
19 | 22 | #endif |
20 | 23 | |
21 | -#if UNITY_ANDROID | |
24 | +#if UNITY_ANDROID && !UNITY_EDITOR | |
22 | 25 | private const string BASE_URL = "http://150.165.205.9/anims/ANDROID/"; |
23 | 26 | #endif |
24 | - | |
25 | - private const string SERVER_URL = "http://vlibras.lavid.ufpb.br:5000/glosa?texto="; | |
27 | + private const string SERVER_URL = "http://vlibras.lavid.ufpb.br/glosa?texto="; | |
26 | 28 | |
27 | 29 | public GameObject loading_snippet; |
28 | 30 | |
... | ... | @@ -93,7 +95,7 @@ public class PlayerManager : GenericPlayerManager { |
93 | 95 | } |
94 | 96 | } |
95 | 97 | |
96 | - protected string getGlosaFromServer(string str) | |
98 | + /*protected string getGlosaFromServer(string str) | |
97 | 99 | { |
98 | 100 | string strToServer = ""; |
99 | 101 | |
... | ... | @@ -114,7 +116,7 @@ public class PlayerManager : GenericPlayerManager { |
114 | 116 | |
115 | 117 | Debug.Log("returned from server -> " + www.text); |
116 | 118 | return www.text; |
117 | - } | |
119 | + }*/ | |
118 | 120 | |
119 | 121 | protected IEnumerator waitForRequest(WWW www) |
120 | 122 | { |
... | ... | @@ -126,4 +128,16 @@ public class PlayerManager : GenericPlayerManager { |
126 | 128 | else |
127 | 129 | Debug.Log("WWW Error: "+ www.error); |
128 | 130 | } |
131 | + | |
132 | + // Called from microphone icon at main interface | |
133 | + public void callVoiceRecognizer() | |
134 | + { | |
135 | + base.stop_animations(); | |
136 | + base.glosa = base.voiceRecognizer.callRecognition(); | |
137 | + | |
138 | + if(!base.glosa.Equals("")) | |
139 | + { | |
140 | + StartCoroutine(translate ()); | |
141 | + } | |
142 | + } | |
129 | 143 | } | ... | ... |
... | ... | @@ -0,0 +1,81 @@ |
1 | +/********************** | |
2 | +********LAVID********** | |
3 | +***VLibras Project***** | |
4 | +*------------------------------------------------------------------------ | |
5 | +*Description: | |
6 | +* | |
7 | +*This class needs an android plugin to call Google Speech API | |
8 | +*Before recognition, it verifies if there is internect connection. | |
9 | +*If there is no connection, the application doesn't run and shows an error message. | |
10 | +* | |
11 | +*--------------------------------------------------------------------------- | |
12 | +*Plugin directory: | |
13 | +* - Assets/Plugins/Android | |
14 | +*References: | |
15 | +* - http://docs.unity3d.com/ScriptReference/AndroidJavaClass.html | |
16 | +* - https://msdn.microsoft.com/pt-br/library/system.net.webclient(v=vs.110).aspx | |
17 | +* | |
18 | +*------------------------------------------------------------------------ | |
19 | +*Author: Claudiomar Araujo | |
20 | +*claudiomar.araujo@lavid.ufpb.br | |
21 | +***********************/ | |
22 | + | |
23 | +using UnityEngine; | |
24 | +using System.Collections; | |
25 | +using UnityEngine.UI; | |
26 | +using System.Net; | |
27 | +using System.IO; | |
28 | +using System; | |
29 | + | |
30 | +public class VoiceRecognition{ | |
31 | + | |
32 | + AndroidJavaClass unity; | |
33 | + AndroidJavaObject currentActivity; | |
34 | + WebClient client; | |
35 | + Stream stream; | |
36 | + string voiceText = ""; | |
37 | + | |
38 | + // Constructor | |
39 | + public VoiceRecognition() | |
40 | + { | |
41 | + #if !UNITY_EDITOR | |
42 | + unity = new AndroidJavaClass ("com.unity3d.player.UnityPlayer"); | |
43 | + | |
44 | + currentActivity = unity.GetStatic<AndroidJavaObject> ("currentActivity"); | |
45 | + #endif | |
46 | + } | |
47 | + | |
48 | + // Calls Google Speech from plugin method and returns recognized text | |
49 | + public string callRecognition() | |
50 | + { | |
51 | + if (checkConnection()) { // Runs only with internet connection | |
52 | + voiceText = currentActivity.Call<string> ("callGoogleSpeech"); | |
53 | + } | |
54 | + return voiceText; | |
55 | + } | |
56 | + | |
57 | + // Tries a requisition with an specific url | |
58 | + public bool checkConnection() | |
59 | + { | |
60 | + client = new WebClient(); | |
61 | + stream = client.OpenRead("http://www.google.com"); | |
62 | + | |
63 | + return closeConnection (); | |
64 | + } | |
65 | + | |
66 | + // Returns the result of checkConnection's requisition | |
67 | + bool closeConnection() | |
68 | + { | |
69 | + // Requisition OK | |
70 | + if (stream != null) | |
71 | + { | |
72 | + stream.Close (); | |
73 | + client = null; | |
74 | + return true; | |
75 | + } | |
76 | + else // Requisition NOT OK | |
77 | + { | |
78 | + return false; | |
79 | + } | |
80 | + } | |
81 | +} | ... | ... |
... | ... | @@ -0,0 +1,12 @@ |
1 | +fileFormatVersion: 2 | |
2 | +guid: c7b25ca3c0524de4d9528663de8bb2e3 | |
3 | +timeCreated: 1442945000 | |
4 | +licenseType: Free | |
5 | +MonoImporter: | |
6 | + serializedVersion: 2 | |
7 | + defaultReferences: [] | |
8 | + executionOrder: 0 | |
9 | + icon: {instanceID: 0} | |
10 | + userData: | |
11 | + assetBundleName: | |
12 | + assetBundleVariant: | ... | ... |
ProjectSettings/ProjectVersion.txt