11# Conversational Flow Component - Android
22
3- | | TYPE | VERSION | STATUS | COVERAGE |
4- | --------------------------- | :-------: | ---------------------- | -------------------- | :--------: |
5- | ` conversational-flow-core ` | _ core_ | ![ Latest version] [ i1 ] | ![ Build Status] [ i4 ] | 0% |
6- | ` addon-android-speech ` | _ addon_ | ![ Latest version] [ i2 ] | ![ Build Status] [ i5 ] | 0% |
7- | ` addon-google-speech ` | _ addon_ | ![ Latest version] [ i3 ] | ![ Build Status] [ i6 ] | 0% |
3+ | | TYPE | VERSION | STATUS | COVERAGE |
4+ | --------------------------- | :-------: | ---------------------- | -------------------- | :----------------------: |
5+ | ` conversational-flow-core ` | _ core_ | ![ Latest version] [ i1 ] | ![ Build Status] [ i4 ] | ![ Coverage Status ] [ i7 ] |
6+ | ` addon-android-speech ` | _ addon_ | ![ Latest version] [ i2 ] | ![ Build Status] [ i5 ] | ![ Coverage Status ] [ i8 ] |
7+ | ` addon-google-speech ` | _ addon_ | ![ Latest version] [ i3 ] | ![ Build Status] [ i6 ] | ![ Coverage Status ] [ i9 ] |
88
99
10- Part of the [ Voice User Interaction SDK] ( ) .
10+ Part of the [ Voice & User Interaction SDK] ( ) .
1111
1212The library wraps and combines single platform resources and builds
13- a _ Software Component_ capable of create a communication flow between a devices and a user with ease.
13+ a _ Software Component_ capable of create a communication flow between a device and a user with ease.
1414
15- Besides, it also lets you choose between the following providers:
16- like Android, Google Cloud,
17- (Amazon, Wit.ai, Temi, Bing Speech, IBM, ...)
15+ Besides, it comes the following providers:
1816
1917- [ Built-in Android] ( https://developers.google.com/voice-actions/interaction/voice-interactions ) (default)
2018 - [ TextToSpeech] ( https://developer.android.com/reference/android/speech/tts/TextToSpeech )
2119 - [ SpeechRecognizer] ( https://developer.android.com/reference/android/speech/SpeechRecognizer )
2220- [ Google Cloud] ( https://cloud.google.com/ )
2321 - [ Speech-To-Text] ( https://cloud.google.com/speech-to-text/ )
2422 - [ Text-To-Speech] ( https://cloud.google.com/text-to-speech/ )
23+
24+ like Android, Google Cloud,
25+ (Amazon, Wit.ai, Temi, Bing Speech, IBM, ...)
2526
2627<p align =" center " ><img src =" assets/demo-sample.jpg " alt =" demo-sample " /></p >
2728
2829## Why choosing this library?
2930
30- The ** Conversational Flow Component** is based on [ Directed Graph] ( https://en.wikipedia.org/wiki/Directed_graph )
31+ The ** Conversational Flow Component** is based on a [ Directed Graph] ( https://en.wikipedia.org/wiki/Directed_graph )
3132which also allows [ Directed Cycles] ( https://en.wikipedia.org/wiki/Cycle_(graph_theory) )
32- to create connected nodes that build a consistent flow.
33+ to create connected nodes that build a consistent conversation flow. ** Consistent** here means that you won't need
34+ to code the flow using conditional statements or add any extra complexity if you don't want.
3335
34- Some devices don't have configured the resources you need to run a conversation in your app,
35- a developer needs to learn and test quite a lot before even to start coding for voice capabilities, noise is impacting
36- considerably the communication, android components force you to create a lot of boilerplate, some countries don't
37- allow Google Play Services, etc.
36+ This library helps you when:
37+ - some devices don't have configured the resources you need to run a conversation in your app
38+ - a developer needs to learn and test quite a lot before even to start coding for voice capabilities
39+ - noise is impacting considerably the communication
40+ - android components force you to create a lot of boilerplate
41+ - some countries don't allow Google Play Services
42+ - etc.
3843
39- This library helps you on all these aspects and more.
40-
4144
4245## Prerequisites
4346The SDK works on Android version 5.0 (Lollipop) and above. _ (for lower versions [ contact us] ( mailto:hello@chattylabs.com ) )_
4447
4548## Setup
4649Add the following code to your gradle file.
4750
48- ``` groovy
49- repositories {
50- maven { url "https://dl.bintray.com/chattylabs/maven" }
51- }
52-
53- dependencies {
54- // Required
55- implementation 'com.chattylabs.sdk.android:conversational-flow-core:x.y.z'
56- // You can either use only one or combine addons
57- implementation 'com.chattylabs.sdk.android:addon-android-speech:x.y.z'
58- implementation 'com.chattylabs.sdk.android:addon-google-speech:x.y.z'
59- }
60- ```
51+
52+ repositories {
53+ maven { url "https://dl.bintray.com/chattylabs/maven" }
54+ }
55+
56+ dependencies {
57+ // Required
58+ implementation 'com.chattylabs.sdk.android:conversational-flow-core:x.y.z'
59+
60+ // You can either use only one or combine addon features
61+ // i.e. use the Synthesizer of Google but the Recognizer of Android
62+ implementation 'com.chattylabs.sdk.android:addon-android-speech:x.y.z'
63+ implementation 'com.chattylabs.sdk.android:addon-google-speech:x.y.z'
64+ }
65+
6166
6267## Usage
6368
6469If you use [ Dagger 2] ( https://google.github.io/dagger/ ) in your project,
65- you can provide the current ` ConversationalFlowComponent ` instance if you add the ` ConversationalFlowModule.class `
66- as a module item into your dagger component graph.
70+ you can provide the current ` ConversationalFlowComponent ` instance by applying the ` ConversationalFlowModule.class `
71+ to your dagger component graph.
6772
6873``` java
6974@dagger.Component ( modules = { ConversationalFlowModule . class } )
7075
7176// ...
7277
73- @Inject ConversationalFlowComponent conversationalFlowComponent ;
78+ @Inject ConversationalFlowComponent component ;
7479```
7580
76- If you don't user ` Dagger 2 ` , then you can retrieve an instance using:
81+ If you don't user [ Dagger 2] ( https://google.github.io/dagger/ ) , then you can retrieve an instance using:
7782
7883``` java
79- conversationalFlowComponent = ConversationalFlowModule . provideComponent(new ILoggerImpl ());
84+ component = ConversationalFlowModule . provideComponent(new ILoggerImpl ());
8085```
8186
82- By default, the library sets up the built-in Android addon,
83- so you must at least import the ` addon-android-speech ` dependency.
84- Afterwards, you won't need to configure anything else, although you could still setup a new configuration
85- or update some changes on the current one at anytime.
87+ Remember that you have to import at least one of the ` addon ` dependencies and configure
88+ which component you will be using.
8689
8790``` java
88- // Optional
89- conversationalFlowComponent. updateConfiguration(
90- builder - > builder. setBluetoothScoRequired(() - > preferences. connectToBluetoothSco()). build());
91+ component. updateConfiguration(builder - >
92+ builder .setRecognizerServiceType(() - > AndroidSpeechRecognizer . class)
93+ .setSynthesizerServiceType(() - > AndroidSpeechSynthesizer . class). build());
94+
95+ component. setup(
96+ context, status - > {
97+ if (status. isAvailable()) {
98+ // start using the functionality
99+ }
100+ });
91101```
92102
93- The config builder is based on a ` LazyProvider ` interface.
94- This is helpful for example with [ SharedPreferences] ( ) where the values can change anytime according
95- to user preferences.
103+ The configuration builder is based on a ` LazyProvider ` interface.
104+ <br />This is helpful for instance with [ SharedPreferences] ( ) , where the values can change anytime according
105+ to user preferences. By providing with the ` LazyProvider ` once, you don't need to run ` updateConfiguration() `
106+ and ` setup() ` again.
96107
97108[ Learn more] ( ) about the configurations you can set up.
98109
99110### Create a Conversation
100111
101112You can use the ` ConversationalFlowComponent ` at any context level, both in an Activity and a Service.
102113
103- To create a conversation between the user and your app, you will create a set of ` VoiceNode ` objects and build a flow with them.
114+ To create a conversation between the user and your app, you will create a set of ` VoiceNode ` objects
115+ and build a flow.
104116
105117Retrieve a new instance of ` Conversation ` .
106118
107119``` java
108- Conversation conversation = conversationalFlowComponent . create(context);
120+ Conversation conversation = component . create(context);
109121```
110122
111- Create the message and action nodes you expect to use during the conversation.
123+ Create the various message and action nodes you expect to use during the conversation.
112124
113125``` java
114- // We create the initial message node.
126+ // We create an initial message node.
115127VoiceMessage question = VoiceMessage . newBuilder(). setText(" Do you need help?" ). build();
116128
117- // We define the expected replies from the user.
129+ // We define what we expect from the user.
118130String [] expected = new String []{ " Yes" , " I think so" , " Sure" };
131+
132+ // We create a node that handles what the user said
119133VoiceMatch answers = VoiceMatch . newBuilder(). setExpectedResults(expected)
120- .setOnMatch(results - > conversation:: next)
121- .build();
134+ .setOnMatch(results - > conversation:: next). build();
135+
136+ // We can create more nodes to check for not matched results and so on...
137+ // We also can automate the creation on a for loop from a Json File.
138+ // Check the sample demos!
122139```
123140
124- Now add the nodes into the current instance.
141+ Now add these nodes into the current ` Conversation ` instance.
125142
126143``` java
127144conversation. addNode(question);
@@ -132,8 +149,7 @@ Connect the nodes and start the conversation.
132149
133150``` java
134151Flow flow = conversation. prepare();
135- flow. from(question). to(replies);
136- // ...
152+ flow. from(question). to(answers);
137153
138154// Start the conversation out loud!
139155conversation. start(question);
@@ -142,23 +158,14 @@ conversation.start(question);
142158This is a simple example of the capabilities of the ** Conversational Flow Component** .
143159<br />There are several configurations and listeners you can apply to each node, and different node types to use.
144160
145- For instance, you could make a ` VoiceMessage ` and then collect a ` VoiceCapture ` from the user,
146- or perhaps create multiple ` VoiceAction ` and connect them to different ` VoiceMessage ` responses
147- and even to other ` VoiceAction ` nodes.
161+ For instance, you could play a ` VoiceMessage ` and then collect a ` VoiceCapture ` from the user,
162+ or perhaps create multiple expected ` VoiceAction ` s and connect them to different ` VoiceMessage ` s.
148163
149164<p align =" center " ><img src =" assets/demo-sample.jpg " alt =" demo-sample " /></p >
150165
151166Take a look at the wiki page to [ learn more] ( ) .
152167
153- ## Running the Demo
154- After you have cloned this project, run the following command on a terminal console.
155- <br />This will retrieve and update the project's build system.
156-
157- ``` bash
158- git submodule update --init
159- ```
160-
161- ## Whose use this library?
168+ ## Who uses this library?
162169This is a list of Apps using the library:
163170
164171<a href =" https://play.google.com/store/apps/details?id=com.Chatty " ><img src =" https://lh3.googleusercontent.com/BwP_HPbu2G523jUQitRcfgADe5qKxZclxAbESmM4xaTNFS3ckz5uqkh12OimzqPC=s50-rw " alt =" Chatty " title =" Chatty " />   ;  ;
@@ -170,4 +177,8 @@ This is a list of Apps using the library:
170177
171178[ i4 ] : https://app.bitrise.io/app/ad178a030b96de53/status.svg?token=Om0YDuYQ4vGPjsP0c_EbYQ&branch=master
172179[ i5 ] : https://app.bitrise.io/app/ad178a030b96de53/status.svg?token=Om0YDuYQ4vGPjsP0c_EbYQ&branch=master
173- [ i6 ] : https://app.bitrise.io/app/ad178a030b96de53/status.svg?token=Om0YDuYQ4vGPjsP0c_EbYQ&branch=master
180+ [ i6 ] : https://app.bitrise.io/app/ad178a030b96de53/status.svg?token=Om0YDuYQ4vGPjsP0c_EbYQ&branch=master
181+
182+ [ i7 ] : https://coveralls.io/repos/chattylabs/conversational-flow-core/badge.svg?branch=master&service=github
183+ [ i8 ] : https://coveralls.io/repos/chattylabs/addon-android-speech/badge.svg?branch=master&service=github
184+ [ i9 ] : https://coveralls.io/repos/chattylabs/addon-google-speech/badge.svg?branch=master&service=github
0 commit comments