feat(java): add streaming ASR SDK - #1100
Mason Chen (jiec-msft) wants to merge 7 commits into
Conversation
Add a Java 17 JNA binding for reusable-model PCM transcription, final results, cancellation, and deterministic cleanup. Package a normal Maven SDK and sources JAR while keeping native runtimes and model weights external. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Mason Chen (@jiec-msft) is attempting to deploy a commit to the MSFT-AIP Team on Vercel. A member of the Team first needs to authorize it. |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Commenter does not have sufficient privileges for PR 1100 in repo microsoft/foundry-local |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
Native cleanup can be skipped on failure, while CI orchestration introduces excessive model downloads and still omits the Rust SDK from the all-SDK workflow.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a Java 17/JNA SDK for in-process streaming ASR, including native ownership, cancellation, bounded PCM input, packaging, tests, and CI integration.
Changes:
- Introduces the Java SDK and streaming ASR API.
- Adds unit/native integration tests and Maven packaging.
- Extends developer tooling and five-platform CI coverage.
File summaries
| File | Description |
|---|---|
sdk_v2/java/THIRD_PARTY_NOTICES.md |
Documents dependency licensing. |
sdk_v2/java/src/test/java/com/microsoft/foundry/local/TranscriptionStateTest.java |
Tests cancellation races. |
sdk_v2/java/src/test/java/com/microsoft/foundry/local/NativeContractTest.java |
Tests native ABI assumptions. |
sdk_v2/java/src/test/java/com/microsoft/foundry/local/NativeAsrTest.java |
Exercises native ASR lifecycle. |
sdk_v2/java/src/test/java/com/microsoft/foundry/local/AudioValidationTest.java |
Tests PCM/WAV validation. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/WavAudio.java |
Parses bounded PCM WAV input. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/TranscriptionTiming.java |
Defines timing metrics. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/TranscriptionResult.java |
Defines final results. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/Transcription.java |
Implements streaming and ownership. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/SpeechEvent.java |
Defines streaming events. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/PcmFormat.java |
Validates PCM input. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/NativeApi.java |
Implements JNA bindings. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/ModelInfo.java |
Defines model metadata. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/Model.java |
Manages model operations. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/FoundryLocalManager.java |
Owns native manager lifecycle. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/FoundryLocalException.java |
Exposes native errors. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/Configuration.java |
Defines runtime configuration. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/Catalog.java |
Exposes catalog queries. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/CancellationToken.java |
Adds download cancellation. |
sdk_v2/java/src/main/java/com/microsoft/foundry/local/AudioSession.java |
Manages ASR sessions. |
sdk_v2/java/README.md |
Documents setup and usage. |
sdk_v2/java/pom.xml |
Configures Maven build/package. |
sdk_v2/java/build.ps1 |
Adds PowerShell build helper. |
sdk_v2/java/.gitignore |
Ignores Java build outputs. |
sdk_v2/DEVELOPMENT.md |
Adds Java prerequisites. |
sdk_v2/build_and_test_all.ps1 |
Adds Java to local builds. |
.pipelines/v2/templates/steps-build-java.yml |
Defines Java CI steps. |
.pipelines/v2/templates/stages-sdk-v2.yml |
Registers Java stages. |
.pipelines/v2/templates/stages-java.yml |
Adds the Java CI matrix. |
Review details
Suppressed comments (4)
.pipelines/v2/templates/stages-java.yml:61
- This ASR job needs only the Nemotron speech model, but this shared template downloads all six test models, including DeepSeek R1 Distill Qwen 14B. Repeating that large, unrelated download in every Java architecture job adds substantial CI time, bandwidth, and disk usage; parameterize the fetch template and request only the ASR model here.
- template: ../../templates/fetch-models-from-artifacts-feed.yml@self
.pipelines/v2/templates/stages-java.yml:91
- This ASR job needs only the Nemotron speech model, but this shared template downloads all six test models, including DeepSeek R1 Distill Qwen 14B. Repeating that large, unrelated download in every Java architecture job adds substantial CI time, bandwidth, and disk usage; parameterize the fetch template and request only the ASR model here.
- template: ../../templates/fetch-models-from-artifacts-feed.yml@self
.pipelines/v2/templates/stages-java.yml:122
- This ASR job needs only the Nemotron speech model, but this shared template downloads all six test models, including DeepSeek R1 Distill Qwen 14B. Repeating that large, unrelated download in every Java architecture job adds substantial CI time, bandwidth, and disk usage; parameterize the fetch template and request only the ASR model here.
- template: ../../templates/fetch-models-from-artifacts-feed.yml@self
.pipelines/v2/templates/stages-java.yml:154
- This ASR job needs only the Nemotron speech model, but this shared template downloads all six test models, including DeepSeek R1 Distill Qwen 14B. Repeating that large, unrelated download in every Java architecture job adds substantial CI time, bandwidth, and disk usage; parameterize the fetch template and request only the ASR model here.
- template: ../../templates/fetch-models-from-artifacts-feed.yml@self
- Files reviewed: 29/29 changed files
- Comments generated: 4
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Baiju Meswani (@baijumeswani) Could you help review this PR? You have the broadest recent review coverage across SDK v2, native/audio, and pipeline changes, so your input on the Java-to-C ABI ownership and lifecycle, and the five-platform CI integration, would be especially helpful. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Native thread-start failures can violate ownership guarantees, and missing-model lookup behavior needs an explicit API contract.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 30/30 changed files
- Comments generated: 3
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The extensive native ABI, concurrency, ownership, and cross-platform packaging surface warrants final human validation.
Review details
Suppressed comments (4)
Previously missed (2) — in code that hasn't changed since the last review.
sdk_v2/java/src/main/java/com/microsoft/foundry/local/AudioSession.java:39
- This line exceeds the repository's 120-character limit; wrap the guard so the new Java source follows the required formatting rule.
sdk_v2/java/src/test/java/com/microsoft/foundry/local/NativeAsrTest.java:21 - This line is 121 characters and exceeds the repository's 120-character limit.
This issue also appears in the following locations of the same file:
- line 52
- line 67
sdk_v2/java/src/test/java/com/microsoft/foundry/local/NativeAsrTest.java:52
- This line is 121 characters and exceeds the repository's 120-character limit.
try (Transcription run = session.streamPcm(PcmFormat.SPEECH, event -> callbacks.incrementAndGet())) {
sdk_v2/java/src/test/java/com/microsoft/foundry/local/NativeAsrTest.java:67
- This line is 121 characters and exceeds the repository's 120-character limit.
try (Transcription run = session.streamPcm(PcmFormat.SPEECH, event -> callbacks.incrementAndGet())) {
- Files reviewed: 31/31 changed files
- Comments generated: 0 new
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
|
Superseded by #1113, which contains the current Java SDK implementation and validation. Closing this earlier attempt to keep the review focused on the replacement PR. |
Adds a Java 17/JNA SDK for in-process streaming ASR with bounded PCM input, final results, cancellation, and deterministic native ownership.
The platform-independent Maven bundle keeps native runtimes and model weights external; one loaded model serves successive requests and the manager can be recreated.
NativeAsrTestpassed on Windows x64/ARM64, Linux x64/ARM64, and macOS ARM64 (run). Adds the matching Azure matrix and replaces #1094.