16 lines
827 B
C#
16 lines
827 B
C#
namespace Volcanic.AgenticCore.Telegram.Speech;
|
|
|
|
/// <summary>Turns a voice note or audio file into text before a prompt exists. The core only ever sees the text.</summary>
|
|
public interface ISpeechToText
|
|
{
|
|
/// <summary>The trimmed transcript; throws <see cref="SpeechToTextException"/> when the service fails.</summary>
|
|
Task<string> TranscribeAsync(ReadOnlyMemory<byte> audio, string fileName, string mimeType, CancellationToken cancellationToken);
|
|
}
|
|
|
|
/// <summary>A transcription failed; the message is fit for the user and never contains the API key.</summary>
|
|
public sealed class SpeechToTextException(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; }
|
|
}
|