Skip to content

Commit

Permalink
com.openai.unity 5.2.3 (#132)
Browse files Browse the repository at this point in the history
- switched audio encoding from wav to ogg
- changed Audio.TranscriptionRequest.Temperature int? -> float?
  • Loading branch information
StephenHodgson authored Nov 24, 2023
1 parent 58cd5a7 commit 786d090
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
1 change: 1 addition & 0 deletions Documentation~/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

---

Expand Down
14 changes: 7 additions & 7 deletions Runtime/Audio/AudioTranscriptionRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System;
using System.IO;
using UnityEngine;
using Utilities.Encoding.Wav;
using Utilities.Encoding.OggVorbis;

namespace OpenAI.Audio
{
Expand All @@ -13,7 +13,7 @@ public sealed class AudioTranscriptionRequest : IDisposable
/// Constructor.
/// </summary>
/// <param name="audioPath">
/// 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.
/// </param>
/// <param name="model">
/// ID of the model to use.
Expand Down Expand Up @@ -59,7 +59,7 @@ public AudioTranscriptionRequest(
/// The <see cref="AudioClip"/> to transcribe.
/// </param>
/// <param name="model">
/// ID of the model to use. Only whisper-1 is currently available.
/// ID of the model to use.
/// </param>
/// <param name="prompt">
/// Optional, An optional text to guide the model's style or continue a previous audio segment.<br/>
Expand Down Expand Up @@ -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)
{
}

Expand All @@ -105,7 +105,7 @@ public AudioTranscriptionRequest(
/// The name of the audio file to transcribe.
/// </param>
/// <param name="model">
/// ID of the model to use. Only whisper-1 is currently available.
/// ID of the model to use.
/// </param>
/// <param name="prompt">
/// Optional, An optional text to guide the model's style or continue a previous audio segment.<br/>
Expand Down Expand Up @@ -157,7 +157,7 @@ public AudioTranscriptionRequest(
~AudioTranscriptionRequest() => Dispose(false);

/// <summary>
/// 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.
/// </summary>
public Stream Audio { get; }

Expand All @@ -167,7 +167,7 @@ public AudioTranscriptionRequest(
public string AudioName { get; }

/// <summary>
/// ID of the model to use. Only whisper-1 is currently available.
/// ID of the model to use.
/// </summary>
public string Model { get; }

Expand Down
20 changes: 10 additions & 10 deletions Runtime/Audio/AudioTranslationRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System;
using System.IO;
using UnityEngine;
using Utilities.Encoding.Wav;
using Utilities.Encoding.OggVorbis;

namespace OpenAI.Audio
{
Expand All @@ -13,10 +13,10 @@ public sealed class AudioTranslationRequest : IDisposable
/// Constructor.
/// </summary>
/// <param name="audioPath">
/// 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.
/// </param>
/// <param name="model">
/// ID of the model to use. Only whisper-1 is currently available.
/// ID of the model to use.
/// </param>
/// <param name="prompt">
/// Optional, An optional text to guide the model's style or continue a previous audio segment.<br/>
Expand Down Expand Up @@ -49,7 +49,7 @@ public AudioTranslationRequest(
/// The <see cref="AudioClip"/> to translate.
/// </param>
/// <param name="model">
/// ID of the model to use. Only whisper-1 is currently available.
/// ID of the model to use.
/// </param>
/// <param name="prompt">
/// Optional, An optional text to guide the model's style or continue a previous audio segment.<br/>
Expand All @@ -70,16 +70,16 @@ 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)
{
}

/// <summary>
/// Constructor.
/// </summary>
/// <param name="audio">
/// 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.
/// </param>
/// <param name="audioName">
/// The name of the audio file to translate.
Expand Down Expand Up @@ -107,7 +107,7 @@ public AudioTranslationRequest(
string model = null,
string prompt = null,
AudioResponseFormat responseFormat = AudioResponseFormat.Json,
int? temperature = null)
float? temperature = null)
{
Audio = audio;

Expand Down Expand Up @@ -136,7 +136,7 @@ public AudioTranslationRequest(
public string AudioName { get; }

/// <summary>
/// ID of the model to use. Only whisper-1 is currently available.
/// ID of the model to use.
/// </summary>
public string Model { get; }

Expand All @@ -158,7 +158,7 @@ public AudioTranslationRequest(
/// the model will use log probability to automatically increase the temperature until certain thresholds are hit.<br/>
/// Defaults to 0
/// </summary>
public int? Temperature { get; }
public float? Temperature { get; }

private void Dispose(bool disposing)
{
Expand Down
3 changes: 2 additions & 1 deletion Runtime/OpenAI.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"references": [
"GUID:7958db66189566541a6363568aee1575",
"GUID:a6609af893242c7438d701ddd4cce46a",
"GUID:f7a0d77b5e1d79742a738fb859ee2f28"
"GUID:f7a0d77b5e1d79742a738fb859ee2f28",
"GUID:fe98ce187c2363b409d00954d687ec68"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": [
{
Expand Down

0 comments on commit 786d090

Please sign in to comment.