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