Giter Club home page Giter Club logo

unityandroidspeechrecognition's Introduction

UnityAndroidSpeechRecognition

This repository is a Unity plugin for Android Speech Recognition (based on Java implementation). This is just a basic implementation which uses the inbuilt Android Speech Recognition. I have implemented some additional functions to give some basic functionality.

Features

  • Set Recognition Language
  • Set the max number of results
  • Set the prompt question

Usage

  • You can first test out the SpeechRecognition.apk from here. You need a minimum of Android Lollipop (API Level 21) to use this apk.
  • Next, import SpeechRecognition.unitypackage into your Unity project. (Tested latest on Unity 2018.1.0f2)
  • To include SpeechReconginition in your own project copy the contents of Plugins/Android/ into the same folder in your project and have a look at Test.cs and ReceiveResult.cs for an example usage. Test.cs has function for calling the speech recognition popoup whereas ReceiveResult.cs has function which receives the recognized text.
  • When you press the button, a speech recognition itent should pop up. This intent sends the recognized text to 'void onActivityResult(string recognizedText)' function of the object 'Main Camera' (You can change the object to which ReceiveResult.cs should be attached by changing the object name in Test.cs. The default return object is set to 'Main Camera').
  • You can change the following line pluginClass.CallStatic("setLanguage", "en_US") in Test.cs to change the language. A list of languages along with their tags is present in the languages.txt file. This file is not exhaustive.
  • Similarly you can also manipulate other features like maximum number of results etc (In case of the max number of results, this is literally maximum and the number of results you get may not always be this number, but it would be definitely less than this number).

Experimenting

  • You can import SpeechPlugin to Android Studio to experiment with it (pluginlibrary module is only important).
  • Once you make changes and build the module you should have a pluginlibrary-release.aar file in SpeechPlugin/pluginlibrary/build/outputs/aar folder. Rename this to speechassist-debug.zip and then unzip it. On unzipping you will get a classes.jar file which you will have to copy into Plugins/Android folder in Unity along with the AndroidManifest.xml. The manifest specifies the activity class which extends the UnityPlayerActivity and hence is necessary. If you already have a manifest in plugins folder, I would recommend against copying this manifest as it can cause confilict. Instead, you can modify the manifest which you already have to specify the activity class which extends the UnityPlayerActivity.
  • One more thing to observe is that I have classes.jar in my libs folder of my AndroidStudio project. Have a look at this post to know where you can find it.

Note

  • I have extended UnityPlayerActivity with my custom activity and forced to subsitute it by changing the manifest file. Though, this works it is undesirable when you want to make/use multiple plugins. An ideal way would be to create a custom activity that will be short-lived and its sole purpose would be to get created, do the job (user picks photo from gallery e.g.), deliver result (picked image) into onActivityResult and terminate itself. Please refer this post for more details on this approach. I will update the plugin once I have more free time.

  • On experiencing a problem, feel free to create an issue.

  • If you want any additional features too, feel free to create an issue.

unityandroidspeechrecognition's People

Contributors

gsssrao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unityandroidspeechrecognition's Issues

Combining multiple plug-ins

Hi,

We are trying to integrate your code with Google Tango, which means there are two plugins. Combining the two manifest files has failed and the mentioned resources did also not work. Do you happen to already fixed this issue or do you have some markers on it?

How to remove Google popup

Hi,
Thank you so much for this as a free. It's working awesome but I need your help to resolve my issue.
I want to remove or hide google popup when it's started recording.
Is there any solution.
Thanks in advance
Sweetan M

Add feature

I don't just want to recognize words but also perform certain activities on the game object. Can you please tell me what I need to do for that? Example: roll a ball should roll the ball in my scene

Support for android 4?

Hi, thanks for your amazing plugin. I just have a problem. What do I need to do to make it work on android 4 too?

Build Failure: Multiple dex files define Lcom/example/speechassist/BuildConfig

Hey, many thanks for open sourcing this! I tried creating a new project in Unity 2018, imported your plugin, set my bundle name, set min sdk to 21 and target sdk to 23, and pressed build. Unfortunately I get this error:

Build failure: com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/example/speechassist/BuildConfig; See the Console for details.

Any idea what this could be due to? Many thanks

Not working! when I press the button nothing happened

When I installed the app, no permission is asked for the microphone, I only followed your guide, I downloaded the package and used test.cs and receiveRequest.cs should I add extra things? like manually ask for permission if yes what should I write?

Error on playing in unity editor!!

Exception: JNI: Init'd AndroidJavaClass with null ptr!
UnityEngine.AndroidJavaClass..ctor (IntPtr jclass) (at C:/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:622)
UnityEngine.AndroidJavaObject.get_JavaLangClass () (at C:/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:600)
UnityEngine.AndroidJavaObject.FindClass (System.String name) (at C:/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:591)
UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) (at C:/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:611)
UnityEngine.AndroidJavaClass..ctor (System.String className) (at C:/buildslave/unity/build/artifacts/generated/bindings_old/common/Core/AndroidJavaBindings.gen.cs:92)
Test.TaskOnClick () (at Assets/Test.cs:17)
UnityEngine.Events.InvokableCall.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:166)
UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:58)
UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:36)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:45)
UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:261)
UnityEngine.EventSystems.EventSystem:Update()

Unable to include code into Unity Project

Hi, first off, thanks form making this public.

I have what it must be a very simple problem, my Unity project doesn't work after importing SpeechRecognition.unitypackage, using Unity 5.3.3f1, on Win 7 64bits, and running the apk in a Samsug Galaxy S5 running Android 5.0. The first thing to mention is that your apk works wondeful on it own, but:

  1. If I run my apk (your unitypackage imported into my project), it crashes, shows the default Unity splash for just 1 sec, besides is strange that the splash looks not centered and that the app icon is lost and replaced by the default Android icon.
  2. If I delete AndroidManifest.xml file from the project and compile again, the apk loads successfully, so I'm able to click the "speak button", then the google api window shows up, I'm able to speak, my speech is "recognized" as the google api window closes, BUT... no words are shown on 'TextRecognition' UI Text component, seems that by deleting the xml file, I broke the possibility that the callback method onActivityResult() gets called. Though at least my app doesn't crash and my app icon is back again!

I'm a good C# programmer and been using Unity for more than two years, but dealing with Android api classes and xml manifest files is beyond my knowledge, so far now.

Any help would be apprecciated.

Regards,
Rodrigo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.