-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: StreamingSynthesize now supports opus
PiperOrigin-RevId: 707168599 Source-Link: googleapis/googleapis@d985436 Source-Link: googleapis/googleapis-gen@3fcc3af Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuQ2xvdWQuVGV4dFRvU3BlZWNoLlYxQmV0YTEvLk93bEJvdC55YW1sIiwiaCI6IjNmY2MzYWZiZjhjOTIwODRjYzRhMzAyMzJhNzZjYTI0NzQ4OWMzZDAifQ==
- Loading branch information
1 parent
8c0fdf1
commit f3023c2
Showing
27 changed files
with
10,427 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
...eech.V1Beta1.GeneratedSnippets/Google.Cloud.TextToSpeech.V1Beta1.GeneratedSnippets.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net6.0;net462</TargetFrameworks> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="../Google.Cloud.TextToSpeech.V1Beta1/Google.Cloud.TextToSpeech.V1Beta1.csproj" /> | ||
<PackageReference Include="System.Linq.Async" Version="6.0.1" /> | ||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" /> | ||
</ItemGroup> | ||
|
||
</Project> |
44 changes: 44 additions & 0 deletions
44
...oud.TextToSpeech.V1Beta1.GeneratedSnippets/TextToSpeechClient.ListVoicesAsyncSnippet.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2024 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 GoogleCSharpSnippets | ||
{ | ||
// [START texttospeech_v1beta1_generated_TextToSpeech_ListVoices_async_flattened] | ||
using Google.Cloud.TextToSpeech.V1Beta1; | ||
using System.Threading.Tasks; | ||
|
||
public sealed partial class GeneratedTextToSpeechClientSnippets | ||
{ | ||
/// <summary>Snippet for ListVoicesAsync</summary> | ||
/// <remarks> | ||
/// This snippet has been automatically generated and should be regarded as a code template only. | ||
/// It will require modifications to work: | ||
/// - It may require correct/in-range values for request initialization. | ||
/// - It may require specifying regional endpoints when creating the service client as shown in | ||
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. | ||
/// </remarks> | ||
public async Task ListVoicesAsync() | ||
{ | ||
// Create client | ||
TextToSpeechClient textToSpeechClient = await TextToSpeechClient.CreateAsync(); | ||
// Initialize request argument(s) | ||
string languageCode = ""; | ||
// Make the request | ||
ListVoicesResponse response = await textToSpeechClient.ListVoicesAsync(languageCode); | ||
} | ||
} | ||
// [END texttospeech_v1beta1_generated_TextToSpeech_ListVoices_async_flattened] | ||
} |
44 changes: 44 additions & 0 deletions
44
...ech.V1Beta1.GeneratedSnippets/TextToSpeechClient.ListVoicesRequestObjectAsyncSnippet.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2024 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 GoogleCSharpSnippets | ||
{ | ||
// [START texttospeech_v1beta1_generated_TextToSpeech_ListVoices_async] | ||
using Google.Cloud.TextToSpeech.V1Beta1; | ||
using System.Threading.Tasks; | ||
|
||
public sealed partial class GeneratedTextToSpeechClientSnippets | ||
{ | ||
/// <summary>Snippet for ListVoicesAsync</summary> | ||
/// <remarks> | ||
/// This snippet has been automatically generated and should be regarded as a code template only. | ||
/// It will require modifications to work: | ||
/// - It may require correct/in-range values for request initialization. | ||
/// - It may require specifying regional endpoints when creating the service client as shown in | ||
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. | ||
/// </remarks> | ||
public async Task ListVoicesRequestObjectAsync() | ||
{ | ||
// Create client | ||
TextToSpeechClient textToSpeechClient = await TextToSpeechClient.CreateAsync(); | ||
// Initialize request argument(s) | ||
ListVoicesRequest request = new ListVoicesRequest { LanguageCode = "", }; | ||
// Make the request | ||
ListVoicesResponse response = await textToSpeechClient.ListVoicesAsync(request); | ||
} | ||
} | ||
// [END texttospeech_v1beta1_generated_TextToSpeech_ListVoices_async] | ||
} |
43 changes: 43 additions & 0 deletions
43
...ToSpeech.V1Beta1.GeneratedSnippets/TextToSpeechClient.ListVoicesRequestObjectSnippet.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2024 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 GoogleCSharpSnippets | ||
{ | ||
// [START texttospeech_v1beta1_generated_TextToSpeech_ListVoices_sync] | ||
using Google.Cloud.TextToSpeech.V1Beta1; | ||
|
||
public sealed partial class GeneratedTextToSpeechClientSnippets | ||
{ | ||
/// <summary>Snippet for ListVoices</summary> | ||
/// <remarks> | ||
/// This snippet has been automatically generated and should be regarded as a code template only. | ||
/// It will require modifications to work: | ||
/// - It may require correct/in-range values for request initialization. | ||
/// - It may require specifying regional endpoints when creating the service client as shown in | ||
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. | ||
/// </remarks> | ||
public void ListVoicesRequestObject() | ||
{ | ||
// Create client | ||
TextToSpeechClient textToSpeechClient = TextToSpeechClient.Create(); | ||
// Initialize request argument(s) | ||
ListVoicesRequest request = new ListVoicesRequest { LanguageCode = "", }; | ||
// Make the request | ||
ListVoicesResponse response = textToSpeechClient.ListVoices(request); | ||
} | ||
} | ||
// [END texttospeech_v1beta1_generated_TextToSpeech_ListVoices_sync] | ||
} |
43 changes: 43 additions & 0 deletions
43
...le.Cloud.TextToSpeech.V1Beta1.GeneratedSnippets/TextToSpeechClient.ListVoicesSnippet.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2024 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 GoogleCSharpSnippets | ||
{ | ||
// [START texttospeech_v1beta1_generated_TextToSpeech_ListVoices_sync_flattened] | ||
using Google.Cloud.TextToSpeech.V1Beta1; | ||
|
||
public sealed partial class GeneratedTextToSpeechClientSnippets | ||
{ | ||
/// <summary>Snippet for ListVoices</summary> | ||
/// <remarks> | ||
/// This snippet has been automatically generated and should be regarded as a code template only. | ||
/// It will require modifications to work: | ||
/// - It may require correct/in-range values for request initialization. | ||
/// - It may require specifying regional endpoints when creating the service client as shown in | ||
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. | ||
/// </remarks> | ||
public void ListVoices() | ||
{ | ||
// Create client | ||
TextToSpeechClient textToSpeechClient = TextToSpeechClient.Create(); | ||
// Initialize request argument(s) | ||
string languageCode = ""; | ||
// Make the request | ||
ListVoicesResponse response = textToSpeechClient.ListVoices(languageCode); | ||
} | ||
} | ||
// [END texttospeech_v1beta1_generated_TextToSpeech_ListVoices_sync_flattened] | ||
} |
79 changes: 79 additions & 0 deletions
79
...TextToSpeech.V1Beta1.GeneratedSnippets/TextToSpeechClient.StreamingSynthesizeSnippet.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright 2024 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 GoogleCSharpSnippets | ||
{ | ||
// [START texttospeech_v1beta1_generated_TextToSpeech_StreamingSynthesize_sync] | ||
using Google.Api.Gax.Grpc; | ||
using Google.Cloud.TextToSpeech.V1Beta1; | ||
using System.Threading.Tasks; | ||
|
||
public sealed partial class GeneratedTextToSpeechClientSnippets | ||
{ | ||
/// <summary>Snippet for StreamingSynthesize</summary> | ||
/// <remarks> | ||
/// This snippet has been automatically generated and should be regarded as a code template only. | ||
/// It will require modifications to work: | ||
/// - It may require correct/in-range values for request initialization. | ||
/// - It may require specifying regional endpoints when creating the service client as shown in | ||
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. | ||
/// </remarks> | ||
public async Task StreamingSynthesize() | ||
{ | ||
// Create client | ||
TextToSpeechClient textToSpeechClient = TextToSpeechClient.Create(); | ||
// Initialize streaming call, retrieving the stream object | ||
using TextToSpeechClient.StreamingSynthesizeStream response = textToSpeechClient.StreamingSynthesize(); | ||
|
||
// 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<StreamingSynthesizeResponse> responseStream = response.GetResponseStream(); | ||
while (await responseStream.MoveNextAsync()) | ||
{ | ||
StreamingSynthesizeResponse 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 | ||
StreamingSynthesizeRequest request = new StreamingSynthesizeRequest | ||
{ | ||
StreamingConfig = new StreamingSynthesizeConfig(), | ||
}; | ||
// 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 texttospeech_v1beta1_generated_TextToSpeech_StreamingSynthesize_sync] | ||
} |
46 changes: 46 additions & 0 deletions
46
...xtToSpeech.V1Beta1.GeneratedSnippets/TextToSpeechClient.SynthesizeSpeechAsyncSnippet.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2024 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 GoogleCSharpSnippets | ||
{ | ||
// [START texttospeech_v1beta1_generated_TextToSpeech_SynthesizeSpeech_async_flattened] | ||
using Google.Cloud.TextToSpeech.V1Beta1; | ||
using System.Threading.Tasks; | ||
|
||
public sealed partial class GeneratedTextToSpeechClientSnippets | ||
{ | ||
/// <summary>Snippet for SynthesizeSpeechAsync</summary> | ||
/// <remarks> | ||
/// This snippet has been automatically generated and should be regarded as a code template only. | ||
/// It will require modifications to work: | ||
/// - It may require correct/in-range values for request initialization. | ||
/// - It may require specifying regional endpoints when creating the service client as shown in | ||
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. | ||
/// </remarks> | ||
public async Task SynthesizeSpeechAsync() | ||
{ | ||
// Create client | ||
TextToSpeechClient textToSpeechClient = await TextToSpeechClient.CreateAsync(); | ||
// Initialize request argument(s) | ||
SynthesisInput input = new SynthesisInput(); | ||
VoiceSelectionParams voice = new VoiceSelectionParams(); | ||
AudioConfig audioConfig = new AudioConfig(); | ||
// Make the request | ||
SynthesizeSpeechResponse response = await textToSpeechClient.SynthesizeSpeechAsync(input, voice, audioConfig); | ||
} | ||
} | ||
// [END texttospeech_v1beta1_generated_TextToSpeech_SynthesizeSpeech_async_flattened] | ||
} |
54 changes: 54 additions & 0 deletions
54
...Beta1.GeneratedSnippets/TextToSpeechClient.SynthesizeSpeechRequestObjectAsyncSnippet.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2024 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 GoogleCSharpSnippets | ||
{ | ||
// [START texttospeech_v1beta1_generated_TextToSpeech_SynthesizeSpeech_async] | ||
using Google.Cloud.TextToSpeech.V1Beta1; | ||
using System.Threading.Tasks; | ||
|
||
public sealed partial class GeneratedTextToSpeechClientSnippets | ||
{ | ||
/// <summary>Snippet for SynthesizeSpeechAsync</summary> | ||
/// <remarks> | ||
/// This snippet has been automatically generated and should be regarded as a code template only. | ||
/// It will require modifications to work: | ||
/// - It may require correct/in-range values for request initialization. | ||
/// - It may require specifying regional endpoints when creating the service client as shown in | ||
/// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. | ||
/// </remarks> | ||
public async Task SynthesizeSpeechRequestObjectAsync() | ||
{ | ||
// Create client | ||
TextToSpeechClient textToSpeechClient = await TextToSpeechClient.CreateAsync(); | ||
// Initialize request argument(s) | ||
SynthesizeSpeechRequest request = new SynthesizeSpeechRequest | ||
{ | ||
Input = new SynthesisInput(), | ||
Voice = new VoiceSelectionParams(), | ||
AudioConfig = new AudioConfig(), | ||
EnableTimePointing = | ||
{ | ||
SynthesizeSpeechRequest.Types.TimepointType.Unspecified, | ||
}, | ||
AdvancedVoiceOptions = new AdvancedVoiceOptions(), | ||
}; | ||
// Make the request | ||
SynthesizeSpeechResponse response = await textToSpeechClient.SynthesizeSpeechAsync(request); | ||
} | ||
} | ||
// [END texttospeech_v1beta1_generated_TextToSpeech_SynthesizeSpeech_async] | ||
} |
Oops, something went wrong.