in genesyscloud/genesyscloud-audiohook/dialogflow_api.py [0:0]
def generator_streaming_analyze_content_request(
self,
audio_config: dialogflow.InputAudioConfig,
participant: dialogflow.Participant,
audio_stream: Stream):
"""Generates and return an iterator for StreamingAnalyzeContentRequest,
The first request should only include the input_audio_config
And the following request contains the audio chunks as input_audio.
The last request does not have any input_audio or input_audio_config and indicates that
the server side is half-closing the streaming
Args:
audio_config (dialogflow.InputAudioConfig): Input for Speech Recognizer
https://cloud.google.com/dialogflow/es/docs/reference/rest/v2beta1/InputAudioConfig
participant (dialogflow.Participant): Participant for the Dialogflow API call
audio_queue (asyncio.Queue): Queue to store the audio binary stream
Yields:
_type_: first filed the audio config, and then yield the binary data.
"""
# Sending audio_config for participant
enable_debugging_info = config.log_level.upper() == "DEBUG"
generator = audio_stream.generator()
yield dialogflow.StreamingAnalyzeContentRequest(
participant=participant.name,
audio_config=audio_config,
enable_debugging_info=enable_debugging_info,
)
for content in generator:
# next audio chunks to streaming_analyze_content
yield dialogflow.StreamingAnalyzeContentRequest(
input_audio=content,
enable_debugging_info=enable_debugging_info,
)
logging.info(
"Participant: %s, streaming analyze content request, end streaming yield an empty request ",
participant.name)
yield dialogflow.StreamingAnalyzeContentRequest(
enable_debugging_info=enable_debugging_info,
)
logging.debug(
"Ending the current audio stream session, start new session")