From 786d090443dbd94c48522fb209873b86c61920cb Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Fri, 24 Nov 2023 16:25:46 -0500 Subject: [PATCH] com.openai.unity 5.2.3 (#132) - switched audio encoding from wav to ogg - changed Audio.TranscriptionRequest.Temperature int? -> float? --- Documentation~/README.md | 1 + Runtime/Audio/AudioTranscriptionRequest.cs | 14 +++++++------- Runtime/Audio/AudioTranslationRequest.cs | 20 ++++++++++---------- Runtime/OpenAI.asmdef | 3 ++- package.json | 5 +++-- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Documentation~/README.md b/Documentation~/README.md index 473c767a..37e941b1 100644 --- a/Documentation~/README.md +++ b/Documentation~/README.md @@ -42,6 +42,7 @@ The recommended installation method is though the unity package manager and [Ope - [com.utilities.rest](https://github.com/RageAgainstThePixel/com.utilities.rest) - [com.utilities.audio](https://github.com/RageAgainstThePixel/com.utilities.audio) - [com.utilities.encoder.wav](https://github.com/RageAgainstThePixel/com.utilities.encoder.wav) + - [com.utilities.encoder.ogg](https://github.com/RageAgainstThePixel/com.utilities.encoder.ogg) --- diff --git a/Runtime/Audio/AudioTranscriptionRequest.cs b/Runtime/Audio/AudioTranscriptionRequest.cs index dc9cf10e..e4ad1862 100644 --- a/Runtime/Audio/AudioTranscriptionRequest.cs +++ b/Runtime/Audio/AudioTranscriptionRequest.cs @@ -3,7 +3,7 @@ using System; using System.IO; using UnityEngine; -using Utilities.Encoding.Wav; +using Utilities.Encoding.OggVorbis; namespace OpenAI.Audio { @@ -13,7 +13,7 @@ public sealed class AudioTranscriptionRequest : IDisposable /// Constructor. /// /// - /// The audio file to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm. + /// The audio file to transcribe, in one of these formats flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. /// /// /// ID of the model to use. @@ -59,7 +59,7 @@ public AudioTranscriptionRequest( /// The to transcribe. /// /// - /// ID of the model to use. Only whisper-1 is currently available. + /// ID of the model to use. /// /// /// Optional, An optional text to guide the model's style or continue a previous audio segment.
@@ -91,7 +91,7 @@ public AudioTranscriptionRequest( AudioResponseFormat responseFormat = AudioResponseFormat.Json, float? temperature = null, string language = null) - : this(new MemoryStream(audio.EncodeToWav()), $"{audio.name}.wav", model, prompt, responseFormat, temperature, language) + : this(new MemoryStream(audio.EncodeToOggVorbis()), $"{audio.name}.ogg", model, prompt, responseFormat, temperature, language) { } @@ -105,7 +105,7 @@ public AudioTranscriptionRequest( /// The name of the audio file to transcribe. /// /// - /// ID of the model to use. Only whisper-1 is currently available. + /// ID of the model to use. /// /// /// Optional, An optional text to guide the model's style or continue a previous audio segment.
@@ -157,7 +157,7 @@ public AudioTranscriptionRequest( ~AudioTranscriptionRequest() => Dispose(false); /// - /// The audio file to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm. + /// The audio file to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. /// public Stream Audio { get; } @@ -167,7 +167,7 @@ public AudioTranscriptionRequest( public string AudioName { get; } /// - /// ID of the model to use. Only whisper-1 is currently available. + /// ID of the model to use. /// public string Model { get; } diff --git a/Runtime/Audio/AudioTranslationRequest.cs b/Runtime/Audio/AudioTranslationRequest.cs index 96554abe..94ba692e 100644 --- a/Runtime/Audio/AudioTranslationRequest.cs +++ b/Runtime/Audio/AudioTranslationRequest.cs @@ -3,7 +3,7 @@ using System; using System.IO; using UnityEngine; -using Utilities.Encoding.Wav; +using Utilities.Encoding.OggVorbis; namespace OpenAI.Audio { @@ -13,10 +13,10 @@ public sealed class AudioTranslationRequest : IDisposable /// Constructor. /// /// - /// The audio file to translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm + /// The audio file to translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. /// /// - /// ID of the model to use. Only whisper-1 is currently available. + /// ID of the model to use. /// /// /// Optional, An optional text to guide the model's style or continue a previous audio segment.
@@ -49,7 +49,7 @@ public AudioTranslationRequest( /// The to translate. /// /// - /// ID of the model to use. Only whisper-1 is currently available. + /// ID of the model to use. /// /// /// Optional, An optional text to guide the model's style or continue a previous audio segment.
@@ -70,8 +70,8 @@ public AudioTranslationRequest( string model = null, string prompt = null, AudioResponseFormat responseFormat = AudioResponseFormat.Json, - int? temperature = null) - : this(new MemoryStream(audio.EncodeToWav()), $"{audio.name}.wav", model, prompt, responseFormat, temperature) + float? temperature = null) + : this(new MemoryStream(audio.EncodeToOggVorbis()), $"{audio.name}.ogg", model, prompt, responseFormat, temperature) { } @@ -79,7 +79,7 @@ public AudioTranslationRequest( /// Constructor. /// /// - /// The audio file to translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm. + /// The audio file to translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. /// /// /// The name of the audio file to translate. @@ -107,7 +107,7 @@ public AudioTranslationRequest( string model = null, string prompt = null, AudioResponseFormat responseFormat = AudioResponseFormat.Json, - int? temperature = null) + float? temperature = null) { Audio = audio; @@ -136,7 +136,7 @@ public AudioTranslationRequest( public string AudioName { get; } /// - /// ID of the model to use. Only whisper-1 is currently available. + /// ID of the model to use. /// public string Model { get; } @@ -158,7 +158,7 @@ public AudioTranslationRequest( /// the model will use log probability to automatically increase the temperature until certain thresholds are hit.
/// Defaults to 0 /// - public int? Temperature { get; } + public float? Temperature { get; } private void Dispose(bool disposing) { diff --git a/Runtime/OpenAI.asmdef b/Runtime/OpenAI.asmdef index e57354bf..46255867 100644 --- a/Runtime/OpenAI.asmdef +++ b/Runtime/OpenAI.asmdef @@ -4,7 +4,8 @@ "references": [ "GUID:7958db66189566541a6363568aee1575", "GUID:a6609af893242c7438d701ddd4cce46a", - "GUID:f7a0d77b5e1d79742a738fb859ee2f28" + "GUID:f7a0d77b5e1d79742a738fb859ee2f28", + "GUID:fe98ce187c2363b409d00954d687ec68" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/package.json b/package.json index 16fb8aba..270a090e 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "OpenAI", "description": "A OpenAI package for the Unity Game Engine to use GPT-4, GPT-3.5, GPT-3 and Dall-E though their RESTful API (currently in beta).\n\nIndependently developed, this is not an official library and I am not affiliated with OpenAI.\n\nAn OpenAI API account is required.", "keywords": [], - "version": "5.2.2", + "version": "5.2.3", "unity": "2021.3", "documentationUrl": "https://github.com/RageAgainstThePixel/com.openai.unity#documentation", "changelogUrl": "https://github.com/RageAgainstThePixel/com.openai.unity/releases", @@ -18,7 +18,8 @@ }, "dependencies": { "com.utilities.rest": "2.2.5", - "com.utilities.encoder.wav": "1.0.8" + "com.utilities.encoder.wav": "1.0.8", + "com.utilities.encoder.ogg": "3.0.12" }, "samples": [ {