From 9933716fa82412162e0ff377c28c493cef461eec Mon Sep 17 00:00:00 2001 From: Jose Arriaga Maldonado Date: Sun, 11 Aug 2024 21:11:40 -0700 Subject: [PATCH 1/2] Rename GenerateSpeechFromTest to GenerateSpeech --- .../src/Custom/Audio/AzureAudioClient.Protocol.cs | 4 ++-- .dotnet/api/OpenAI.netstandard2.0.cs | 8 ++++---- .dotnet/examples/Audio/Example01_SimpleTextToSpeech.cs | 2 +- .../examples/Audio/Example01_SimpleTextToSpeechAsync.cs | 2 +- .dotnet/examples/CombinationExamples.cs | 6 +++--- .dotnet/src/Custom/Audio/AudioClient.Protocol.cs | 4 ++-- .dotnet/src/Custom/Audio/AudioClient.cs | 8 ++++---- .dotnet/tests/Audio/TextToSpeechTests.cs | 8 ++++---- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.dotnet.azure/src/Custom/Audio/AzureAudioClient.Protocol.cs b/.dotnet.azure/src/Custom/Audio/AzureAudioClient.Protocol.cs index 98275f687..874b4f3be 100644 --- a/.dotnet.azure/src/Custom/Audio/AzureAudioClient.Protocol.cs +++ b/.dotnet.azure/src/Custom/Audio/AzureAudioClient.Protocol.cs @@ -41,14 +41,14 @@ public override async Task TranslateAudioAsync(BinaryContent conte } [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientResult GenerateSpeechFromText(BinaryContent content, RequestOptions options = null) + public override ClientResult GenerateSpeech(BinaryContent content, RequestOptions options = null) { using PipelineMessage message = CreateGenerateSpeechFromTextRequestMessage(content, options); return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } [EditorBrowsable(EditorBrowsableState.Never)] - public override async Task GenerateSpeechFromTextAsync(BinaryContent content, RequestOptions options = null) + public override async Task GenerateSpeechAsync(BinaryContent content, RequestOptions options = null) { using PipelineMessage message = CreateGenerateSpeechFromTextRequestMessage(content, options); PipelineResponse response = await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index a67971fb5..fa901d491 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -999,11 +999,11 @@ public class AudioClient { public AudioClient(string model, ApiKeyCredential credential); public virtual ClientPipeline Pipeline { get; } [EditorBrowsable(EditorBrowsableState.Never)] - public virtual ClientResult GenerateSpeechFromText(BinaryContent content, RequestOptions options = null); - public virtual ClientResult GenerateSpeechFromText(string text, GeneratedSpeechVoice voice, SpeechGenerationOptions options = null, CancellationToken cancellationToken = default); + public virtual ClientResult GenerateSpeech(BinaryContent content, RequestOptions options = null); + public virtual ClientResult GenerateSpeech(string text, GeneratedSpeechVoice voice, SpeechGenerationOptions options = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] - public virtual Task GenerateSpeechFromTextAsync(BinaryContent content, RequestOptions options = null); - public virtual Task> GenerateSpeechFromTextAsync(string text, GeneratedSpeechVoice voice, SpeechGenerationOptions options = null, CancellationToken cancellationToken = default); + public virtual Task GenerateSpeechAsync(BinaryContent content, RequestOptions options = null); + public virtual Task> GenerateSpeechAsync(string text, GeneratedSpeechVoice voice, SpeechGenerationOptions options = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual ClientResult TranscribeAudio(BinaryContent content, string contentType, RequestOptions options = null); public virtual ClientResult TranscribeAudio(Stream audio, string audioFilename, AudioTranscriptionOptions options = null, CancellationToken cancellationToken = default); diff --git a/.dotnet/examples/Audio/Example01_SimpleTextToSpeech.cs b/.dotnet/examples/Audio/Example01_SimpleTextToSpeech.cs index 79b8ac127..8573152ff 100644 --- a/.dotnet/examples/Audio/Example01_SimpleTextToSpeech.cs +++ b/.dotnet/examples/Audio/Example01_SimpleTextToSpeech.cs @@ -18,7 +18,7 @@ public void Example01_SimpleTextToSpeech() + " moisture, it is wise to postpone watering for a couple more days. When in doubt, it is often safer" + " to water sparingly and maintain a less-is-more approach."; - BinaryData speech = client.GenerateSpeechFromText(input, GeneratedSpeechVoice.Alloy); + BinaryData speech = client.GenerateSpeech(input, GeneratedSpeechVoice.Alloy); using FileStream stream = File.OpenWrite($"{Guid.NewGuid()}.mp3"); speech.ToStream().CopyTo(stream); diff --git a/.dotnet/examples/Audio/Example01_SimpleTextToSpeechAsync.cs b/.dotnet/examples/Audio/Example01_SimpleTextToSpeechAsync.cs index ae8432eb8..7226ae739 100644 --- a/.dotnet/examples/Audio/Example01_SimpleTextToSpeechAsync.cs +++ b/.dotnet/examples/Audio/Example01_SimpleTextToSpeechAsync.cs @@ -19,7 +19,7 @@ public async Task Example01_SimpleTextToSpeechAsync() + " moisture, it is wise to postpone watering for a couple more days. When in doubt, it is often safer" + " to water sparingly and maintain a less-is-more approach."; - BinaryData speech = await client.GenerateSpeechFromTextAsync(input, GeneratedSpeechVoice.Alloy); + BinaryData speech = await client.GenerateSpeechAsync(input, GeneratedSpeechVoice.Alloy); using FileStream stream = File.OpenWrite($"{Guid.NewGuid()}.mp3"); speech.ToStream().CopyTo(stream); diff --git a/.dotnet/examples/CombinationExamples.cs b/.dotnet/examples/CombinationExamples.cs index c4b460b1c..7987d81f2 100644 --- a/.dotnet/examples/CombinationExamples.cs +++ b/.dotnet/examples/CombinationExamples.cs @@ -48,7 +48,7 @@ public void AlpacaArtAssessor() // Finally, we'll get some text-to-speech for that critical evaluation using tts-1-hd: AudioClient audioClient = new("tts-1-hd", Environment.GetEnvironmentVariable("OPENAI_API_KEY")); - ClientResult ttsResult = audioClient.GenerateSpeechFromText( + ClientResult ttsResult = audioClient.GenerateSpeech( text: chatResponseText, GeneratedSpeechVoice.Fable, new SpeechGenerationOptions() @@ -84,7 +84,7 @@ public async Task CuriousCreatureCreator() // Asynchronously, in parallel to the next steps, we'll get the creative description in the voice of Onyx AudioClient ttsClient = new("tts-1-hd", Environment.GetEnvironmentVariable("OPENAI_API_KEY")); - Task> imageDescriptionAudioTask = ttsClient.GenerateSpeechFromTextAsync( + Task> imageDescriptionAudioTask = ttsClient.GenerateSpeechAsync( description, GeneratedSpeechVoice.Onyx, new SpeechGenerationOptions() @@ -131,7 +131,7 @@ public async Task CuriousCreatureCreator() Console.WriteLine($"Critic's appraisal:\n{appraisal}"); // Finally, we'll get that art expert's laudations in the voice of Fable - ClientResult appraisalAudioResult = await ttsClient.GenerateSpeechFromTextAsync( + ClientResult appraisalAudioResult = await ttsClient.GenerateSpeechAsync( appraisal, GeneratedSpeechVoice.Fable, new SpeechGenerationOptions() diff --git a/.dotnet/src/Custom/Audio/AudioClient.Protocol.cs b/.dotnet/src/Custom/Audio/AudioClient.Protocol.cs index ba0001627..0fd68c698 100644 --- a/.dotnet/src/Custom/Audio/AudioClient.Protocol.cs +++ b/.dotnet/src/Custom/Audio/AudioClient.Protocol.cs @@ -27,7 +27,7 @@ public partial class AudioClient /// Service returned a non-success status code. /// The response returned from the service. [EditorBrowsable(EditorBrowsableState.Never)] - public virtual async Task GenerateSpeechFromTextAsync(BinaryContent content, RequestOptions options = null) + public virtual async Task GenerateSpeechAsync(BinaryContent content, RequestOptions options = null) { Argument.AssertNotNull(content, nameof(content)); @@ -48,7 +48,7 @@ public virtual async Task GenerateSpeechFromTextAsync(BinaryConten /// Service returned a non-success status code. /// The response returned from the service. [EditorBrowsable(EditorBrowsableState.Never)] - public virtual ClientResult GenerateSpeechFromText(BinaryContent content, RequestOptions options = null) + public virtual ClientResult GenerateSpeech(BinaryContent content, RequestOptions options = null) { Argument.AssertNotNull(content, nameof(content)); diff --git a/.dotnet/src/Custom/Audio/AudioClient.cs b/.dotnet/src/Custom/Audio/AudioClient.cs index fff3bc7db..58c0e49a8 100644 --- a/.dotnet/src/Custom/Audio/AudioClient.cs +++ b/.dotnet/src/Custom/Audio/AudioClient.cs @@ -93,7 +93,7 @@ protected internal AudioClient(ClientPipeline pipeline, string model, OpenAIClie /// A token that can be used to cancel this method call. /// is null. /// The generated audio in the specified output format. - public virtual async Task> GenerateSpeechFromTextAsync(string text, GeneratedSpeechVoice voice, SpeechGenerationOptions options = null, CancellationToken cancellationToken = default) + public virtual async Task> GenerateSpeechAsync(string text, GeneratedSpeechVoice voice, SpeechGenerationOptions options = null, CancellationToken cancellationToken = default) { Argument.AssertNotNull(text, nameof(text)); @@ -101,7 +101,7 @@ public virtual async Task> GenerateSpeechFromTextAsync( CreateSpeechGenerationOptions(text, voice, ref options); using BinaryContent content = options.ToBinaryContent(); - ClientResult result = await GenerateSpeechFromTextAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + ClientResult result = await GenerateSpeechAsync(content, cancellationToken.ToRequestOptions()).ConfigureAwait(false); return ClientResult.FromValue(result.GetRawResponse().Content, result.GetRawResponse()); } @@ -116,7 +116,7 @@ public virtual async Task> GenerateSpeechFromTextAsync( /// A token that can be used to cancel this method call. /// is null. /// The generated audio in the specified output format. - public virtual ClientResult GenerateSpeechFromText(string text, GeneratedSpeechVoice voice, SpeechGenerationOptions options = null, CancellationToken cancellationToken = default) + public virtual ClientResult GenerateSpeech(string text, GeneratedSpeechVoice voice, SpeechGenerationOptions options = null, CancellationToken cancellationToken = default) { Argument.AssertNotNull(text, nameof(text)); @@ -124,7 +124,7 @@ public virtual ClientResult GenerateSpeechFromText(string text, Gene CreateSpeechGenerationOptions(text, voice, ref options); using BinaryContent content = options.ToBinaryContent(); - ClientResult result = GenerateSpeechFromText(content, cancellationToken.ToRequestOptions()); ; + ClientResult result = GenerateSpeech(content, cancellationToken.ToRequestOptions()); ; return ClientResult.FromValue(result.GetRawResponse().Content, result.GetRawResponse()); } diff --git a/.dotnet/tests/Audio/TextToSpeechTests.cs b/.dotnet/tests/Audio/TextToSpeechTests.cs index c3753e149..cbbd748d1 100644 --- a/.dotnet/tests/Audio/TextToSpeechTests.cs +++ b/.dotnet/tests/Audio/TextToSpeechTests.cs @@ -23,8 +23,8 @@ public async Task BasicTextToSpeechWorks() AudioClient client = GetTestClient(TestScenario.Audio_TTS); BinaryData audio = IsAsync - ? await client.GenerateSpeechFromTextAsync("Hello, world! This is a test.", GeneratedSpeechVoice.Shimmer) - : client.GenerateSpeechFromText("Hello, world! This is a test.", GeneratedSpeechVoice.Shimmer); + ? await client.GenerateSpeechAsync("Hello, world! This is a test.", GeneratedSpeechVoice.Shimmer) + : client.GenerateSpeech("Hello, world! This is a test.", GeneratedSpeechVoice.Shimmer); Assert.That(audio, Is.Not.Null); ValidateGeneratedAudio(audio, "hello"); @@ -47,8 +47,8 @@ public async Task OutputFormatWorks(GeneratedSpeechFormat? responseFormat) : new() { ResponseFormat = responseFormat }; BinaryData audio = IsAsync - ? await client.GenerateSpeechFromTextAsync("Hello, world!", GeneratedSpeechVoice.Alloy, options) - : client.GenerateSpeechFromText("Hello, world!", GeneratedSpeechVoice.Alloy, options); + ? await client.GenerateSpeechAsync("Hello, world!", GeneratedSpeechVoice.Alloy, options) + : client.GenerateSpeech("Hello, world!", GeneratedSpeechVoice.Alloy, options); Assert.That(audio, Is.Not.Null); } From 830b15fa55da446f5667f74a596b7cee6efc19a6 Mon Sep 17 00:00:00 2001 From: Jose Arriaga Maldonado Date: Sat, 24 Aug 2024 17:00:22 -0700 Subject: [PATCH 2/2] Update CHANGELOG --- .dotnet/CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.dotnet/CHANGELOG.md b/.dotnet/CHANGELOG.md index d8777eb6a..57f50e663 100644 --- a/.dotnet/CHANGELOG.md +++ b/.dotnet/CHANGELOG.md @@ -1,5 +1,17 @@ # Release History +## 2.0.0-beta.10 (Unreleased) + +### Features Added + +### Breaking Changes + +- Renamed `AudioClient`'s `GenerateSpeechFromText` methods to simply `GenerateSpeech`. (commit_hash) + +### Bugs Fixed + +### Other Changes + ## 2.0.0-beta.9 (2024-08-23) ### Features Added