Skip to content
lcgao edited this page Apr 10, 2020 · 53 revisions

Overview

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.

Applications

  1. To ask temi to speak use the speak(TtsRequest ttsRequest) method and pass a TtsRequest which amongst other attributes will include the text string to be spoken.
  2. To cancel a TtsRequest use the cancelAllTtsRequests() method.
  3. To trigger the wakeup programmatically use the method wakeup().
  4. To get temi's wakeup word use the method wakeWord().
  5. To listen for tts changes you need to add TtsListener to the addTtsListener(TtsListener ttsListener) method.
  6. To stop listening for tts changes you need to remove listener using the removeTtsListener(TtsListener ttsListener) method.
  7. To listen for wakeup triggers you need to add WakeupWordListener to the addWakeupWordListener method.
  8. To stop listening for wakeup triggers you need to remove the listener using the removeWakeupWordListener method.
  9. To listen for ASR results you need to add ASRListener to the addAsrListener(ASRListener asrListener) method.
  10. To stop listening for ASR results you need to remove the listener using the removeAsrListener(ASRListener asrListener) method.
  11. To let temi actively speak to the user and wait for the user to answer use the askQuestion(String question) method.
  12. To finish a conversation use the finishConversation() method.

Methods

Below are the details regarding the speech methods you can use from SDK.

◆ Speak

com.robotemi.sdk.Robot.speak ( TtsRequest  ttsRequest ) void

Using this method you are essentially asking temi to add to its' speech request queue another request

Parameters
ttsRequest An object of type TtsRequest in this object you will add the text to be spoken
Returns
void object.

Exceptions
Exception Failed to invoke remote call speak()

◆ Cancel Speech

com.robotemi.sdk.Robot.cancelAllTtsRequests ( )
void

Stops currently processed TTS request and empty the queue

Returns
void object.
Exceptions
Exception Failed to invoke remote call cancelAllTtsRequest()

◆ Wakeup

com.robotemi.sdk.Robot.wakeup ( )
void

Use this method to trigger temi's wakeup programmatically

Returns
void object.
Exceptions
Exception wakeup() error.

◆ Get Wake Word

com.robotemi.sdk.Robot.wakeupWord ( )
String

Use this method to get temi's wake word assistant

Returns

String object, containing one of the following wakeword options:

  • Alexa
  • Ding Dang
  • Hey, temi
  • Exceptions
    Exception getWakeupWord() error

    ◆ temi speak actively and wait for the user to answer

    com.robotemi.sdk.Robot.askQuestion ( String question )
    void

    Use this method to let temi actively speak to the user and wait for the user to answer.

    Returns
    void object.
    Exceptions
    Exception askQuestion() error
    Tips

    A custom dialog flow can be realized by cooperating with AsrListener. For details, please refer to Sample code.


    ◆ Finish Conversation

    com.robotemi.sdk.Robot.finishConversation ( )
    void

    Use this method to finish the conversation (Stop recording for ASR).

    Returns
    void object.
    Exceptions
    Exception finishConversation() error

    Listeners

    Below are the details regarding how to listen for speech changes.

    ◆ Add speech listener

    com.robotemi.sdk.Robot.addTtsListener ( TtsListener  ttsListener
    )
    void

    Use this method to add a listener that listens for text to speech status changes.

    Parameters
    ttsListener A listener object of type TtsListener that contains a void method onTtsStatusChanged(TtsRequest ttsRequest) which contains information regarding a specific speech request
    Returns
    void object.

    ◆ Remove speech listener

    com.robotemi.sdk.Robot.removeTtsListener ( TtsListener  ttsListener
    )
    void

    Use this method to remove a specific tts listener

    Parameters
    ttsListener The tts listener object (of type TtsListener) which you want to stop listening to.
    Returns
    void object.

    Below are the details regarding how to listen for wakeup triggers.

    ◆ Add Wakeup Word Listener

    com.robotemi.sdk.Robot.addWakeupWordListener ( WakeupWordListener  wakeupWordListener
    )
    void

    Use this method to add a listener that will be called when a wakeup word is caught

    Parameters
    wakeupWordListener A listener object of type WakeupWordListener that contains a void method onWakeupWord(String wakeWord) which contains the wakeup word that was used by the user
    Returns
    void object.

    ◆ Remove Wake Word Listener

    com.robotemi.sdk.Robot.removeWakeupWordListener ( WakeupWordListener  wakeupWordListener
    )
    void

    Use this method to remove a specific wake word listener

    Parameters
    wakeupWordListener The wake word listener object (of type WakeWordListener) which you want to stop listening to.
    Returns
    void object.

    ◆ Add ASR Listener

    com.robotemi.sdk.Robot.addAsrListener ( AsrListener  asrListener
    )
    void

    Use this method to add a listener that will be called when the ASR has returned a result

    Parameters
    asrListener A listener object of type AsrListener which contains a method onAsrResult(String asrResult) that holds the ASR result in string format
    Returns
    void object.
    Tips

    After version 0.10.63, developers can add the following <meta-data> under the <application> tag of AndroidManifest.xml to cover temi’s original voice flow, so developers can access their own NLP service here, and take asrResult as its input:
    <meta-data android:name="@string/metadata_kiosk" android:value="TRUE" />
    <meta-data android:name="@string/metadata_override_nlu" android:value="TRUE" />

    ◆ Remove ASR Listener

    com.robotemi.sdk.Robot.removeAsrListener ( AsrListener  asrListener
    )
    void

    Use this method to remove a specific ASR listener

    Parameters
    asrListener The ASR listener object (of type AsrListener) which you want to stop listening to.
    Returns
    void object.

    Models

    Below are the details regarding models used in speech methods

    ◆ Text to Speech Request

    com.robotemi.sdk.TtsRequest create ( String  speech
    boolean  isShowOnConversationLayer
    )

    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

    Attributes
    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
    public enum Status{
    PENDING, PROCESSING, STARTED, COMPLETED, ERROR, NOT_ALLOWED
    }
    isShowOnConversationLayer boolean should the conversation line be shown when temi speaks the text
    Note: Only relevant for 'Hey temi' assistant skills
    Example
    TtsRequest.create("Hi, I'm temi", true);

    ◆ Text to Speech Listener

    Interface
    com.robotemi.sdk.Robot.TtsListener {
    void onTtsStatusChanged ( TtsRequest  ttsRequest )
    }

    Set your context to implement this listener and add the override method to get tts status changes


    ◆ Wake Word Listener

    Interface
    com.robotemi.sdk.Robot.WakeupWordListener {
    onWakeupWord ( String  wakeupWord ,
    int  direction )
    }
    Parameters
    wakeupWord String object containing the wakeup word used to trigger
    direction Which direction did the wakeup come from, or in other words where the user was standing with respect to temi when triggered the wakeup. The direction is returned as an integer and represents the angle of 0 - 360.
  • 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
  • Set your context to implement this listener and add the override method to get wake word value when triggered by the user


    ◆ ASR Listener

    Interface
    com.robotemi.sdk.Robot.AsrListener {
    onAsrResult ( String  asrResult )
    }
    Parameters
    asrResult String object containing the words spoken temi after the wakeup trigger

    Set your context to implement this listener and add the override method to get the ASR result

    Clone this wiki locally