Skip to main content

Qwen-Audio-ASR-Streaming / Message C# SDK overview

Stream audio to Qwen-Audio-ASR-Streaming / Message with the C# SDK and receive recognition results.

Quick start

Follow SDK overview to install the SDK and configure your API key. Replace WorkspaceId in the example endpoint with your workspace ID from the same region. Save the sample audio as asr_example.wav. The example reads the file in chunks to simulate live input without a microphone.
  • Qwen-Audio-ASR-Streaming
  • Qwen-Audio-ASR-Message
Transcribe the audio and print interim results and the final text of each sentence to the console.
using DashScope.Speech;

await using var client = new FunAsrSpeechTranscriber(new FunAsrTranscriberOptions
{
    Model = "qwen-audio-3.1-asr-flash-streaming",
    Url = "wss://WorkspaceId.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/inference",
    Format = "wav",
    SampleRate = 16000,
});
client.PartialResult += (_, e) => Console.WriteLine($"Interim: {e.Sentence.Text}");
client.SentenceEnd += (_, e) => Console.WriteLine($"Final: {e.Sentence.Text}");

using var audio = File.OpenRead("asr_example.wav");
byte[] buffer = new byte[3200];
await client.StartAsync();
int count;
while ((count = await audio.ReadAsync(buffer)) > 0)
{
    await client.SendAudioAsync(buffer.AsMemory(0, count));
    await Task.Delay(100);
}
await client.StopAsync();

Call workflow

  1. Create a FunAsrSpeechTranscriber instance and subscribe to events (such as SentenceEnd; subscribe to PartialResult as well if you want interim results).
  2. Call StartAsync to connect, send run-task, and wait for task-started.
  3. After TranscriberStarted, call SendAudioAsync continuously at the audio playback rate.
    With Qwen-Audio-ASR-Message, call SendContextAsync while sending audio if you need to update the context during a running task.
  4. Receive interim and final results in SentenceBegin, PartialResult, and SentenceEnd (interim PartialResult text may change; use SentenceEnd for the final text).
  5. After all audio is sent, call StopAsync and wait for task-finished (Completed).
  6. Call DisposeAsync to release the connection when done.

Request parameters

Pass FunAsrTranscriberOptions to the FunAsrSpeechTranscriber constructor. Optional values set to null are omitted from the request.
ParameterTypeDefaultDescription
Modelstringqwen-audio-3.1-asr-flash-streamingModel ID. Set the model for this family explicitly.
FormatstringpcmAudio format.
SampleRateint16000Audio sample rate in Hz.
Qwen-Audio-ASR-Message supports 16000 Hz only.
MaxSentenceSilenceint?nullVAD end-of-sentence silence threshold in milliseconds.
MultiThresholdModeEnabledbool?nullQwen-Audio-ASR-Streaming: Enable multi-threshold VAD segmentation.
KeepDialectbool?nullPreserve dialect expressions. In Qwen-Audio-ASR-Streaming, only qwen-audio-3.1-asr-flash-streaming supports this option. In Qwen-Audio-ASR-Message, it affects final results (SentenceEnd), not interim results (PartialResult).
Heartbeatbool?nullKeep the connection alive while sending silent audio.
VocabularyIdstring?nullPrecompiled vocabulary ID.
VocabularyIDictionary<string, int>?nullInstant hotwords mapped to weights.
LanguageHintsIList<string>?nullLanguage hints.
SpeechNoiseThresholdfloat?nullSpeech/noise threshold.
SpecialWordFilterstring?nullQwen-Audio-ASR-Streaming: Sensitive-word filtering rules as a JSON string.
ExtraParametersJsonstring?nullPass a JSON object as a string. Its fields are merged into the protocol parameters object.
IntermediateResultEnabledbool?nullQwen-Audio-ASR-Message: By default, only final sentences are returned. Set this option to true to receive interim results through PartialResult. Qwen-Audio-ASR-Streaming returns interim results by default; this option applies only to Qwen-Audio-ASR-Message.
DisfluencyRemovalEnabledbool?nullQwen-Audio-ASR-Message: Remove disfluencies.