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.
Call workflow
-
Create a
FunAsrSpeechTranscriberinstance and subscribe to events (such asSentenceEnd; subscribe toPartialResultas well if you want interim results). -
Call
StartAsyncto connect, sendrun-task, and wait fortask-started. -
After
TranscriberStarted, callSendAudioAsynccontinuously at the audio playback rate.WithQwen-Audio-ASR-Message, callSendContextAsyncwhile sending audio if you need to update the context during a running task. -
Receive interim and final results in
SentenceBegin,PartialResult, andSentenceEnd(interimPartialResulttext may change; useSentenceEndfor the final text). -
After all audio is sent, call
StopAsyncand wait fortask-finished(Completed). -
Call
DisposeAsyncto release the connection when done.
Request parameters
Pass FunAsrTranscriberOptions to the FunAsrSpeechTranscriber constructor. Optional values set to null are omitted from the request.
| Parameter | Type | Default | Description |
|---|---|---|---|
Model | string | qwen-audio-3.1-asr-flash-streaming | Model ID. Set the model for this family explicitly. |
Format | string | pcm | Audio format. |
SampleRate | int | 16000 | Audio sample rate in Hz.Qwen-Audio-ASR-Message supports 16000 Hz only. |
MaxSentenceSilence | int? | null | VAD end-of-sentence silence threshold in milliseconds. |
MultiThresholdModeEnabled | bool? | null | Qwen-Audio-ASR-Streaming: Enable multi-threshold VAD segmentation. |
KeepDialect | bool? | null | Preserve 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). |
Heartbeat | bool? | null | Keep the connection alive while sending silent audio. |
VocabularyId | string? | null | Precompiled vocabulary ID. |
Vocabulary | IDictionary<string, int>? | null | Instant hotwords mapped to weights. |
LanguageHints | IList<string>? | null | Language hints. |
SpeechNoiseThreshold | float? | null | Speech/noise threshold. |
SpecialWordFilter | string? | null | Qwen-Audio-ASR-Streaming: Sensitive-word filtering rules as a JSON string. |
ExtraParametersJson | string? | null | Pass a JSON object as a string. Its fields are merged into the protocol parameters object. |
IntermediateResultEnabled | bool? | null | Qwen-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. |
DisfluencyRemovalEnabled | bool? | null | Qwen-Audio-ASR-Message: Remove disfluencies. |