Skip to content

Commit 28338df

Browse files
authored
get project and credentials from the ADC (#9502)
1 parent 47929f9 commit 28338df

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

dialogflow/analyze_content_stream_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ def participant_id(conversation_id):
7777
def test_analyze_content_audio_stream(capsys, conversation_id, participant_id):
7878
# Call StreamingAnalyzeContent to transcribe the audio.
7979
participant_management.analyze_content_audio_stream(
80-
project_id=PROJECT_ID,
8180
conversation_id=conversation_id,
8281
participant_id=participant_id,
8382
audio_file_path=AUDIO_FILE_PATH,

dialogflow/participant_management.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"""Dialogflow API Python sample showing how to manage Participants.
1717
"""
1818

19+
import google.auth
1920
from google.cloud import dialogflow_v2beta1 as dialogflow
2021

2122
ROLES = ["HUMAN_AGENT", "AUTOMATED_AGENT", "END_USER"]
@@ -112,12 +113,11 @@ def analyze_content_text(project_id, conversation_id, participant_id, text):
112113

113114
# [START dialogflow_analyze_content_audio_stream]
114115
def analyze_content_audio_stream(
115-
project_id, conversation_id, participant_id, audio_file_path
116+
conversation_id, participant_id, audio_file_path
116117
):
117118
"""Analyze audio content for END_USER
118119
119120
Args:
120-
project_id: The GCP project linked with the conversation profile.
121121
conversation_id: Id of the conversation.
122122
participant_id: Id of the participant.
123123
audio_file_path: audio file in wav/mp3 format contains utterances of END_USER."""
@@ -127,7 +127,8 @@ def analyze_content_audio_stream(
127127
# After completing all of your requests, call the "__exit__()" method to safely
128128
# clean up any remaining background resources. Alternatively, use the client as
129129
# a context manager.
130-
client = dialogflow.ParticipantsClient()
130+
credentials, project_id = google.auth.default()
131+
client = dialogflow.ParticipantsClient(credentials=credentials)
131132

132133
participant_path = client.participant_path(
133134
project_id, conversation_id, participant_id

0 commit comments

Comments
 (0)