Skip to content

Commit ef00edd

Browse files
committed
Updated README and refactored some names.
1 parent 16ef573 commit ef00edd

File tree

13 files changed

+63
-55
lines changed

13 files changed

+63
-55
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111
Part of the [Voice & User Interaction SDK]().
1212

13-
This library combines both native built-in resources and cloud services from various providers into
14-
a Component capable to run reliably a Speech Synthesizer and a Voice Recognizer.
13+
This library combines both native built-in resources and cloud services into
14+
a software component capable to run reliably a Speech Synthesizer and a Voice Recognizer.
1515

16-
Besides, it provides an [Interface](#create-a-conversation) based on a
16+
Besides, it provides an [Interface](#how-to-create-a-conversation) based on a
1717
[Directed Graph](https://en.wikipedia.org/wiki/Directed_graph)
1818
implementation with [Directed Cycles](https://en.wikipedia.org/wiki/Cycle_(graph_theory))
1919
that allows a developer to create connected nodes and build a consistent conversation flow between
2020
a device and a user with ease.
21-
<br/>**Consistency** here stands for the needless to code the flow using conditional statements or
21+
<br/>_Consistency_ here stands for the needless to code the flow using conditional statements or
2222
any extra state complexity while ensuring the conversation will behave as expected.
2323

2424
It enables currently the following providers:
@@ -27,13 +27,13 @@ It enables currently the following providers:
2727
- [TextToSpeech](https://developer.android.com/reference/android/speech/tts/TextToSpeech)
2828
- [SpeechRecognizer](https://developer.android.com/reference/android/speech/SpeechRecognizer)
2929
- [Google Cloud](https://cloud.google.com/)
30-
- [Speech-To-Text](https://cloud.google.com/speech-to-text/)
3130
- [Text-To-Speech](https://cloud.google.com/text-to-speech/)
31+
- [Speech-To-Text](https://cloud.google.com/speech-to-text/)
3232

3333
like Android, Google Cloud,
3434
(Amazon, Wit.ai, Temi, Bing Speech, IBM, ...)
3535

36-
<p align="center"><img src="assets/demo-sample.jpg" alt="demo-sample"/></p>
36+
<p align="center"><img src="art/demo-sample.jpg" alt="demo-sample"/></p>
3737

3838
## Why choosing this library?
3939

@@ -95,7 +95,7 @@ conversation.start(question);
9595

9696
There are different [Voice Nodes](), check the [wiki page]()
9797

98-
<p align="center"><img src="assets/flow-sample.jpg" alt="flow-sample"/></p>
98+
<p align="center"><img src="art/flow-sample.jpg" alt="flow-sample"/></p>
9999

100100
&nbsp;
101101

demo/src/main/AndroidManifest.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,17 @@
1313
<meta-data android:name="net.hockeyapp.android.appIdentifier" android:value="${HOCKEYAPP_APP_ID}" />
1414
<activity android:name="com.chattylabs.demo.voice.BuildFromJsonActivity"
1515
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
16-
android:screenOrientation="portrait"
17-
android:windowSoftInputMode="adjustResize">
16+
android:screenOrientation="portrait">
1817
<intent-filter>
1918
<action android:name="android.intent.action.MAIN" />
2019

2120
<category android:name="android.intent.category.LAUNCHER" />
2221
</intent-filter>
2322
</activity>
24-
<activity android:name="com.chattylabs.demo.voice.CustomConversationActivity"
23+
<activity android:name="com.chattylabs.demo.voice.TestTheComponentActivity"
2524
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
2625
android:screenOrientation="portrait"
27-
android:windowSoftInputMode="adjustResize"/>
26+
android:windowSoftInputMode="adjustPan"/>
2827
</application>
2928

3029
</manifest>

demo/src/main/java/com/chattylabs/demo/voice/BaseActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
152152
switch (item.getItemId()) {
153153
case R.id.demo_custom_conversation:
154154
ContextCompat.startActivity(this,
155-
new Intent(this, CustomConversationActivity.class), null);
155+
new Intent(this, TestTheComponentActivity.class), null);
156156
return true;
157157
case R.id.demo_build_from_json:
158158
ContextCompat.startActivity(this,

demo/src/main/java/com/chattylabs/demo/voice/BuildFromJsonActivity.java

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
import android.annotation.SuppressLint;
44
import android.os.Bundle;
5-
import android.support.constraint.ConstraintLayout;
6-
import android.view.Gravity;
5+
import android.text.Spanned;
76
import android.view.ViewGroup;
8-
import android.widget.AbsListView;
97
import android.widget.ArrayAdapter;
108
import android.widget.Button;
119
import android.widget.ListView;
12-
import android.widget.TextView;
1310

11+
import com.chattylabs.sdk.android.common.HtmlUtils;
1412
import com.chattylabs.sdk.android.common.Tag;
1513
import com.chattylabs.sdk.android.voice.Conversation;
1614
import com.chattylabs.sdk.android.voice.ConversationFlow;
@@ -31,7 +29,7 @@ public class BuildFromJsonActivity extends BaseActivity {
3129

3230
private static final String TAG = Tag.make(BuildFromJsonActivity.class);
3331

34-
private ArrayAdapter<String> listViewAdapter;
32+
private ArrayAdapter<Spanned> listViewAdapter;
3533

3634
@Override
3735
protected void onCreate(Bundle savedInstanceState) {
@@ -50,8 +48,7 @@ private void initViews() {
5048

5149
ListView conversationListView = findViewById(R.id.conversation);
5250
listViewAdapter = new ArrayAdapter<>(this, R.layout.item_block,
53-
R.id.conversation_item_text,
54-
new ArrayList<>());
51+
R.id.conversation_item_text, new ArrayList<>());
5552
listViewAdapter.setNotifyOnChange(true);
5653
conversationListView.setEmptyView(findViewById(R.id.empty_text));
5754
conversationListView.setAdapter(listViewAdapter);
@@ -76,9 +73,7 @@ private void loadConversation() {
7673
VoiceMessage message = VoiceMessage.newBuilder()
7774
.setText(text)
7875
.setOnReady(() -> {
79-
runOnUiThread(() -> {
80-
listViewAdapter.add(text);
81-
});
76+
addIntoAdapter(text);
8277
}).build();
8378

8479
VoiceMatch matches = null;
@@ -91,22 +86,22 @@ private void loadConversation() {
9186
}
9287
matches = VoiceMatch.newBuilder()
9388
.setOnReady(() -> {
94-
listViewAdapter.add(dots);
89+
addIntoAdapter(dots);
9590
})
9691
.setExpectedResults(stringArray)
9792
.setOnMatched(strings -> {
98-
listViewAdapter.remove(dots);
93+
removeLastFromAdapter();
9994
if (strings != null) {
100-
listViewAdapter.add(strings.get(0));
95+
addIntoAdapter("<b>You said:</b> " + strings.get(0));
10196
conversation.next();
10297
}
10398
})
10499
.build();
105100
noMatches = VoiceMismatch.newBuilder()
106101
.setOnNotMatched(strings -> {
107-
listViewAdapter.remove(dots);
108-
listViewAdapter.add("You said: " + strings);
109-
listViewAdapter.add("I did not expect that. Please try again!");
102+
removeLastFromAdapter();
103+
addIntoAdapter("<b>You said:</b> " + strings);
104+
addIntoAdapter("I was not expecting that. Please try again!");
110105
}).build();
111106
}
112107

@@ -130,6 +125,20 @@ private void loadConversation() {
130125
}
131126
}
132127

128+
private void removeLastFromAdapter() {
129+
runOnUiThread(() -> {
130+
listViewAdapter.remove(listViewAdapter.getItem(
131+
listViewAdapter.getCount() - 1
132+
));
133+
});
134+
}
135+
136+
private void addIntoAdapter(String text) {
137+
runOnUiThread(() -> {
138+
listViewAdapter.add(HtmlUtils.from(text));
139+
});
140+
}
141+
133142
public String loadJSONFromAsset() {
134143
String json = null;
135144
try {

demo/src/main/java/com/chattylabs/demo/voice/DemoApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static abstract class DemoModule {
3232
abstract ILogger provideLogger(ILoggerImpl logger);
3333

3434
@ContributesAndroidInjector
35-
abstract CustomConversationActivity conversationCreatorActivity();
35+
abstract TestTheComponentActivity conversationCreatorActivity();
3636

3737
@ContributesAndroidInjector
3838
abstract BuildFromJsonActivity mainActivity();

demo/src/main/java/com/chattylabs/demo/voice/CustomConversationActivity.java renamed to demo/src/main/java/com/chattylabs/demo/voice/TestTheComponentActivity.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
import static com.chattylabs.sdk.android.voice.ConversationalFlowComponent.matches;
2525

2626

27-
public class CustomConversationActivity extends BaseActivity {
27+
public class TestTheComponentActivity extends BaseActivity {
2828

29-
private static final String TAG = Tag.make(CustomConversationActivity.class);
29+
private static final String TAG = Tag.make(TestTheComponentActivity.class);
3030

3131
// Constants
3232
private static final int CHECK = 3;
@@ -50,7 +50,7 @@ public class CustomConversationActivity extends BaseActivity {
5050
@Override
5151
protected void onCreate(Bundle savedInstanceState) {
5252
super.onCreate(savedInstanceState);
53-
setContentView(R.layout.activity_customize_the_component);
53+
setContentView(R.layout.activity_test_the_component);
5454
peripheral = new Peripheral((AudioManager) getSystemService(AUDIO_SERVICE));
5555
initCommonViews();
5656
initViews();
@@ -102,10 +102,10 @@ private void representQueue(int index) {
102102
}
103103
}
104104
String action = label + (item.first == LISTEN ? "" : " \"<i>" + text + "</i>\" ");
105-
tx = new StringBuilder(tx == null || tx.length() == 0 ?
106-
action :
107-
tx.append((item.first == READ ? "<br/>" : "<br/>...then "))
108-
.append(action));
105+
if (tx == null) {
106+
tx = new StringBuilder();
107+
}
108+
tx.append("<br/><br/> > ").append(action);
109109
isChecking = item.first == CHECK;
110110
}
111111
}

demo/src/main/res/layout/activity_build_from_json.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77
android:layout_height="match_parent"
88
android:animateLayoutChanges="true"
99
android:background="#ffffff"
10-
tools:context="com.chattylabs.demo.voice.CustomConversationActivity">
10+
tools:context="com.chattylabs.demo.voice.TestTheComponentActivity">
1111

1212
<android.support.constraint.Guideline
1313
android:id="@+id/guideline"
1414
android:layout_width="0dp"
1515
android:layout_height="wrap_content"
1616
android:orientation="horizontal"
17-
app:layout_constraintGuide_percent="0.65" />
17+
app:layout_constraintGuide_percent="0.85" />
1818

1919
<TextView
2020
android:id="@+id/empty_text"
2121
android:layout_width="wrap_content"
2222
android:layout_height="wrap_content"
2323
android:text="Choose an addon and press on proceed"
2424
app:layout_constraintBottom_toBottomOf="@+id/conversation"
25-
app:layout_constraintStart_toStartOf="@+id/conversation"
2625
app:layout_constraintEnd_toEndOf="@+id/conversation"
26+
app:layout_constraintStart_toStartOf="@+id/conversation"
2727
app:layout_constraintTop_toTopOf="@+id/conversation" />
2828

2929
<ListView

demo/src/main/res/layout/activity_customize_the_component.xml renamed to demo/src/main/res/layout/activity_test_the_component.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
android:layout_width="match_parent"
77
android:layout_height="match_parent"
88
android:animateLayoutChanges="true"
9-
tools:context="com.chattylabs.demo.voice.CustomConversationActivity">
9+
tools:context="com.chattylabs.demo.voice.TestTheComponentActivity">
1010

1111
<android.support.constraint.Guideline
1212
android:id="@+id/guideline"
1313
android:layout_width="wrap_content"
1414
android:layout_height="wrap_content"
1515
android:orientation="horizontal"
16-
app:layout_constraintGuide_percent="0.35" />
16+
app:layout_constraintGuide_percent="0.55" />
1717

1818
<TextView
1919
android:id="@+id/execution"
@@ -24,6 +24,7 @@
2424
android:padding="10dp"
2525
android:scrollbars="vertical"
2626
android:textColor="@android:color/darker_gray"
27+
android:typeface="monospace"
2728
app:layout_constraintBottom_toTopOf="@+id/guideline"
2829
app:layout_constraintEnd_toEndOf="parent"
2930
app:layout_constraintStart_toStartOf="parent"

demo/src/main/res/menu/demos.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<menu xmlns:android="http://schemas.android.com/apk/res/android">
3-
<item android:id="@+id/demo_custom_conversation"
4-
android:title="Custom Conversation Activity"/>
53
<item android:id="@+id/demo_build_from_json"
6-
android:title="Build From Json Activity"/>
4+
android:title="Build From Json"/>
5+
<item android:id="@+id/demo_custom_conversation"
6+
android:title="Test the Component"/>
77
</menu>
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[
22
{
3-
"message": "Hi!"
4-
},
5-
{
6-
"message": "How are you?",
3+
"message": "Hi! How are you doing today?",
74
"results": ["good", "fine", "not bad"]
85
},
96
{
10-
"message": "Good!. Are you ok if we keep talking?",
7+
"message": "Good! Are you ok if we keep talking?",
118
"results": ["yes", "sure", "no", "of course"]
129
},
10+
{ "message": "Ok. I'm a voice synthesizer created to assist you." },
1311
{
14-
"message": "Ok. I'm a bit lazy now, let's try next time."
15-
}
12+
"message": "Do you have any query so far?",
13+
"results": ["yes", "sure", "no", "of course"]
14+
},
15+
{ "message": "Ok. Let's keep that in mind in our next talk!" }
1616
]

demo/src/main/res/values/arrays.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<string-array name="actions">
44
<item>Select and option&#8230;</item>
55
<item>Read aloud&#8230;</item>
6-
<item>Listen to any message</item>
6+
<item>Listen&#8230;</item>
77
<item>Check for&#8230;</item>
88
</string-array>
99
<string-array name="addons">

sdk-addon-android-speech/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ dependencies {
4242
api 'com.google.dagger:dagger:2.15'
4343
kapt 'com.google.dagger:dagger-compiler:2.15'
4444
// SDK
45+
implementation 'com.chattylabs.sdk.android:common:+'
4546
api project(':sdk-conversational-flow-core')
4647
}
4748

sdk-addon-google-speech/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,12 @@ ext {
4343

4444
dependencies {
4545
implementation fileTree(dir: 'libs', include: ['*.jar'])
46-
4746
// Dagger
4847
api 'com.google.dagger:dagger:2.15'
4948
kapt 'com.google.dagger:dagger-compiler:2.15'
50-
5149
// SDK
50+
implementation 'com.chattylabs.sdk.android:common:+'
5251
api project(':sdk-conversational-flow-core')
53-
5452
// Google Cloud
5553
implementation "io.grpc:grpc-okhttp:$grpcVersion"
5654
implementation "com.google.cloud:google-cloud-texttospeech:0.55.0-beta"

0 commit comments

Comments
 (0)