Skip to content

Commit

Permalink
feat: Added StreamingAnalyzeContent API
Browse files Browse the repository at this point in the history
feat: Added obfuscated_external_user_id to Participant
feat: Can directly set Cloud Speech model on the SpeechToTextConfig

PiperOrigin-RevId: 483696090

Source-Link: googleapis/googleapis@3772bf3

Source-Link: googleapis/googleapis-gen@e358d26
Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuQ2xvdWQuRGlhbG9nZmxvdy5WMi8uT3dsQm90LnlhbWwiLCJoIjoiZTM1OGQyNjliMWYwZWI5OTY0MTg5ZDE4NzY4ODIzYmM5ZThhYjQxYyJ9
  • Loading branch information
gcf-owl-bot[bot] authored and jskeet committed Oct 25, 2022
1 parent 8aa3a16 commit bdfcd9e
Show file tree
Hide file tree
Showing 10 changed files with 2,634 additions and 256 deletions.
@@ -0,0 +1,85 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace Google.Cloud.Dialogflow.V2.Snippets
{
// [START dialogflow_v2_generated_Participants_StreamingAnalyzeContent_sync]
using Google.Api.Gax.Grpc;
using Google.Cloud.Dialogflow.V2;
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using System.Threading.Tasks;

public sealed partial class GeneratedParticipantsClientSnippets
{
/// <summary>Snippet for StreamingAnalyzeContent</summary>
/// <remarks>
/// This snippet has been automatically generated for illustrative purposes only.
/// It may require modifications to work in your environment.
/// </remarks>
public async Task StreamingAnalyzeContent()
{
// Create client
ParticipantsClient participantsClient = ParticipantsClient.Create();
// Initialize streaming call, retrieving the stream object
ParticipantsClient.StreamingAnalyzeContentStream response = participantsClient.StreamingAnalyzeContent();

// Sending requests and retrieving responses can be arbitrarily interleaved
// Exact sequence will depend on client/server behavior

// Create task to do something with responses from server
Task responseHandlerTask = Task.Run(async () =>
{
// Note that C# 8 code can use await foreach
AsyncResponseStream<StreamingAnalyzeContentResponse> responseStream = response.GetResponseStream();
while (await responseStream.MoveNextAsync())
{
StreamingAnalyzeContentResponse responseItem = responseStream.Current;
// Do something with streamed response
}
// The response stream has completed
});

// Send requests to the server
bool done = false;
while (!done)
{
// Initialize a request
StreamingAnalyzeContentRequest request = new StreamingAnalyzeContentRequest
{
ParticipantAsParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
AudioConfig = new InputAudioConfig(),
ReplyAudioConfig = new OutputAudioConfig(),
InputAudio = ByteString.Empty,
QueryParams = new QueryParameters(),
AssistQueryParams = new AssistQueryParameters(),
EnablePartialAutomatedAgentReply = false,
CxParameters = new Struct(),
};
// Stream a request to the server
await response.WriteAsync(request);
// Set "done" to true when sending requests is complete
}

// Complete writing requests to the stream
await response.WriteCompleteAsync();
// Await the response handler
// This will complete once all server responses have been processed
await responseHandlerTask;
}
}
// [END dialogflow_v2_generated_Participants_StreamingAnalyzeContent_sync]
}
Expand Up @@ -12756,6 +12756,32 @@
},
"origin": "API_DEFINITION"
},
{
"regionTag": "dialogflow_v2_generated_Participants_StreamingAnalyzeContent_sync",
"title": "StreamingAnalyzeContent",
"description": "Snippet for StreamingAnalyzeContent",
"file": "ParticipantsClient.StreamingAnalyzeContentSnippet.g.cs",
"language": "C_SHARP",
"clientMethod": {
"shortName": "StreamingAnalyzeContent",
"fullName": "Google.Cloud.Dialogflow.V2.ParticipantsClient.StreamingAnalyzeContent",
"resultType": "Google.Cloud.Dialogflow.V2.ParticipantsClient+StreamingAnalyzeContentStream",
"client": {
"shortName": "ParticipantsClient",
"fullName": "Google.Cloud.Dialogflow.V2.ParticipantsClient"
},
"method": {
"shortName": "StreamingAnalyzeContent",
"fullName": "google.cloud.dialogflow.v2.Participants.StreamingAnalyzeContent",
"service": {
"shortName": "Participants",
"fullName": "google.cloud.dialogflow.v2.Participants"
}
}
},
"canonical": true,
"origin": "API_DEFINITION"
},
{
"regionTag": "dialogflow_v2_generated_Participants_SuggestArticles_sync",
"title": "SuggestArticlesRequestObject",
Expand Down
Expand Up @@ -17,6 +17,8 @@
namespace Google.Cloud.Dialogflow.V2.Snippets
{
using Google.Api.Gax;
using Google.Api.Gax.Grpc;
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using System;
using System.Linq;
Expand Down Expand Up @@ -706,6 +708,60 @@ public async Task AnalyzeContent2ResourceNamesAsync()
// End snippet
}

/// <summary>Snippet for StreamingAnalyzeContent</summary>
public async Task StreamingAnalyzeContent()
{
// Snippet: StreamingAnalyzeContent(CallSettings, BidirectionalStreamingSettings)
// Create client
ParticipantsClient participantsClient = ParticipantsClient.Create();
// Initialize streaming call, retrieving the stream object
ParticipantsClient.StreamingAnalyzeContentStream response = participantsClient.StreamingAnalyzeContent();

// Sending requests and retrieving responses can be arbitrarily interleaved
// Exact sequence will depend on client/server behavior

// Create task to do something with responses from server
Task responseHandlerTask = Task.Run(async () =>
{
// Note that C# 8 code can use await foreach
AsyncResponseStream<StreamingAnalyzeContentResponse> responseStream = response.GetResponseStream();
while (await responseStream.MoveNextAsync())
{
StreamingAnalyzeContentResponse responseItem = responseStream.Current;
// Do something with streamed response
}
// The response stream has completed
});

// Send requests to the server
bool done = false;
while (!done)
{
// Initialize a request
StreamingAnalyzeContentRequest request = new StreamingAnalyzeContentRequest
{
ParticipantAsParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
AudioConfig = new InputAudioConfig(),
ReplyAudioConfig = new OutputAudioConfig(),
InputAudio = ByteString.Empty,
QueryParams = new QueryParameters(),
AssistQueryParams = new AssistQueryParameters(),
EnablePartialAutomatedAgentReply = false,
CxParameters = new Struct(),
};
// Stream a request to the server
await response.WriteAsync(request);
// Set "done" to true when sending requests is complete
}

// Complete writing requests to the stream
await response.WriteCompleteAsync();
// Await the response handler
// This will complete once all server responses have been processed
await responseHandlerTask;
// End snippet
}

/// <summary>Snippet for SuggestArticles</summary>
public void SuggestArticlesRequestObject()
{
Expand Down
Expand Up @@ -44,6 +44,7 @@ public void CreateParticipantRequestObject()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -74,6 +75,7 @@ public void CreateParticipantRequestObject()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -106,6 +108,7 @@ public void CreateParticipant()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -136,6 +139,7 @@ public void CreateParticipant()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -168,6 +172,7 @@ public void CreateParticipantResourceNames()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -198,6 +203,7 @@ public void CreateParticipantResourceNames()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -229,6 +235,7 @@ public void GetParticipantRequestObject()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -258,6 +265,7 @@ public void GetParticipantRequestObject()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -289,6 +297,7 @@ public void GetParticipant()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -318,6 +327,7 @@ public void GetParticipant()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -349,6 +359,7 @@ public void GetParticipantResourceNames()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -378,6 +389,7 @@ public void GetParticipantResourceNames()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -410,6 +422,7 @@ public void UpdateParticipantRequestObject()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -440,6 +453,7 @@ public void UpdateParticipantRequestObject()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -472,6 +486,7 @@ public void UpdateParticipant()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down Expand Up @@ -502,6 +517,7 @@ public void UpdateParticipant()
ParticipantName = ParticipantName.FromProjectConversationParticipant("[PROJECT]", "[CONVERSATION]", "[PARTICIPANT]"),
Role = Participant.Types.Role.HumanAgent,
SipRecordingMediaLabel = "sip_recording_media_labela9ddfd5d",
ObfuscatedExternalUserId = "obfuscated_external_user_id5424dfb8",
DocumentsMetadataFilters =
{
{
Expand Down

0 comments on commit bdfcd9e

Please sign in to comment.