OpenAISpeechToTextClient sends Ogg MemoryStream audio with an .mp3 filename

Open Beginner friendly
#7,900 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Manish-1kumar is already working on this.

Since Nov 1, 2026.

  • #7901 by @Manish-1kumar — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
api

Research direction

Start with src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAISpeechToTextClient.cs, especially DetectAudioExtension and the filename resolution shared by ordinary and streaming transcription. Add focused coverage for Ogg/Opus and Ogg/Vorbis memory streams, checking that uploaded bytes remain unchanged and the multipart filename uses an Ogg extension. Done when both transcription paths label Ogg input correctly without changing its bytes or stream position.

Written by the indexing model from the issue text.

Description

area-ai untriaged

Description

OpenAISpeechToTextClient misidentifies an Ogg/Opus MemoryStream as MP3, sending its unchanged Ogg bytes with the multipart filename audio.mp3. This affects in-memory voice recordings, for example Telegram voice notes.

The issue exists in Microsoft.Extensions.AI.OpenAI 10.11.0 (repository commit 25f07afa51034e37b334210642d7dc5f191c142d) and is also visible in the current main source inspected on 2026-10-30. DetectAudioExtension recognizes WAV, WebM, MP4/M4A and MP3, but not the Ogg OggS signature; the default is mp3.

Reproduction Steps

Use a valid Ogg/Opus recording and the normal SDK adapter:

#pragma warning disable MEAI001
using Microsoft.Extensions.AI;
using OpenAI.Audio;

// audioClient is a configured official OpenAI or Azure OpenAI AudioClient.
using ISpeechToTextClient speech = audioClient.AsISpeechToTextClient();
using var audio = new MemoryStream(await File.ReadAllBytesAsync("voice.ogg"));
await speech.GetTextAsync(audio);

Inspect the multipart file part at a local test transcription endpoint: the filename is audio.mp3, while the bytes start with OggS and still contain the original Ogg recording. The same issue applies to GetStreamingTextAsync, which calls the same filename resolver.

The adapter offers no filename option on SpeechToTextOptions; its raw-options callback only controls AudioTranscriptionOptions/AudioTranslationOptions, not the filename passed separately to AudioClient.

Expected behavior

Ogg input is labeled with an Ogg extension, with no byte conversion or stream-position change. Preferably applications can explicitly supply a filename instead of depending exclusively on sniffing, including for non-seekable streams. The official SDK already supports this with AudioClient.TranscribeAudioAsync(stream, fileName, options, cancellationToken).

Actual behavior

The multipart filename is audio.mp3. We observed an Azure OpenAI transcription rejection with HTTP 400, invalid_request_error, parameter file, and the message Audio file might be corrupted or unsupported in an affected in-memory voice-ingestion path. This report identifies the incorrect filename independently of any provider's decoding behavior; it does not claim every provider rejects every mismatched upload.

Regression?

Not bisected against older package versions.

Known Workarounds

Call the official SDK overload with an explicit filename. A FileStream also retains its filename, but requiring local temporary files is unsuitable for existing in-memory/private-storage pipelines.

Configuration

  • .NET 10.
  • Microsoft.Extensions.AI.OpenAI 10.11.0.
  • Official OpenAI / Azure OpenAI audio client.
  • The filename-detection branch is platform-independent.

Other information

Affected source: OpenAISpeechToTextClient.cs.

Suggested focused upstream coverage: valid Ogg/Opus and Ogg/Vorbis memory streams, unchanged uploaded bytes/stream position, and both ordinary and streaming transcription filename resolution.

Dominant language
C#
Stars
3.3k
Forks
919
Avg merge
2d 2h
Merged PRs (30d)
35

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/extensions

All issues in dotnet/extensions

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.