Coder Social home page Coder Social logo

Comments (3)

eniasebiomo avatar eniasebiomo commented on May 30, 2024

Having same issue

from python-dialogflow.

dysnomia avatar dysnomia commented on May 30, 2024

I noticed that if you don't group the audio chunks in a iterator collection (yield), they will not be handled as an unique stream when calling streaming_detect_intent(), so you need to process the stream until you somehow detects the audio input stopped or something similar and then deliver the iterator collection for detection, which is kind of silly since we could have detected intents prior to the end of the streaming (almost the same effect of recording the audio and then calling detect_intent()).

The generator you pass into sessions_client.streaming_detect_intent and the partial Speech recognition responses you get are processed concurrently. That is, you can make the generator dependent on the partial recognition results (http://dialogflow-python-client-v2.readthedocs.io/en/latest/gapic/v2/types.html#dialogflow_v2.types.StreamingDetectIntentResponse).

Stopping: In particular, you decide when to stop Speech recognition by exiting the generator based on whatever signals you want. If you set single_utterance to True (http://dialogflow-python-client-v2.readthedocs.io/en/latest/gapic/v2/types.html#dialogflow_v2.types.StreamingDetectIntentRequest.single_utterance), we will return a RECOGNITION_EVENT_END_OF_SINGLE_UTTERANCE event when we believe a Speech utterance has ended. You should then exit the generator (in fact we ignore further input audio).

Warning: As described in http://dialogflow-python-client-v2.readthedocs.io/en/latest/gapic/v2/types.html#dialogflow_v2.types.StreamingRecognitionResult you will get exactly one intent result per stream (returning multiple intents wouldn't have an obvious semantic). The main use of StreamingDetectIntent is to send audio that is being recorded from a microphone, get partial recognition results and then close the microphone after RECOGNITION_EVENT_END_OF_SINGLE_UTTERANCE. There is no significant advantage in using StreamingDetectIntent if you have prerecorded audio.

Is there a way to call it separately and inform it is the same stream for getting intermediate results, thus dynamically decide to stop streaming and process the results?

No, separate streams are fully independent of each other.

Please let me know whether that clarified the use of StreamingDetectIntent.

from python-dialogflow.

nnegrey avatar nnegrey commented on May 30, 2024

This appears to be answered, if not, please feel free to re-open.

Thanks! :)

from python-dialogflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.