Synthesize natural-sounding speech from text using an Inworld voice.
This example assumes using Inworld; is in scope and apiKey contains your Inworld API key.
1 2 3 4 5 6 7 8 910111213141516171819202122
// Create an Inworld client using your API key.usingvarclient=newInworldClient(apiKey);// TTS-2 supports BCP-47 languages, natural-language direction, conversation context, and enhanced denoising.// Use InworldTtsModels.RealtimeTts2Flash instead when minimum latency and cost matter most.varresponse=awaitclient.TextToSpeech.SynthesizeSpeechAsync(text:"Your booking reference is <verbatim>AHAA7771Z</verbatim>.",voiceId:"Dennis",modelId:InworldTtsModels.RealtimeTts2,deliveryMode:DeliveryMode.Balanced,language:"en-US",instruction:"Speak warmly and clearly, emphasizing the booking reference.",enhanceGeneration:true,synthesisContext:newSynthesisContext{PreviousRequests=[ new PreviousSynthesisRequest { Text = "I found your reservation." }, ],});// The response contains Base64-encoded audio bytes ready to decode into a playable file.