androidapp-actions

Is it possible to playback some text using Google Assistant?


I have an android app with a custom intent that is fired by the Google Assistant with some text like "open my app and activate some action" (for example, "open clients database and sort clients"). All this is done very well but I would like to add some speech once the job is done, maybe a "job done" text or more specific "clients list is now sorted". Is this possible with the Assistant. Can we send back a result for it to speak it?


Solution

  • I haven't found any solution on playing voice using the Assistant but I could play voice using TextToSpeech.speak. Very simple.

    TextToSpeech oTextToSpeech=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
                @Override
                public void onInit(int status) {
                    if(status != TextToSpeech.ERROR) {                        
                        oTextToSpeech.speak("Hello this is a test", TextToSpeech.QUEUE_ADD, null);
                    }
                }
            });
    

    The only problem is that I cannot use the same voice but it works very well and it is very simple.