File tree Expand file tree Collapse file tree 4 files changed +67
-4
lines changed
src/main/java/chattylabs/conversations
sdk-voice-user-interaction/src/main/java/chattylabs/conversations Expand file tree Collapse file tree 4 files changed +67
-4
lines changed Original file line number Diff line number Diff line change 21
21
#-renamesourcefileattribute SourceFile
22
22
23
23
-keepnames class chattylabs.conversations.AndroidSpeechRecognizer
24
- -keepnames class chattylabs.conversations.AndroidSpeechSynthesizer
24
+ -keepnames class chattylabs.conversations.AndroidSpeechSynthesizer
25
+
26
+ # No need to obfuscate
27
+ # -keep class com.google.** { *; }
28
+ -keep class io.grpc.** { *; }
Original file line number Diff line number Diff line change @@ -133,14 +133,27 @@ public void onActivityResumed(Activity activity) {
133
133
_tts [0 ] = new TextToSpeech (application , ttsListener );
134
134
}
135
135
});
136
- Intent newIntent = new Intent (TextToSpeech .Engine .ACTION_CHECK_TTS_DATA );
137
- activity .startActivity (newIntent );
136
+ Intent checkData = new Intent (TextToSpeech .Engine .ACTION_CHECK_TTS_DATA );
137
+ boolean checkDataExists = checkData .resolveActivityInfo (activity .getPackageManager (), 0 ) != null ;
138
+ if (checkDataExists )
139
+ activity .startActivity (checkData );
140
+ Intent installData = new Intent (TextToSpeech .Engine .ACTION_INSTALL_TTS_DATA );
141
+ boolean installDataExists = installData .resolveActivityInfo (activity .getPackageManager (), 0 ) != null ;
142
+ if (installDataExists )
143
+ activity .startActivity (checkData );
144
+ else {
145
+ shutdown ();
146
+ logger .e (TAG , "NOT_AVAILABLE_ERROR" );
147
+ listener .execute (NOT_AVAILABLE_ERROR );
148
+ }
138
149
}
139
150
140
151
private void determineError (SynthesizerListener .OnStatusChecked listener , int errorCode ) {
141
152
Locale speechLanguage = getConfiguration ().getSpeechLanguage ();
142
153
143
- int result = tts .isLanguageAvailable (speechLanguage );
154
+ int result = TextToSpeech .ERROR ;
155
+ if (tts != null )
156
+ result = tts .isLanguageAvailable (speechLanguage );
144
157
145
158
shutdown ();
146
159
if (result == TextToSpeech .LANG_MISSING_DATA
Original file line number Diff line number Diff line change @@ -48,5 +48,30 @@ abstract class Status {
48
48
public static final int AFTER_PARTIAL_RESULTS_ERROR = 208 ;
49
49
public static final int NO_SOUND_ERROR = 209 ;
50
50
public static final int LOW_SOUND_ERROR = 210 ;
51
+
52
+ public static String getString (int status ) {
53
+ switch (status ) {
54
+ case NOT_AVAILABLE :
55
+ return "NOT_AVAILABLE" ;
56
+ case UNKNOWN_ERROR :
57
+ return "UNKNOWN_ERROR" ;
58
+ case EMPTY_RESULTS_ERROR :
59
+ return "EMPTY_RESULTS_ERROR" ;
60
+ case UNAVAILABLE_ERROR :
61
+ return "UNAVAILABLE_ERROR" ;
62
+ case STOPPED_TOO_EARLY_ERROR :
63
+ return "STOPPED_TOO_EARLY_ERROR" ;
64
+ case RETRY_ERROR :
65
+ return "RETRY_ERROR" ;
66
+ case AFTER_PARTIAL_RESULTS_ERROR :
67
+ return "AFTER_PARTIAL_RESULTS_ERROR" ;
68
+ case NO_SOUND_ERROR :
69
+ return "NO_SOUND_ERROR" ;
70
+ case LOW_SOUND_ERROR :
71
+ return "LOW_SOUND_ERROR" ;
72
+ default :
73
+ return "AVAILABLE" ;
74
+ }
75
+ }
51
76
}
52
77
}
Original file line number Diff line number Diff line change @@ -34,5 +34,26 @@ abstract class Status {
34
34
public static final int SUCCESS = 106 ;
35
35
public static final int ERROR = 107 ;
36
36
public static final int TIMEOUT = 108 ;
37
+
38
+ public static String getString (int status ) {
39
+ switch (status ) {
40
+ case AVAILABLE_BUT_INACTIVE :
41
+ return "AVAILABLE_BUT_INACTIVE" ;
42
+ case UNKNOWN_ERROR :
43
+ return "UNKNOWN_ERROR" ;
44
+ case LANGUAGE_NOT_SUPPORTED_ERROR :
45
+ return "LANGUAGE_NOT_SUPPORTED_ERROR" ;
46
+ case NOT_AVAILABLE_ERROR :
47
+ return "NOT_AVAILABLE_ERROR" ;
48
+ case SUCCESS :
49
+ return "SUCCESS" ;
50
+ case ERROR :
51
+ return "ERROR" ;
52
+ case TIMEOUT :
53
+ return "TIMEOUT" ;
54
+ default :
55
+ return "AVAILABLE" ;
56
+ }
57
+ }
37
58
}
38
59
}
You can’t perform that action at this time.
0 commit comments