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-streaming",
Url = "wss://WorkspaceId.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/inference",
Format = "wav",
SampleRate = 16000,
});
client.PartialResult += (_, e) => Console.WriteLine($"中间结果: {e.Sentence.Text}");
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();