Skip to content

Commit a1e5d55

Browse files
authored
Update Readme.md
1 parent 911dd73 commit a1e5d55

File tree

1 file changed

+69
-9
lines changed

1 file changed

+69
-9
lines changed

README.md

Lines changed: 69 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,87 @@ If you like my general work and contributions consider [sponsoring me on Github]
3030

3131
But if you just want to donate straightforward, I also have [PayPal.me](https://paypal.me/EricBatlleClavero?locale.x=es_ES).
3232

33-
## How to Use ⚙️
33+
## How to Install :hammer_and_wrench:
34+
35+
- If you want to install the the app, you can download the APK from [here](https://github.com/EricBatlle/UnityAndroidSpeechRecognizer/releases/download/v1.3/SpeechRecognizer_1.3.apk).
3436

35-
If you want to test the app, you can download the APK from [here](https://github.com/EricBatlle/UnityAndroidSpeechRecognizer/releases/download/v1.2/SpeechRecognizer_1.2.apk).
37+
- If you want to install the whole project and check the code, you need to have **Unity** and **AndroidStudio** installed and updated.
3638

37-
If you want to open the project and check the code, you need to have **Unity** and **AndroidStudio** installed and updated.
39+
- If you want to install only the few files to make the plugin work and don't want the whole project, you only need to import the package **SpeechRecognizer_pckg** located inside ``UnitySpeechRecognizer/Assets/``. To import it simply drag and drop the file in your current Unity project.
3840

39-
If you want to scratch the code:
41+
## How to Use ⚙️
4042

43+
#### How to use the Demo:
44+
- Functionality is simple, just press the **Start Listening button** and talk to your device to check the results!
45+
- If you want to enable/disable continuous listening mode simply press the **Continous Listening checkmark**.
46+
- You can also stop the current recongizer by pressing the **Stop Listening button**.
47+
- Set the language of the recognizer or the maximum results you want that the recognizer retrieves.
48+
49+
#### How to use the Plugin:
50+
51+
To call the plugin you first need a variable to reference it:
52+
```csharp
53+
private SpeechRecognizerPlugin plugin = null;
54+
```
55+
Then you have to create a new platform-specific instance by calling:
56+
```csharp
57+
plugin = SpeechRecognizerPlugin.GetPlatformPluginVersion(this.gameObject.name);
58+
```
59+
Notice that ``this.gameObject.name`` is the name of the GameObject that will have the plugin callback methods to retrieve the recognition results and errors.
60+
To create those callbacks you need to add and implement the Interface ```ISpeechRecognizerPlugin``` on the same GameObject. A common implementation of the interface will be:
61+
```csharp
62+
public void OnResult(string recognizedResult)
63+
{
64+
char[] delimiterChars = { '~' };
65+
string[] results = recognizedResult.Split(delimiterChars);
66+
67+
//Do something with the results
68+
}
69+
70+
public void OnError(string recognizedError)
71+
{
72+
ERROR error = (ERROR)int.Parse(recognizedError);
73+
switch (error)
74+
{
75+
case ERROR.UNKNOWN:
76+
Debug.Log("<b>ERROR: </b> Unknown");
77+
break;
78+
case ERROR.INVALID_LANGUAGE_FORMAT:
79+
Debug.Log("<b>ERROR: </b> Language format is not valid");
80+
break;
81+
default:
82+
break;
83+
}
84+
}
85+
```
86+
From so on every time you want to call any plugin feature you only have to call it like any other object:
87+
88+
Do you want to start the recognition?
89+
```csharp
90+
plugin.StartListening();
91+
```
92+
Do you want to stop it?
93+
```csharp
94+
plugin.StopListening();
95+
```
96+
Do you want to start the recognition with continous recognition and specific language?
97+
```csharp
98+
plugin.StartListening(true, "es-ES");
99+
```
100+
101+
#### How to scratch the code:
41102
- To check **Unity** project, **open the project**, select **SpeechRecognizer** scene.
42103
Either inside the unity project or simply dragging the **.cs** classes on your editor, you have to watch on to the classes located on ``UnitySpeechRecognizer/Assets/Scripts``.
43104
- To check **Android Plugin** you can do it opening the solution with **AndroidStudio** or just drag the ``SpeechRecognizerFragment.java`` class located on ``UnitySpeechRecognizerPlugin\SpeechRecognizer\src\main\java\com\example\eric\unityspeechrecognizerplugin``
44105

45-
Functionality is simple, just press the checkmark if you want to enable/disable continuous listening mode, press Start listening and talk to your device to check the results!
46106

47-
#### Multiple plugins support 🔌
107+
## Multiple plugins support 🔌
48108
This plugin has been made following a **fragment-pattern** to avoid errors that can be derived from extending *UnityPlayerActivity*.
49109

50110
This way you can integrate this plugin with your projects even if they already have more plugins. **Truly pluggable**.
51111

52-
#### Upgrading dependencies 📜
112+
## Upgrading dependencies 📜
53113

54-
Keep in mind that the actual release ([v1.2](https://github.com/EricBatlle/UnityAndroidSpeechRecognizer/releases/tag/v1.2)) of the plugin works with **AndroidX** dependencies. That means that is targeting **Android 9** (API level 28).
114+
Keep in mind that the actual release ([v1.3](https://github.com/EricBatlle/UnityAndroidSpeechRecognizer/releases/tag/v1.3)) of the plugin works with **AndroidX** dependencies. That means that is targeting **Android 9** (API level 28).
55115

56-
If you want to target older versions I recommend to use the old version of the plugin ([v1.0]((https://github.com/EricBatlle/UnityAndroidSpeechRecognizer/releases/tag/v1.0))) that works with **Android Support v4**. You can download the old plugin source code and APK from [here](https://github.com/EricBatlle/UnityAndroidSpeechRecognizer/releases/tag/v1.0).
116+
If you want to target older versions I recommend to use the old version of the plugin ([v1.0]((https://github.com/EricBatlle/UnityAndroidSpeechRecognizer/releases/tag/v1.0))) that works with **Android Support v4**. *But remember that some features like specify recognition language aren't available for the moment.* You can download the old plugin source code and APK from [here](https://github.com/EricBatlle/UnityAndroidSpeechRecognizer/releases/tag/v1.0).

0 commit comments

Comments
 (0)