You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Voice overlay** helps you turn your user's **voice** into **text**, providing a **polished UX** while handling for you the **necessary permission**.
8
11
9
-
**InstantSearch Insights Android** is supported on Android devices starting from SDK 14 (Ice Cream Sandwich) and is usable from both **Kotlin** and **Java** code.
12
+
<pfloat="left">
13
+
<imgsrc="./docs/permission.jpg"width="200" />
14
+
15
+
<imgsrc="./docs/listen.gif"width="200" />
16
+
17
+
<imgsrc="./docs/speak.gif"width="200" />
18
+
19
+
<imgsrc="./docs/nopermission.jpg"width="200" />
20
+
21
+
</p>
10
22
11
-
# Install
23
+
# Demo
12
24
13
-
Add `jCenter` to your repositories in `build.gradle`
25
+
You can clone this repo, then run the Demo project by doing `./gradlew app:installDebug` and launching the application:
14
26
15
-
```
16
-
allprojects {
17
-
repositories {
18
-
// [...]
19
-
jcenter()
20
-
}
21
-
}
22
-
```
27
+
<imgsrc="./docs/demo.gif"width="250">
28
+
29
+
# Installation
23
30
24
-
Add the following dependency to your `Gradle` file
31
+
The Voice overlay is available as a gradle dependency via [JCenter](https://bintray.com/bintray/jcenter). To install
32
+
it, add the following line to your app's `build.gradle`:
_See [it implemented in the demo app](app/src/main/kotlin/com/algolia/instantsearch/voice/demo/MainActivity.kt#L26-L30)._
55
+
56
+
This will display the permission dialog if the `RECORD_AUDIO` permission was not yet granted, then the voice input dialog once the permission is granted.
57
+
58
+
Once the user speaks, you will get their input back by implementing `VoiceSpeechRecognizer.ResultsListener`:
_See [it implemented in the demo app](app/src/main/kotlin/com/algolia/instantsearch/voice/demo/MainActivity.kt#L41-L43)._
66
+
67
+
## When the permission is not granted
68
+
69
+
If the user didn't accept the permission, you [should explain](https://developer.android.com/training/permissions/requesting#explain) the permission's rationale. If they deny the permission, you need to guide them into manually enabling it if they want to use the voice-input feature.
70
+
71
+
Voice overlay makes it easy to handle all these cases:
72
+
73
+
```groovy
74
+
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
<stringname="permission_enable_instructions">On the next screen, tap Permissions then Microphone.</string>
142
+
```
143
+
### Layouts
144
+
145
+
You can replace the voice overlay's layouts by your own, as long as they respect the following structure:
146
+
147
+
#### Permission
148
+
149
+
Create a layout called `voice_input.xml` with
150
+
- A `ViewGroup` container with id `@+id/voicePermission`
151
+
- A `View` with id `@+id/close` for closing the overlay when clicked
152
+
- A `TextView` with id `@+id/title`
153
+
- A `TextView` with id `@+id/subtitle`
154
+
155
+
#### Input
156
+
157
+
Create a layout called `voice_permission.xml` with
158
+
- A `ViewGroup` container with id `@+id/voiceInput`
159
+
- A `VoiceMicrophone` with id `@+id/microphone` to handle the voice input
160
+
- A `TextView` with id `@+id/suggestions` to display eventual suggestions
161
+
- A `View` with id `@+id/close` for closing the overlay when clicked
162
+
- A `TextView` with id `@+id/title`
163
+
- A `TextView` with id `@+id/subtitle`
164
+
- An eventual `TextView` with id `@+id/hint` to display a hint on error
165
+
- An eventual `RippleView` with id `@+id/ripple` if you want to keep the animation
166
+
35
167
## Getting Help
36
168
37
169
-**Need help**? Ask a question to the [Algolia Community](https://discourse.algolia.com/) or on [Stack Overflow](http://stackoverflow.com/questions/tagged/algolia).
@@ -41,11 +173,10 @@ dependencies {
41
173
42
174
## Getting involved
43
175
44
-
* If you **want to contribute** please feel free to **[submit pull requests](https://github.com/algolia/voice-overlay-android/pull/new)**.
45
-
* If you **have a feature request** please **[open an
* If you use **InstantSearch** in your app, we would love to hear about it! Drop us a line on [discourse](https://discourse.algolia.com/new-topic?title=InstantSearch%20Mobile%20App:&category_id=10&body=I%27m%20using%20InstantSearch%20for...) or [twitter](https://twitter.com/algolia).
176
+
* If you **want to contribute** please feel free to [**submit pull requests**](https://github.com/algolia/voice-overlay-android/pull/new).
177
+
* If you **have a feature request** please [**open an issue**](https://github.com/algolia/voice-overlay-android/issues/new).
178
+
* If you use the **Voice Overlay** in your app, we would love to hear about it! Drop us a line on [discourse](https://discourse.algolia.com/) or [twitter](https://twitter.com/algolia).
48
179
49
-
# License
180
+
##License
50
181
51
-
InstantSearch Android Voice is [MIT licensed](LICENSE.md).
182
+
The VoiceOverlay is available under the MIT license. See the [LICENSE file](./LICENSE) for more info.
0 commit comments