Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
WorkspaceId 替換為同一地域的業務空間 ID。
將範例音訊儲存為 asr_example.wav。範例分段讀取檔案來模擬即時輸入,不需麥克風。
辨識音訊,在主控台輸出每句的最終文字。
using DashScope.Speech;
await using var client = new FunAsrSpeechTranscriber(new FunAsrTranscriberOptions
{
Model = "qwen-audio-3.1-asr-flash-message",
Url = "wss://WorkspaceId.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/inference",
Format = "wav",
SampleRate = 16000,
});
client.SentenceEnd += (_, e) => Console.WriteLine(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();