varapiKey=Environment.GetEnvironmentVariable("XAI_API_KEY")is{Length:>0}apiKeyValue?apiKeyValue:thrownewAssertInconclusiveException("XAI_API_KEY environment variable is not found.");// Create a WebSocket client and connect with the TTS voice, language, and audio format.usingvarclient=newXai.TextToSpeech.XaiTextToSpeechStreamingClient(apiKey);awaitclient.ConnectAsync(language:"en",voice:"eve",codec:"mp3");// Stream text as one or more deltas, then flush the utterance with text.done.awaitclient.SendTextDeltaAsync(newXai.TextToSpeech.TextDeltaPayload{Delta="Hello from xAI streaming text to speech.",});awaitclient.SendTextDoneAsync(newXai.TextToSpeech.TextDonePayload());// Receive base64 audio chunks until the utterance is complete.usingvarcts=newCancellationTokenSource(TimeSpan.FromSeconds(30));usingvaraudio=newMemoryStream();varreceivedAudioDone=false;awaitforeach(varserverEventinclient.ReceiveUpdatesAsync(cts.Token)){if(serverEvent.IsAudioDelta){audio.Write(serverEvent.AudioDelta.DeltaBytes.Span);}elseif(serverEvent.IsAudioDone){receivedAudioDone=true;break;}elseif(serverEvent.IsError){thrownewInvalidOperationException($"Received error: {serverEvent.Error?.Message}");}}Console.WriteLine($"Generated {audio.Length} streaming audio bytes.");