dialogflow / dialogflow-android-client

Android SDK for Dialogflow
https://dialogflow.com
Apache License 2.0
575 stars 270 forks source link

display text with speech recognisation #58

Closed vipulasri closed 7 years ago

vipulasri commented 7 years ago

When a user is saying something, simultaneously display recognized text just like Google Assistant. Basically getting recognization results from AIService

vipulasri commented 7 years ago

Got it:

Just by setting a PartialResultsListener to AIService


if (aiService instanceof GoogleRecognitionServiceImpl) {
            ((GoogleRecognitionServiceImpl) aiService).setPartialResultsListener(new PartialResultsListener() {
                @Override
                public void onPartialResults(final List<String> partialResults) {
                    if (partialResultsListener != null) {
                        partialResultsListener.onPartialResults(partialResults);
                    }
                }
            });
        }
kevinjmz commented 5 years ago

hey @vipulasri , can you specify what are the contents of partialResultsListener object please? I would greatly appreciate your help.

:) [ Never mind, I figured it out by doing this]


 final PartialResultsListener partialResultsListener = new PartialResultsListener() {
                @Override
                public void onPartialResults(List<String> partialResults) {
                    secondTitleTxt.setText(partialResults.get(0));
                }
            };

            if (aiService instanceof GoogleRecognitionServiceImpl) {
                ((GoogleRecognitionServiceImpl) aiService).setPartialResultsListener(new PartialResultsListener() {
                    @Override
                    public void onPartialResults(final List<String> partialResults) {
                        if (partialResultsListener != null) {
                            partialResultsListener.onPartialResults(partialResults);
                        }
                    }
                });
            }

```Thank you!
son2017 commented 5 years ago

hi @kevinjmz i tryed with your code but its working fine but while runnig its take same voice message in multiple time do you have any idea?