-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor string enum conversion factory added a way to enable debugging of json payload content
- Loading branch information
1 parent
e69beca
commit 34b0d8f
Showing
22 changed files
with
268 additions
and
193 deletions.
There are no files selected for viewing
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
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
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
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 @@ | ||
using System.Text.Json.Serialization; | ||
using OpenAI.Extensions; | ||
using OpenAI.Models; | ||
|
||
namespace OpenAI.Audio | ||
{ | ||
public sealed class SpeechRequest | ||
{ | ||
/// <summary> | ||
/// Constructor. | ||
/// </summary> | ||
/// <param name="input">The text to generate audio for. The maximum length is 4096 characters.</param> | ||
/// <param name="model">One of the available TTS models. Defaults to tts-1.</param> | ||
/// <param name="voice">The voice to use when generating the audio.</param> | ||
/// <param name="responseFormat">The format to audio in. Supported formats are mp3, opus, aac, and flac.</param> | ||
/// <param name="speed">The speed of the generated audio. Select a value from 0.25 to 4.0. 1.0 is the default.</param> | ||
public SpeechRequest(string input, Model model = null, SpeechVoice voice = SpeechVoice.Alloy, SpeechResponseFormat responseFormat = SpeechResponseFormat.MP3, float? speed = null) | ||
{ | ||
Input = input; | ||
Model = string.IsNullOrWhiteSpace(model?.Id) ? Models.Model.TTS_1 : model; | ||
Voice = voice; | ||
ResponseFormat = responseFormat; | ||
Speed = speed; | ||
} | ||
|
||
[JsonPropertyName("model")] | ||
public string Model { get; } | ||
|
||
[JsonPropertyName("input")] | ||
public string Input { get; } | ||
|
||
[JsonPropertyName("voice")] | ||
public SpeechVoice Voice { get; } | ||
|
||
[JsonPropertyName("response_format")] | ||
[JsonIgnore(Condition = JsonIgnoreCondition.Never)] | ||
[JsonConverter(typeof(JsonStringEnumConverter<SpeechResponseFormat>))] | ||
public SpeechResponseFormat ResponseFormat { get; } | ||
|
||
[JsonPropertyName("speed")] | ||
public float? Speed { get; } | ||
} | ||
} |
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,16 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace OpenAI.Audio | ||
{ | ||
public enum SpeechResponseFormat | ||
{ | ||
[EnumMember(Value = "mp3")] | ||
MP3, | ||
[EnumMember(Value = "opus")] | ||
Opus, | ||
[EnumMember(Value = "aac")] | ||
AAC, | ||
[EnumMember(Value = "flac")] | ||
Flac | ||
} | ||
} |
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,12 @@ | ||
namespace OpenAI.Audio | ||
{ | ||
public enum SpeechVoice | ||
{ | ||
Alloy = 0, | ||
Echo, | ||
Fable, | ||
Onyx, | ||
Nova, | ||
Shimmer | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,16 +1,10 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace OpenAI.Chat | ||
{ | ||
public enum Role | ||
{ | ||
[EnumMember(Value = "system")] | ||
System = 1, | ||
[EnumMember(Value = "assistant")] | ||
Assistant = 2, | ||
[EnumMember(Value = "user")] | ||
User = 3, | ||
[EnumMember(Value = "function")] | ||
Function = 4, | ||
Assistant, | ||
User, | ||
Function, | ||
} | ||
} |
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
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.