1919import static com .chattylabs .sdk .android .voice .ConversationalFlowComponent .TAG ;
2020
2121/**
22- * When implementing from this class you must create a constructor that receives the following parameters
23- * in the same order:
22+ * This is the base class that handles internally and holds a queue of messages to be played out.
23+ * <br/>You only need to implement the contract of {@link SpeechSynthesizerComponent} and extend to this
24+ * class.
2425 * <p/>
25- * <pre>{@code
26+ * The technical requirements while implementing the {@link SpeechSynthesizerComponent} through
27+ * this base class are:
28+ * <p/>
29+ * - You will create a constructor that receives the following parameters in the same order:
30+ * <br/><pre>{@code
2631 * public Constructor(Application, ComponentConfig, AndroidAudioManager, BluetoothSco, ILogger) {
2732 * super(ComponentConfig, AndroidAudioManager, BluetoothSco, ILogger);
2833 * //...
2934 * }
3035 * }</pre>
31- * Otherwise the addon initialization will throw and Exception on runtime.
36+ * If the parameters are not in the same order the addon initialization will throw an Exception.
37+ * <p/>
38+ * - You will implement {@link #setup(SynthesizerListener.OnSetup)} which is
39+ * in charge of testing whether the client provider work and to check whether the required language
40+ * is available.
41+ * <p/>
42+ * - You will implement {@link #initTts(SynthesizerListener.OnInitialised)} which is the entry point
43+ * for any call to {@link #playText(String, SynthesizerListener[])} or
44+ * {@link #playSilence(long, SynthesizerListener[])} and its variations.
45+ * <br/>This method behaves like {@link #setup(SynthesizerListener.OnSetup)} but it stores the current
46+ * Text To Speech client, sets up the current required language, and initializes a
47+ * {@link SynthesizerUtteranceListener}.
48+ * <br/>This method should check whether the current client instance is available or create a new one.
49+ * <p/>
50+ * - You will implement {@link #createUtteranceListener(SynthesizerListener...)} where you handle
51+ * the lifecycle of the played utterance.
52+ * <p/>
53+ * - You will implement {@link #executeOnTtsReady(String, String, HashMap)} where you can apply any
54+ * {@link TextFilter}, escape HTML entities, split a string into chunks if needed, any other treatment
55+ * on the message to be played and ultimately to play the message through the implemented Provider.
3256 *
57+ * @see SynthesizerListener
3358 * @see SpeechSynthesizerComponent
59+ * @see SynthesizerUtteranceListener
3460 * @see android.app.Application
3561 * @see ComponentConfig
3662 * @see AndroidAudioManager
@@ -86,8 +112,7 @@ abstract class BaseSpeechSynthesizer implements SpeechSynthesizerComponent {
86112
87113 abstract void initTts (SynthesizerListener .OnInitialised onSynthesizerInitialised );
88114
89- abstract void executeOnTtsReady (
90- String utteranceId , String text , HashMap <String , String > params );
115+ abstract void executeOnTtsReady (String utteranceId , String text , HashMap <String , String > params );
91116
92117 abstract void playSilence (String utteranceId , long durationInMillis );
93118
@@ -97,8 +122,7 @@ abstract void executeOnTtsReady(
97122
98123 abstract boolean isTtsSpeaking ();
99124
100- abstract SynthesizerUtteranceListener createUtteranceListener (
101- SynthesizerListener [] listeners );
125+ abstract SynthesizerUtteranceListener createUtteranceListener (SynthesizerListener [] listeners );
102126
103127 void setReady (boolean ready ) {
104128 logger .w (TAG , "TTS - ready set to " + Boolean .toString (ready ));
0 commit comments