Opens a Voxtral realtime WebSocket
(wss://api.mistral.ai/v1/audio/transcriptions/realtime) via
Meai.ISpeechToTextClient.GetStreamingTextAsync, streams ~1 s of synthesized
PCM 16-bit LE / 16 kHz silence to drive the session, and verifies at least a
SessionOpen + SessionClose update pair. A TranscriptionDone update with
non-empty text is asserted only when the server returns one — silent input
does not reliably trigger a transcription on Voxtral.
Skips when MISTRAL_API_KEY is unset.
This example assumes using Mistral; is in scope and apiKey contains your Mistral API key.
usingvarclient=newMistralClient(apiKey);// 1 second of PCM 16-bit LE / 16 kHz silence (~16 000 samples × 2 B/sample).varpcmSilence=newbyte[16000*2];usingvaraudio=newMemoryStream(pcmSilence);Meai.ISpeechToTextClientspeechClient=client;boolsessionOpened=false;boolsessionClosed=false;Meai.SpeechToTextResponseUpdate?finalUpdate=null;usingvartimeoutCts=newCancellationTokenSource(TimeSpan.FromSeconds(45));try{awaitforeach(varupdateinspeechClient.GetStreamingTextAsync(audio,cancellationToken:timeoutCts.Token)){if(update.Kind==Meai.SpeechToTextResponseUpdateKind.SessionOpen){sessionOpened=true;}elseif(update.Kind==Meai.SpeechToTextResponseUpdateKind.SessionClose){sessionClosed=true;}elseif(update.Kind==Meai.SpeechToTextResponseUpdateKind.TextUpdated){finalUpdate=update;}}}catch(System.Net.WebSockets.WebSocketExceptionex){thrownewAssertInconclusiveException($"Voxtral realtime endpoint unavailable (WebSocket error: {ex.Message}); skipping live streaming test.",ex);}// finalUpdate may be null when silent input doesn't trigger transcription —// that's expected and not a failure of the streaming plumbing itself.if(finalUpdateisnotnull){}