{"slug":"azure-ai-voicelive-java","title":"azure-ai-voicelive-java","summary":"Azure AI VoiceLive SDK for Java. Real-time bidirectional voice conversations with AI assistants using WebSocket. Triggers: \"VoiceLiveClient java\", \"voice assistant java\", \"real-time voice java\", \"audio streaming java\", \"voice activity detection java\".","platform":"GitHub Copilot","tags":[],"authorName":"Ciza","authorSlug":"ciza","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-08-12T21:05:20.234647Z","repo":{"url":"https://github.com/microsoft/skills","stars":3052,"forks":351,"license":"MIT","updatedAt":"2026-09-24T16:38:17Z"},"bodyHtml":"<hr>\n<h2>name: azure-ai-voicelive-java\ndescription: |\nAzure AI VoiceLive SDK for Java. Real-time bidirectional voice conversations with AI assistants using WebSocket.\nTriggers: \"VoiceLiveClient java\", \"voice assistant java\", \"real-time voice java\", \"audio streaming java\", \"voice activity detection java\".\nlicense: MIT\nmetadata:\nauthor: Microsoft\nversion: \"1.0.0\"\npackage: com.azure:azure-ai-voicelive</h2>\n<h1>Azure AI VoiceLive SDK for Java</h1>\n<p>Real-time, bidirectional voice conversations with AI assistants using WebSocket technology.</p>\n<h2>Installation</h2>\n<pre><code>&lt;dependency&gt;\n    &lt;groupId&gt;com.azure&lt;/groupId&gt;\n    &lt;artifactId&gt;azure-ai-voicelive&lt;/artifactId&gt;\n    &lt;version&gt;1.0.0-beta.2&lt;/version&gt;\n&lt;/dependency&gt;\n</code></pre>\n<h2>Environment Variables</h2>\n<pre><code>AZURE_VOICELIVE_ENDPOINT=https://&lt;resource&gt;.openai.azure.com/ # Required for all auth methods\nAZURE_VOICELIVE_API_KEY=&lt;your-api-key&gt; # Only required for AzureKeyCredential auth\nAZURE_TOKEN_CREDENTIALS=prod  # Required only if DefaultAzureCredential is used in production\n</code></pre>\n<h2>Authentication</h2>\n<h3>API Key</h3>\n<pre><code>import com.azure.ai.voicelive.VoiceLiveAsyncClient;\nimport com.azure.ai.voicelive.VoiceLiveClientBuilder;\nimport com.azure.core.credential.AzureKeyCredential;\n\nVoiceLiveAsyncClient client = new VoiceLiveClientBuilder()\n    .endpoint(System.getenv(\"AZURE_VOICELIVE_ENDPOINT\"))\n    .credential(new AzureKeyCredential(System.getenv(\"AZURE_VOICELIVE_API_KEY\")))\n    .buildAsyncClient();\n</code></pre>\n<h3>DefaultAzureCredential (Recommended)</h3>\n<pre><code>import com.azure.core.credential.TokenCredential;\nimport com.azure.identity.AzureIdentityEnvVars;\nimport com.azure.identity.DefaultAzureCredentialBuilder;\nimport com.azure.identity.ManagedIdentityCredentialBuilder;\n\nTokenCredential credential = new DefaultAzureCredentialBuilder()\n    .requireEnvVars(AzureIdentityEnvVars.AZURE_TOKEN_CREDENTIALS)\n    .build();\n// Or use a specific credential directly in production:\n// See https://learn.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable#credential-classes\n// TokenCredential credential = new ManagedIdentityCredentialBuilder().build();\n\nVoiceLiveAsyncClient client = new VoiceLiveClientBuilder()\n    .endpoint(System.getenv(\"AZURE_VOICELIVE_ENDPOINT\"))\n    .credential(credential)\n    .buildAsyncClient();\n</code></pre>\n<h2>Key Concepts</h2>\n<table>\n<thead>\n<tr>\n<th>Concept</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>VoiceLiveAsyncClient</code></td>\n<td>Main entry point for voice sessions</td>\n</tr>\n<tr>\n<td><code>VoiceLiveSessionAsyncClient</code></td>\n<td>Active WebSocket connection for streaming</td>\n</tr>\n<tr>\n<td><code>VoiceLiveSessionOptions</code></td>\n<td>Configuration for session behavior</td>\n</tr>\n</tbody>\n</table>\n<h3>Audio Requirements</h3>\n<ul>\n<li><strong>Sample Rate</strong>: 24kHz (24000 Hz)</li>\n<li><strong>Bit Depth</strong>: 16-bit PCM</li>\n<li><strong>Channels</strong>: Mono (1 channel)</li>\n<li><strong>Format</strong>: Signed PCM, little-endian</li>\n</ul>\n<h2>Core Workflow</h2>\n<h3>1. Start Session</h3>\n<pre><code>import reactor.core.publisher.Mono;\n\nclient.startSession(\"gpt-4o-realtime-preview\")\n    .flatMap(session -&gt; {\n        System.out.println(\"Session started\");\n        \n        // Subscribe to events\n        session.receiveEvents()\n            .subscribe(\n                event -&gt; System.out.println(\"Event: \" + event.getType()),\n                error -&gt; System.err.println(\"Error: \" + error.getMessage())\n            );\n        \n        return Mono.just(session);\n    })\n    .block();\n</code></pre>\n<h3>2. Configure Session Options</h3>\n<pre><code>import com.azure.ai.voicelive.models.*;\nimport java.util.Arrays;\n\nServerVadTurnDetection turnDetection = new ServerVadTurnDetection()\n    .setThreshold(0.5)                    // Sensitivity (0.0-1.0)\n    .setPrefixPaddingMs(300)              // Audio before speech\n    .setSilenceDurationMs(500)            // Silence to end turn\n    .setInterruptResponse(true)           // Allow interruptions\n    .setAutoTruncate(true)\n    .setCreateResponse(true);\n\nAudioInputTranscriptionOptions transcription = new AudioInputTranscriptionOptions(\n    AudioInputTranscriptionOptionsModel.WHISPER_1);\n\nVoiceLiveSessionOptions options = new VoiceLiveSessionOptions()\n    .setInstructions(\"You are a helpful AI voice assistant.\")\n    .setVoice(BinaryData.fromObject(new OpenAIVoice(OpenAIVoiceName.ALLOY)))\n    .setModalities(Arrays.asList(InteractionModality.TEXT, InteractionModality.AUDIO))\n    .setInputAudioFormat(InputAudioFormat.PCM16)\n    .setOutputAudioFormat(OutputAudioFormat.PCM16)\n    .setInputAudioSamplingRate(24000)\n    .setInputAudioNoiseReduction(new AudioNoiseReduction(AudioNoiseReductionType.NEAR_FIELD))\n    .setInputAudioEchoCancellation(new AudioEchoCancellation())\n    .setInputAudioTranscription(transcription)\n    .setTurnDetection(turnDetection);\n\n// Send configuration\nClientEventSessionUpdate updateEvent = new ClientEventSessionUpdate(options);\nsession.sendEvent(updateEvent).subscribe();\n</code></pre>\n<h3>3. Send Audio Input</h3>\n<pre><code>byte[] audioData = readAudioChunk(); // Your PCM16 audio data\nsession.sendInputAudio(BinaryData.fromBytes(audioData)).subscribe();\n</code></pre>\n<h3>4. Handle Events</h3>\n<pre><code>session.receiveEvents().subscribe(event -&gt; {\n    ServerEventType eventType = event.getType();\n    \n    if (ServerEventType.SESSION_CREATED.equals(eventType)) {\n        System.out.println(\"Session created\");\n    } else if (ServerEventType.INPUT_AUDIO_BUFFER_SPEECH_STARTED.equals(eventType)) {\n        System.out.println(\"User started speaking\");\n    } else if (ServerEventType.INPUT_AUDIO_BUFFER_SPEECH_STOPPED.equals(eventType)) {\n        System.out.println(\"User stopped speaking\");\n    } else if (ServerEventType.RESPONSE_AUDIO_DELTA.equals(eventType)) {\n        if (event instanceof SessionUpdateResponseAudioDelta) {\n            SessionUpdateResponseAudioDelta audioEvent = (SessionUpdateResponseAudioDelta) event;\n            playAudioChunk(audioEvent.getDelta());\n        }\n    } else if (ServerEventType.RESPONSE_DONE.equals(eventType)) {\n        System.out.println(\"Response complete\");\n    } else if (ServerEventType.ERROR.equals(eventType)) {\n        if (event instanceof SessionUpdateError) {\n            SessionUpdateError errorEvent = (SessionUpdateError) event;\n            System.err.println(\"Error: \" + errorEvent.getError().getMessage());\n        }\n    }\n});\n</code></pre>\n<h2>Voice Configuration</h2>\n<h3>OpenAI Voices</h3>\n<pre><code>// Available: ALLOY, ASH, BALLAD, CORAL, ECHO, SAGE, SHIMMER, VERSE\nVoiceLiveSessionOptions options = new VoiceLiveSessionOptions()\n    .setVoice(BinaryData.fromObject(new OpenAIVoice(OpenAIVoiceName.ALLOY)));\n</code></pre>\n<h3>Azure Voices</h3>\n<pre><code>// Azure Standard Voice\noptions.setVoice(BinaryData.fromObject(new AzureStandardVoice(\"en-US-JennyNeural\")));\n\n// Azure Custom Voice\noptions.setVoice(BinaryData.fromObject(new AzureCustomVoice(\"myVoice\", \"endpointId\")));\n\n// Azure Personal Voice\noptions.setVoice(BinaryData.fromObject(\n    new AzurePersonalVoice(\"speakerProfileId\", PersonalVoiceModels.PHOENIX_LATEST_NEURAL)));\n</code></pre>\n<h2>Function Calling</h2>\n<pre><code>VoiceLiveFunctionDefinition weatherFunction = new VoiceLiveFunctionDefinition(\"get_weather\")\n    .setDescription(\"Get current weather for a location\")\n    .setParameters(BinaryData.fromObject(parametersSchema));\n\nVoiceLiveSessionOptions options = new VoiceLiveSessionOptions()\n    .setTools(Arrays.asList(weatherFunction))\n    .setInstructions(\"You have access to weather information.\");\n</code></pre>\n<h2>Best Practices</h2>\n<ol>\n<li><strong>Use async client</strong> — VoiceLive requires reactive patterns</li>\n<li><strong>Configure turn detection</strong> for natural conversation flow</li>\n<li><strong>Enable noise reduction</strong> for better speech recognition</li>\n<li><strong>Handle interruptions</strong> gracefully with <code>setInterruptResponse(true)</code></li>\n<li><strong>Use Whisper transcription</strong> for input audio transcription</li>\n<li><strong>Close sessions</strong> properly when conversation ends</li>\n</ol>\n<h2>Error Handling</h2>\n<pre><code>session.receiveEvents()\n    .doOnError(error -&gt; System.err.println(\"Connection error: \" + error.getMessage()))\n    .onErrorResume(error -&gt; {\n        // Attempt reconnection or cleanup\n        return Flux.empty();\n    })\n    .subscribe();\n</code></pre>\n<h2>Reference Links</h2>\n<table>\n<thead>\n<tr>\n<th>Resource</th>\n<th>URL</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>GitHub Source</td>\n<td><a href=\"https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/ai/azure-ai-voicelive\">https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/ai/azure-ai-voicelive</a></td>\n</tr>\n<tr>\n<td>Samples</td>\n<td><a href=\"https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/ai/azure-ai-voicelive/src/samples\">https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/ai/azure-ai-voicelive/src/samples</a></td>\n</tr>\n</tbody>\n</table>\n","files":[{"path":"references/examples.md","sizeBytes":24860,"isText":true},{"path":"SKILL.md","sizeBytes":8131,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-08-12T21:51:59.569402Z","sha256":"9B09B86ACCB9089E9BF9A1AC34369246F9EA679D306E2E54EA2A5F021CB2F8F8","sizeBytes":8936},"review":null,"source":{"repositoryUrl":"https://github.com/microsoft/skills","path":".github/plugins/azure-sdk-java/skills/azure-ai-voicelive-java","license":"MIT","commit":"23d0dac5f83f268166a17f0bc7dc6c73dc348a33","subtreeSha":"1F6A9DB0AE7EF9A57B2E3F370ADD2EBBFF30E0EE063F993950C72E1FB20B7BAB","lastSyncedAt":"2026-09-25T06:48:53.330584Z"},"reviewedAt":"2026-08-12T21:58:01.959991Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-java/skills/azure-ai-voicelive-java"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install microsoft-skills@llmmart"},{"target":"git","command":"git clone https://github.com/microsoft/skills.git"}]}