OpenAI gpt-4o-mini-tts (female voice nova by default; TTS_MODEL/TTS_VOICE) renders OGG/Opus, sent with sendVoice in order with rendered output. Up to 4500 characters per call, split into 1500-character parts at paragraph/sentence/word boundaries; all parts are synthesized before any is sent, and API errors come back to the agent as text with the key hidden. On whenever OPENAI_API_KEY is set.
18 lines
759 B
C#
18 lines
759 B
C#
using Volcanic.AgenticCore.Telegram.Speech;
|
|
|
|
namespace Volcanic.AgenticCore.Telegram.Tests.Support;
|
|
|
|
/// <summary>Answers every text with fake OGG bytes; <see cref="Failure"/> makes a call throw.</summary>
|
|
public sealed class FakeTextToSpeech : ITextToSpeech
|
|
{
|
|
public Exception? Failure { get; set; }
|
|
public List<(string Text, string? Voice, string? Instructions)> Calls { get; } = [];
|
|
|
|
public Task<byte[]> SynthesizeAsync(string text, string? voice, string? instructions, CancellationToken cancellationToken)
|
|
{
|
|
lock (Calls) Calls.Add((text, voice, instructions));
|
|
if (Failure is not null) throw Failure;
|
|
return Task.FromResult(new byte[] { 0x4F, 0x67, 0x67, 0x53, (byte)Calls.Count }); // "OggS" + call number
|
|
}
|
|
}
|