varapiKey=Environment.GetEnvironmentVariable("ASSEMBLYAI_API_KEY")is{Length:>0}apiKeyValue?apiKeyValue:thrownewAssertInconclusiveException("ASSEMBLYAI_API_KEY environment variable is not found.");// Create the realtime client and connect with API-key auth (Authorization header).usingvarclient=newAssemblyAIRealtimeClient();awaitclient.ConnectAsync(apiKey,newStreamingConnectOptions{FormatTurns=true,});// Receive the session started event.usingvarcts=newCancellationTokenSource(TimeSpan.FromSeconds(30));varreceivedSessionBegins=false;awaitforeach(varserverEventinclient.ReceiveUpdatesAsync(cts.Token)){if(serverEvent.IsBegin){receivedSessionBegins=true;Console.WriteLine($"Session started: {serverEvent.Begin?.Id}");Console.WriteLine($"Expires at: {serverEvent.Begin?.ExpiresAt}");// After the session starts, send audio data.// In a real application, you would stream microphone PCM16 audio:// await client.SendAsync(new ArraySegment<byte>(audioBytes), WebSocketMessageType.Binary, true, cts.Token);// Update configuration for turn detection sensitivity.awaitclient.SendUpdateConfigurationAsync(newUpdateConfigurationPayload{EndOfTurnConfidenceThreshold=0.5,MaxTurnSilence=2000,});// For this example, manually force an endpoint to get results.awaitclient.SendForceEndpointAsync(newForceEndpointPayload());break;}}// Gracefully terminate the session.awaitclient.SendSessionTerminationAsync(newSessionTerminationPayload());