Skip to content

Commit

Permalink
Update to enable override to text to speech
Browse files Browse the repository at this point in the history
  • Loading branch information
Layoric committed Oct 14, 2024
1 parent c8d6ace commit cf900b1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
5 changes: 3 additions & 2 deletions AiServer.ServiceInterface/SpeechServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ public async Task<object> Any(QueueSpeechToText request)

public async Task<object> Any(TextToSpeech request)
{
var model = request.Model ?? "text-to-speech";
var diffRequest = new CreateGeneration
{
Request = new()
{
Model = "text-to-speech",
Model = model,
Seed = request.Seed,
TaskType = AiTaskType.TextToSpeech,
PositivePrompt = request.Text
PositivePrompt = request.Input
}
};

Expand Down
6 changes: 5 additions & 1 deletion AiServer.ServiceModel/Generations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ public class TextToSpeech : IGeneration, IReturn<GenerationResponse>
[ApiMember(Description = "The text to be converted to speech")]
[Description("The text to be converted to speech")]
[Required]
public string Text { get; set; }
public string Input { get; set; }

[ApiMember(Description = "Optional seed for reproducible results in speech generation")]
[Description("Optional seed for reproducible results in speech generation")]
[Range(0, int.MaxValue)]
public int? Seed { get; set; }

[ApiMember(Description = "Optional specific model and voice to use for speech generation")]
[Description("Optional specific model and voice to use for speech generation")]
public string? Model { get; set; }

[ApiMember(Description = "Optional client-provided identifier for the request")]
[Description("Optional client-provided identifier for the request")]
public string? RefId { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion AiServer.Tests/SpeechToTextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task Can_generate_speech()
{
response = await client.ApiAsync(new TextToSpeech
{
Text = "This is a test of synchronous text to speech generation."
Input = "This is a test of synchronous text to speech generation."
});
response.ThrowIfError();
}
Expand Down
8 changes: 8 additions & 0 deletions AiServer/wwwroot/lib/data/media-models.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@
"ComfyUI": "high:en_US-lessac"
}
},
{
"id": "tts_echo",
"name": "TTS Echo",
"modelType": "TextToSpeech",
"apiModels": {
"OpenAI": "tts-1:echo"
}
},
{
"id": "text-to-speech",
"name": "Text to Speech",
Expand Down

0 comments on commit cf900b1

Please sign in to comment.