Skip to content

Instantly share code, notes, and snippets.

@hatsunea
Created May 31, 2026 01:50
Show Gist options
  • Select an option

  • Save hatsunea/697c3b60c16058bad81ca630bd0862d9 to your computer and use it in GitHub Desktop.

Select an option

Save hatsunea/697c3b60c16058bad81ca630bd0862d9 to your computer and use it in GitHub Desktop.
var ws = new ClientWebSocket();
ws.Options.SetRequestHeader("api-key", "<YOUR_KEY>");
await ws.ConnectAsync(
new Uri("wss://eastus.api.cognitive.microsoft.com/voice/live/ws?model=gpt-realtime-mini"),
CancellationToken.None);
// session.update
var json = @"
{
""type"": ""session.update"",
""session"": {
""input_audio_format"": ""pcm16"",
""output_audio_format"": ""pcm16"",
""turn_detection"": { ""type"": ""server_vad"" }
}
}";
await ws.SendAsync(
new ArraySegment<byte>(Encoding.UTF8.GetBytes(json)),
WebSocketMessageType.Text, true, CancellationToken.None);
// ここから PCM16 を ws.SendAsync(..., WebSocketMessageType.Binary) で送る
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment