forked from admin/VolcanicAgenticCore
Spec 5: the HttpClient registration is named as AddHttpClient<ISpeechToText, OpenAiSpeechToText>() (package Microsoft.Extensions.Http), which is how Program.cs registers it.
28 lines
1.2 KiB
C#
28 lines
1.2 KiB
C#
namespace Volcanic.AgenticCore.Telegram.Speech;
|
|
|
|
/// <summary>The <c>Telegram:Speech</c> section. Speech to text is on exactly when <see cref="ApiKey"/> is set.</summary>
|
|
public sealed class SpeechOptions
|
|
{
|
|
public const string DefaultModel = "gpt-4o-transcribe";
|
|
public const string DefaultBaseUrl = "https://api.openai.com/v1";
|
|
|
|
/// <summary>Falls back to <c>OPENAI_API_KEY</c>. Empty turns speech to text off.</summary>
|
|
public string ApiKey { get; set; } = "";
|
|
|
|
/// <summary>Falls back to <c>STT_MODEL</c>, then <see cref="DefaultModel"/>.</summary>
|
|
public string Model { get; set; } = "";
|
|
|
|
/// <summary>Any OpenAI-compatible transcription endpoint.</summary>
|
|
public string BaseUrl { get; set; } = DefaultBaseUrl;
|
|
|
|
/// <summary>Optional ISO-639-1 hint.</summary>
|
|
public string? Language { get; set; }
|
|
|
|
public bool IsEnabled => !string.IsNullOrWhiteSpace(ApiKey);
|
|
|
|
public string ResolvedModel => string.IsNullOrWhiteSpace(Model) ? DefaultModel : Model.Trim();
|
|
|
|
/// <summary>The startup log line (never the key).</summary>
|
|
public string Describe() => IsEnabled ? $"Speech to text: {ResolvedModel}" : "Speech to text: off (no OPENAI_API_KEY)";
|
|
}
|