microsoft/semantic-kernel · error · ArgumentException
The input audio content is not readable.
Error message
The input audio content is not readable.
What it means
Thrown as an ArgumentException by ClientCore.GetTextFromAudioContentsAsync when the input AudioContent's CanRead property is false. Audio-to-text transcription requires readable audio data; if the content stream has been disposed, was never populated, or is in a non-readable state, transcription cannot proceed.
Source
Thrown at dotnet/src/Connectors/Connectors.OpenAI/Core/ClientCore.AudioToText.cs:33
internal partial class ClientCore
{
/// <summary>
/// Generates an image with the provided configuration.
/// </summary>
/// <param name="targetModel">Model identifier</param>
/// <param name="input">Input audio to generate the text</param>
/// <param name="executionSettings">Audio-to-text execution settings for the prompt</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
/// <returns>Url of the generated image</returns>
internal async Task<IReadOnlyList<TextContent>> GetTextFromAudioContentsAsync(
string targetModel,
AudioContent input,
PromptExecutionSettings? executionSettings,
CancellationToken cancellationToken)
{
if (!input.CanRead)
{
throw new ArgumentException("The input audio content is not readable.", nameof(input));
}
OpenAIAudioToTextExecutionSettings audioExecutionSettings = OpenAIAudioToTextExecutionSettings.FromExecutionSettings(executionSettings)!;
AudioTranscriptionOptions? audioOptions = AudioOptionsFromExecutionSettings(audioExecutionSettings);
Verify.ValidFilename(audioExecutionSettings?.Filename);
using var memoryStream = new MemoryStream(input.Data!.Value.ToArray());
AudioTranscription responseData = (await RunRequestAsync(() => this.Client!.GetAudioClient(targetModel).TranscribeAudioAsync(memoryStream, audioExecutionSettings?.Filename, audioOptions)).ConfigureAwait(false)).Value;
return [new(responseData.Text)
{
ModelId = targetModel,
InnerContent = responseData,
Metadata = GetResponseMetadata(responseData)
}];
}View on GitHub (pinned to c028a0c7dc)
Solutions
- Ensure AudioContent is constructed with valid, non-null audio data before calling the transcription method.
- Do not dispose or consume the underlying audio stream before the API call completes.
- Check input.CanRead before invoking GetTextFromAudioContentsAsync and handle gracefully.
Example fix
// before
AudioContent audio = GetAudio(); // stream already disposed
await client.GetTextFromAudioContentsAsync(model, audio, settings, ct);
// after
await using var stream = File.OpenRead("input.wav");
var audio = new AudioContent(stream, mimeType: "audio/wav");
// stream still open at this point
await client.GetTextFromAudioContentsAsync(model, audio, settings, ct); Defensive patterns
Strategy: validation
Validate before calling
if (input is null || !input.CanRead)
{
throw new ArgumentException("Audio content is not readable.", nameof(input));
} Type guard
static bool IsReadableAudio(AudioContent? audio) =>
audio is not null && audio.CanRead; Prevention
- Construct AudioContent from an open stream and keep it open until the call completes.
- Do not dispose audio streams before the transcription API call returns.
- Check input.CanRead before invoking GetTextFromAudioContentsAsync.
When it happens
Trigger: Passing an AudioContent whose underlying data is null or whose stream has already been consumed/disposed; constructing AudioContent without providing actual audio bytes.
Common situations: AudioContent created from a stream that was closed before the API call; reusing an AudioContent after a previous operation consumed its data; passing an AudioContent with a URI but no inline data where Data is expected; memory pressure causing the data to be evicted.
Related errors
- Data is not available for {cityName}.
- The audio transcription format '{responseFormat}' is not sup
- Audio is required for InputAudioBufferAppendEvent
- Failed to create OpenAI settings.
- The OpenAI audio to text model ID is required.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/8656d4a1dd0f1cea.
Report an issue: GitHub.