Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Dialogflow ES: Not receiving response.query_result information in from streaming_detect_intent()

Hi:

I wrote a Python script to take audio from a microphone and process it using streaming_detect_intent(). I am using Dialogflow ES.  Since I am writing a custom integration, I disabled the web hook (not that this should matter). I tested the agent with the "try it now."

The problem is I don't get a query_result. The streaming seems to work. At some point recognition_result.is_final is True. However I am not getting query results. I do not see anything in the log.  My code is a modified version of the Python example. Any suggestions would be appreciated!

 

def sample_streaming_detect_intent(audio_queue, project_id, session_id, sample_rate):

    from google.cloud import dialogflow

    language_code = "en"
    session_client = dialogflow.SessionsClient()
    audio_encoding = dialogflow.AudioEncoding.AUDIO_ENCODING_LINEAR_16
    sample_rate_hertz = sample_rate
    session_path = session_client.session_path(project_id, session_id)
    print(f"Session path: {session_path}")

    def request_generator(audio_config):
        query_input = dialogflow.QueryInput(audio_config=audio_config)

        # The first request contains the configuration.
        yield dialogflow.StreamingDetectIntentRequest(
            session=session_path, query_input=query_input
        )

        while True:
            chunk = audio_queue.get()
            if not chunk:
                break
            # The later requests contains audio data.
            yield dialogflow.StreamingDetectIntentRequest(input_audio=chunk)

    audio_config = dialogflow.InputAudioConfig(
        audio_encoding=audio_encoding,
        language_code=language_code,
        sample_rate_hertz=sample_rate_hertz,
        single_utterance=False,
    )

    requests = request_generator(audio_config)
    responses = session_client.streaming_detect_intent(requests=requests)

    for response in responses:
        print(
            f"{response.recognition_result.is_final} intermediate transcript: {response.recognition_result.transcript}"
        )
        if response.recognition_result.is_final:
            print("=" * 20)
            print(f"Query text: {response.query_result.query_text}")
            print(f"Detected intent: {response.query_result.intent.action} confidence: {response.query_result.intent_detection_confidence}")
            print(f"Fulfillment text: {response.query_result.fulfillment_text}")

 

 

 

1 14 1,551