Skip to main content

CosyVoice C# SDK

Démarrage rapide

Suivez le guide Présentation du SDK pour installer le SDK et configurer votre clé API. Dans le point de terminaison de l’exemple, remplacez WorkspaceId par l’identifiant de votre espace de travail dans la même région. Synthétisez deux phrases avec la voix longanyang et écrivez les blocs audio dans output.wav dans leur ordre de réception. Vous pouvez ensuite écouter le fichier.
using DashScope.Speech;

await using var client = new CosyVoiceSpeechSynthesizer(new CosyVoiceSynthesizerOptions
{
    Model = "cosyvoice-v3-plus",
    Voice = "longanyang",
    Url = "wss://WorkspaceId.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/inference",
    Format = "wav",
    SampleRate = 16000,
});

using var output = File.Create("output.wav");
await foreach (var chunk in client.StreamAudioAsync(["Good afternoon. ", "Welcome to our meeting."]))
{
    await output.WriteAsync(chunk);
}

Référence