All Products
Search
Document Center

Alibaba Cloud Model Studio:Qwen-Audio-ASR-Streaming C# SDK

Last Updated:Nov 23, 2026

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.

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();

Reference