{"record":{"id":"8656d4a1dd0f1cea","repo":"microsoft/semantic-kernel","slug":"the-input-audio-content-is-not-readable","errorCode":null,"errorMessage":"The input audio content is not readable.","messagePattern":"The input audio content is not readable\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.OpenAI/Core/ClientCore.AudioToText.cs","lineNumber":33,"sourceCode":"internal partial class ClientCore\n{\n    /// <summary>\n    /// Generates an image with the provided configuration.\n    /// </summary>\n    /// <param name=\"targetModel\">Model identifier</param>\n    /// <param name=\"input\">Input audio to generate the text</param>\n    /// <param name=\"executionSettings\">Audio-to-text execution settings for the prompt</param>\n    /// <param name=\"cancellationToken\">The <see cref=\"CancellationToken\"/> to monitor for cancellation requests. The default is <see cref=\"CancellationToken.None\"/>.</param>\n    /// <returns>Url of the generated image</returns>\n    internal async Task<IReadOnlyList<TextContent>> GetTextFromAudioContentsAsync(\n        string targetModel,\n        AudioContent input,\n        PromptExecutionSettings? executionSettings,\n        CancellationToken cancellationToken)\n    {\n        if (!input.CanRead)\n        {\n            throw new ArgumentException(\"The input audio content is not readable.\", nameof(input));\n        }\n\n        OpenAIAudioToTextExecutionSettings audioExecutionSettings = OpenAIAudioToTextExecutionSettings.FromExecutionSettings(executionSettings)!;\n        AudioTranscriptionOptions? audioOptions = AudioOptionsFromExecutionSettings(audioExecutionSettings);\n\n        Verify.ValidFilename(audioExecutionSettings?.Filename);\n\n        using var memoryStream = new MemoryStream(input.Data!.Value.ToArray());\n\n        AudioTranscription responseData = (await RunRequestAsync(() => this.Client!.GetAudioClient(targetModel).TranscribeAudioAsync(memoryStream, audioExecutionSettings?.Filename, audioOptions)).ConfigureAwait(false)).Value;\n\n        return [new(responseData.Text)\n        {\n            ModelId = targetModel,\n            InnerContent = responseData,\n            Metadata = GetResponseMetadata(responseData)\n        }];\n    }","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.OpenAI/Core/ClientCore.AudioToText.cs#L15-L51","documentation":"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.","triggerScenarios":"Passing an AudioContent whose underlying data is null or whose stream has already been consumed/disposed; constructing AudioContent without providing actual audio bytes.","commonSituations":"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.","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."],"exampleFix":"// before\nAudioContent audio = GetAudio(); // stream already disposed\nawait client.GetTextFromAudioContentsAsync(model, audio, settings, ct);\n\n// after\nawait using var stream = File.OpenRead(\"input.wav\");\nvar audio = new AudioContent(stream, mimeType: \"audio/wav\");\n// stream still open at this point\nawait client.GetTextFromAudioContentsAsync(model, audio, settings, ct);","handlingStrategy":"validation","validationCode":"if (input is null || !input.CanRead)\n{\n    throw new ArgumentException(\"Audio content is not readable.\", nameof(input));\n}","typeGuard":"static bool IsReadableAudio(AudioContent? audio) =>\n    audio is not null && audio.CanRead;","tryCatchPattern":null,"preventionTips":["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."],"tags":["openai","audio","text-to-speech","audio-to-text","argument-exception"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}