Pick a voice from the available catalog, synthesize text with it, and save the generated audio to disk.
This example assumes using ElevenLabs; is in scope and apiKey contains your ElevenLabs API key.
1 2 3 4 5 6 7 8 9101112131415161718
usingvarclient=newElevenLabsClient(apiKey);// Choose a voice to synthesize with.varvoices=awaitclient.Voices.GetAllAsync();varvoice=voices.Voices[0];conststringtext="Hello, world! This is a test of the ElevenLabs text-to-speech API.";Console.WriteLine($"Using voice: {voice.Name} ({voice.VoiceId})");Console.WriteLine($"Input text: {text}");// Generate speech audio.byte[]audioBytes=awaitclient.TextToSpeech2.ConvertAsync(voiceId:voice.VoiceId,text:text);// Persist the result to a local file.awaitFile.WriteAllBytesAsync("output.mp3",audioBytes);Console.WriteLine($"Saved {audioBytes.Length} bytes to output.mp3");