Files
Playa/hosts/Volcanic.AgenticCore.Telegram/Speech/ITextToSpeech.cs
EugeneTes 7fef3ce94e feat(telegram): ElevenLabs text to speech for the voice tool
ElevenLabs speaks for the voice tool when ELEVENLABS_API_KEY and ELEVENLABS_VOICE_ID
are set (TTS_PROVIDER=elevenlabs|openai picks, the other is the fallback). Opus output
(opus_48000_64) goes to Telegram as is; voice names resolve through /v2/voices;
instructions become audio tags on eleven_v3 and are ignored on other models. The key
is redacted from tool output and never reaches agent processes.
2026-10-14 13:07:36 +00:00

22 lines
1.1 KiB
C#

namespace Volcanic.AgenticCore.Telegram.Speech;
/// <summary>Turns text into a Telegram voice note (OGG/Opus) for the <c>voice</c> tool.</summary>
public interface ITextToSpeech
{
/// <summary>
/// OGG/Opus audio of <paramref name="text"/>; <paramref name="voice"/> and <paramref name="instructions"/> override the
/// configured defaults when set. Throws <see cref="TextToSpeechException"/> when the service fails.
/// </summary>
Task<byte[]> SynthesizeAsync(string text, string? voice, string? instructions, CancellationToken cancellationToken);
/// <summary>What the <c>voice</c> and <c>instructions</c> arguments mean for this service, for the tool description.</summary>
string ArgumentGuide { get; }
}
/// <summary>Speech synthesis failed; the message is fit for the user and never contains the API key.</summary>
public sealed class TextToSpeechException(string message, Exception? inner = null) : Exception(message, inner)
{
/// <summary>Another attempt may succeed (network error, timeout, 408, 429, 5xx).</summary>
internal bool IsTransient { get; init; }
}