25
25
import argparse
26
26
import uuid
27
27
28
+ from google .cloud .dialogflowcx_v3beta1 .services .agents import AgentsClient
28
29
from google .cloud .dialogflowcx_v3beta1 .services .sessions import SessionsClient
29
30
from google .cloud .dialogflowcx_v3beta1 .types import audio_config
30
31
from google .cloud .dialogflowcx_v3beta1 .types import session
34
35
def run_sample ():
35
36
# TODO(developer): Replace these values when running the function
36
37
project_id = "YOUR-PROJECT-ID"
38
+ # For more information about regionalization see https://cloud.google.com/dialogflow/cx/docs/how/region
37
39
location_id = "YOUR-LOCATION-ID"
38
40
# For more info on agents see https://cloud.google.com/dialogflow/cx/docs/concept/agent
39
41
agent_id = "YOUR-AGENT-ID"
@@ -52,9 +54,16 @@ def detect_intent_stream(agent, session_id, audio_file_path, language_code):
52
54
53
55
Using the same `session_id` between requests allows continuation
54
56
of the conversation."""
55
- session_client = SessionsClient ()
56
57
session_path = f"{ agent } /sessions/{ session_id } "
57
58
print (f"Session path: { session_path } \n " )
59
+ client_options = None
60
+ agent_components = AgentsClient .parse_agent_path (agent )
61
+ location_id = agent_components ["location" ]
62
+ if location_id != "global" :
63
+ api_endpoint = f"{ location_id } -dialogflow.googleapis.com:443"
64
+ print (f"API Endpoint: { api_endpoint } \n " )
65
+ client_options = {"api_endpoint" : api_endpoint }
66
+ session_client = SessionsClient (client_options = client_options )
58
67
59
68
input_audio_config = audio_config .InputAudioConfig (
60
69
audio_encoding = audio_config .AudioEncoding .AUDIO_ENCODING_LINEAR_16 ,
0 commit comments