Skip to content

Commit cf900b1

Browse files
committed
Update to enable override to text to speech
1 parent c8d6ace commit cf900b1

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

AiServer.ServiceInterface/SpeechServices.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ public async Task<object> Any(QueueSpeechToText request)
6060

6161
public async Task<object> Any(TextToSpeech request)
6262
{
63+
var model = request.Model ?? "text-to-speech";
6364
var diffRequest = new CreateGeneration
6465
{
6566
Request = new()
6667
{
67-
Model = "text-to-speech",
68+
Model = model,
6869
Seed = request.Seed,
6970
TaskType = AiTaskType.TextToSpeech,
70-
PositivePrompt = request.Text
71+
PositivePrompt = request.Input
7172
}
7273
};
7374

AiServer.ServiceModel/Generations.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ public class TextToSpeech : IGeneration, IReturn<GenerationResponse>
4040
[ApiMember(Description = "The text to be converted to speech")]
4141
[Description("The text to be converted to speech")]
4242
[Required]
43-
public string Text { get; set; }
43+
public string Input { get; set; }
4444

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

50+
[ApiMember(Description = "Optional specific model and voice to use for speech generation")]
51+
[Description("Optional specific model and voice to use for speech generation")]
52+
public string? Model { get; set; }
53+
5054
[ApiMember(Description = "Optional client-provided identifier for the request")]
5155
[Description("Optional client-provided identifier for the request")]
5256
public string? RefId { get; set; }

AiServer.Tests/SpeechToTextTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public async Task Can_generate_speech()
4747
{
4848
response = await client.ApiAsync(new TextToSpeech
4949
{
50-
Text = "This is a test of synchronous text to speech generation."
50+
Input = "This is a test of synchronous text to speech generation."
5151
});
5252
response.ThrowIfError();
5353
}

AiServer/wwwroot/lib/data/media-models.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@
108108
"ComfyUI": "high:en_US-lessac"
109109
}
110110
},
111+
{
112+
"id": "tts_echo",
113+
"name": "TTS Echo",
114+
"modelType": "TextToSpeech",
115+
"apiModels": {
116+
"OpenAI": "tts-1:echo"
117+
}
118+
},
111119
{
112120
"id": "text-to-speech",
113121
"name": "Text to Speech",

0 commit comments

Comments
 (0)