-
Notifications
You must be signed in to change notification settings - Fork 90
Speech
temi's speech flow is comprised of four main components - wakeup, ASR (Automatic Speech Recognition), NLP (Natural language processing) and TTS (text to speech).
temi's SDK provides developers tools to utilize, customize and listen to any of the components.
Return | Method | Description |
---|---|---|
void | speak(TtsRequest ttsRequest) | Ask temi to speak(play TTS) |
void | cancelAllTtsRequests() | cancel TTS request |
void | wakeup() | Wake up temi |
String | getWakeupWord() | Get current wake-up word |
void | askQuestion(String question) | temi speak actively and wait for user's reply |
void | finishConversation() | Finish a conversation(Stop recording for ASR) |
void | startDefaultNlu(String text) | Trigger default NLU service |
Interface | Description |
---|---|
TtsListener | TTS status listener |
WakeupWordListener | Wake-up event listener |
AsrListener | ASR result listener |
ConversationViewAttachesListener | Conversation view attaches listener |
OnTtsVisualizerWaveFormDataChangedListener | Listener for wave form data changes of TTS audio visualizer |
OnTtsVisualizerFftDataChangedListener | Listener for ftt data changes of TTS audio visualizer |
Model | Description |
---|---|
TtsRequest | TTS request instance |
Use this method to let temi speak something that from the parameter ttsRequest
of this method.
-
Parameters
Parameter Type Description ttsRequest TtsRequest An object of type TtsRequest in this object you will add the text to be spoken. -
Prototype
void speak(TtsRequest ttsRequest);
-
Required permissions
None.
-
Support from
0.10.36
Stops currently processed TTS request and empty the queue.
-
Prototype
void cancelAllTtsRequests();
-
Required permissions
None.
-
Support from
Use this method to trigger temi's wakeup programmatically.
-
Prototype
void wakeup();
-
Required permissions
None.
-
Support from
0.10.49
Use this method to get temi's wake word assistant.
-
Return
Type Description String Wake-up word -
Prototype
String getWakeupWord();
-
Required permissions
None.
-
Support from
0.10.49
Use this method to let temi actively speak to the user and wait for the user to answer.
-
Parameters
Parameter Type Description question String The text to be spoken -
Prototype
void askQuestion(String question);
-
Required permissions
None.
-
Support from
0.10.63
-
Recommendation
A custom dialog flow can be realized by cooperating with AsrListener. For details, please refer to Sample code.
Use this method to finish the conversation (Stop recording for ASR).
-
Prototype
void finishConversation();
-
Required permissions
None.
-
Support from
0.10.63
Use this method to trigger the system's default natural language understanding (NLU). If you want to directly trigger system skills such as weather or music in your skill, you can directly pass in "What's the wheather today" or "Play Music" as a parameter and invoke this method to achieve it.
-
Parameters
Parameter Type Description text String Natural language text to be processed -
Prototype
void startDefaultNlu(String text);
-
Required permissions
Selected Kiosk
-
Support from
0.10.70
-
Note
This interface can only be called once every 5 seconds.
Set your context to implement this listener and add the override method to get TTS status changes.
package com.robotemi.sdk;
interface Robot.TtsListener {}
-
Parameters
Parameter Type Description ttsRequest TtsRequest TTS request object that holds its text content and status -
Prototype
void onTtsStatusChanged(TtsRequest ttsRequest);
-
Parameters
Parameter Type Description listener TtsListener An instance of a class that implements this interface -
Prototype
void addTtsListener(TtsListener listener);
-
Parameters
Parameter Type Description listener TtsListener An instance of a class that implements this interface -
Prototype
void removeTtsListener(TtsListener listener);
-
Support from
0.10.36
Set your context to implement this listener and add the override method to get wake word value when triggered by the user.
package com.robotemi.sdk;
interface Robot.WakeupWordListener {}
-
Parameters
Parameter Type Description wakeupWord String The wakeup word used to trigger direction int - 0 - temi was triggered from the front
- 90 - temi was triggered from the left
- 180 - temi was triggered from the back
- 270 - temi was triggered from the right
-
Prototype
void onWakeupWord(String wakeupWord, int direction);
-
Parameters
Parameter Type Description listener WakeupWordListener An instance of a class that implements this interface -
Prototype
void addWakeupWordListener(WakeupWordListener listener);
-
Parameters
Parameter Type Description listener WakeupWordListener An instance of a class that implements this interface -
Prototype
void removeWakeupWordListener(WakeupWordListener listener);
-
Support from
0.10.36
Set your context to implement this listener and add the override method to get the ASR result.
package com.robotemi.sdk;
interface Robot.AsrListener {}
-
Parameters
Parameter Type Description asrResult String The ASR result -
Prototype
void onAsrResult(String asrResult);
-
Parameters
Parameter Type Description listener AsrListener An instance of a class that implements this interface -
Prototype
void addAsrListener(AsrListener listener);
-
Parameters
Parameter Type Description listener AsrListener An instance of a class that implements this interface -
Prototype
void removeAsrListener(AsrListener listener);
-
Support from
0.10.53
Set your context to implement this listener and add the override method to listen if the conversation view attaches.
package com.robotemi.sdk;
interface Robot.ConversationViewAttachesListener {}
-
Parameters
Parameter Type Description isAttached boolean true
means the conversation view attaches,false
otherwise -
Prototype
void onConversationAttaches(boolean isAttached);
-
Parameters
Parameter Type Description listener ConversationViewAttachesListener An instance of a class that implements this interface -
Prototype
void addConversationViewAttachesListenerListener(ConversationViewAttachesListener listener);
-
Parameters
Parameter Type Description listener ConversationViewAttachesListener An instance of a class that implements this interface -
Prototype
void removeConversationViewAttachesListenerListener(ConversationViewAttachesListener listener);
-
Support from
0.10.36
Set your context to implement this interface and override its' abstract method to listen to the status and text changes of the Conversation layer.
Note: Only the selected Kiosk App declared in the AndroidManifest.xml file to override the original conversation layer UI can receive the related callback data.
package com.robotemi.sdk.listeners;
interface OnConversationStatusChangedListener {}
All constants here are only for the status of Conversation layer.
Constant | Type | Value | Description |
---|---|---|---|
IDLE | int | 0 | Idle, no useriteraction |
LISTENING | int | 1 | Listening user's voice |
THINKING | int | 2 | Doing NLP |
SPEAKING | int | 3 | Playing TTS |
-
Parameters
Parameter Type Description status int Status of Conversation layer text String Text of Conversation layer -
Prototype
void onConversationStatusChanged(int status, String text);
-
Parameters
Parameter Type Description listener OnConversationStatusChangedListener An instance of a class that implements this interface -
Prototype
void addOnConversationStatusChangedListener(OnConversationStatusChangedListener listener);
-
Parameters
Parameter Type Description listener OnConversationStatusChangedListener An instance of a class that implements this interface -
Prototype
void removeOnConversationStatusChangedListener(OnConversationStatusChangedListener listener);
-
Support from
0.10.72
Set your context to implements this interface and override its' abstract method to listen to the wave form data changes of the TTS audio visualizer.
package com.robotemi.sdk.listeners;
interface OnTtsVisualizerWaveFormDataChangedListener {}
-
Parameters
Parameter Type Description waveForm byte[] Wave form data -
Prototype
void onTtsVisualizerWaveFormDataChanged(byte[] waveForm);
-
Parameters
Parameter Type Description listener OnTtsVisualizerWaveFormDataChangedListener An instance of a class that implements this interface -
Prototype
void addOnTtsVisualizerWaveFormDataChangedListener(OnTtsVisualizerWaveFormDataChangedListener listener);
-
Parameters
Parameter Type Description listener OnTtsVisualizerWaveFormDataChangedListener An instance of a class that implements this interface -
Prototype
void removeOnTtsVisualizerWaveFormDataChangedListener(OnTtsVisualizerWaveFormDataChangedListener listener);
-
Support from
0.10.72
Set your context to implements this interface and override its' abstract method to listen to the fft data changes of the TTS audio visualizer.
package com.robotemi.sdk.listeners;
interface OnTtsVisualizerFftDataChangedListener {}
-
Parameters
Parameter Type Description fft byte[] fft data -
Prototype
void OnTtsVisualizerFftDataChangedListener(byte[] fft);
-
Parameters
Parameter Type Description listener OnTtsVisualizerFftDataChangedListener An instance of a class that implements this interface -
Prototype
void addOnTtsVisualizerFftDataChangedListener(OnTtsVisualizerFftDataChangedListener listener);
-
Parameters
Parameter Type Description listener OnTtsVisualizerFftDataChangedListener An instance of a class that implements this interface -
Prototype
void removeOnTtsVisualizerFftDataChangedListener(OnTtsVisualizerFftDataChangedListener listener);
-
Support from
0.10.72
Request object passed to temi, which contains all the information temi needs to in order to speak and for the skill to track its' request.
package com.robotemi.sdk;
class TtsRequest {}
Attribute | Type | Description |
---|---|---|
id | UUID | Unique number that identifies each tts request |
speech | String | The text to be spoken |
packageName | String | Skill package name so that temi knows who made the request |
status | Status | Status of the request |
isShowOnConversationLayer | boolean | Should the conversation line be shown when temi speaks the text. Note: Only relevant for 'Hey temi' assistant skills |
Create a TtsRequest object and pass it to speak(TtsRequest ttsRequest) method to play TTS.
-
Parameters
Parameter Type Description speech String The text to be spoken isShowOnConversationLayer boolean true
means the conversation view will appear when TTS is playing,false
otherwise -
Return
Type Description TtsRequest TTS request object created by this method -
Prototype
static TtsRequest create(String speech, boolean isShowOnConversationLayer);
-
Add the following
<meta-data>
s under the<application>
element to AndroidManifest.xml file:<!-- Kiosk mode is required --> <meta-data android:name="@string/metadata_kiosk" android:value="true" /> <meta-data android:name="@string/metadata_override_nlu" android:value="true" />
-
Listen to the ASR and access your own NLP service in its callback method.
-
Operate in Launcher: Settings > Kiosk > Select your skill. Or request to be the selected Kiosk App by method
Robot.getInstance().requestToBeKioskApp()
.
Selected Kiosk
0.10.63
-
Add the following
<meta-data>
s under the<application>
element to AndroidManifest.xml file:<!-- Kiosk mode is required --> <meta-data android:name="@string/metadata_kiosk" android:value="true" /> <meta-data android:name="@string/metadata_override_stt" android:value="true" />
-
Listen to the wake-up event and access your own ASR service in its callback method.
-
Operate in Launcher: Settings > Kiosk > Select your skill. Or request to be the selected Kiosk App by method
Robot.getInstance().requestToBeKioskApp()
.
Selected Kiosk
0.10.70
-
Add the following
<meta-data>
s under the<application>
element to AndroidManifest.xml file:<!-- Kiosk mode is required --> <meta-data android:name="@string/metadata_kiosk" android:value="true" /> <meta-data android:name="@string/metadata_override_conversation_layer" android:value="true" />
-
Listen to onConversationStatusChangedListener and draw the UI according to the data(status, text) from its callback method.
-
Operate in Launcher Settings > App > Kiosk > Select your skill. Or request to be the selected Kiosk App by method
Robot.getInstance().requestToBeKioskApp()
.
Selected Kiosk
0.10.72