OpenAISpeechToTextClient sends Ogg MemoryStream audio with an .mp3 filename

Aperta Adatta ai principianti
#7,900 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Manish-1kumar ci sta già lavorando.

Dal 1/11/2026.

  • #7901 di @Manish-1kumar — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
api

Direzione di ricerca

Inizia da src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAISpeechToTextClient.cs, in particolare da DetectAudioExtension e dalla risoluzione del nome file condivisa dalla trascrizione normale e da quella in streaming. Aggiungi test mirati per gli stream di memoria Ogg/Opus e Ogg/Vorbis, verificando che i byte caricati rimangano invariati e che il nome file multipart utilizzi un'estensione Ogg. Il lavoro è completato quando entrambi i percorsi di trascrizione etichettano correttamente l'input Ogg senza modificarne i byte o la posizione dello stream.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C#
Stelle
3.3k
Fork
916
Merge medio
1g 15h
PR unite (30g)
41

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dotnet/extensions

Tutte le issue di dotnet/extensions

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.