Skip to content

feat(java): add streaming ASR SDK - #1100

Closed
Mason Chen (jiec-msft) wants to merge 7 commits into
microsoft:mainfrom
jiec-msft:mason/java-asr-sdk-refined
Closed

Mason Chen (jiec-msft) wants to merge 7 commits into
microsoft:mainfrom
jiec-msft:mason/java-asr-sdk-refined

Conversation

@jiec-msft

@jiec-msft Mason Chen (jiec-msft) commented Sep 11, 2026

Copy link
Copy Markdown
Member

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.

NativeAsrTest passed on Windows x64/ARM64, Linux x64/ARM64, and macOS ARM64 (run). Adds the matching Azure matrix and replaces #1094.

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>
@vercel

vercel Bot commented Sep 11, 2026

Copy link
Copy Markdown

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

Copy link
Copy Markdown
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>
@jiec-msft

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 1100 in repo microsoft/foundry-local

@jiec-msft
Mason Chen (jiec-msft) marked this pull request as ready for review September 11, 2026 14:38
Copilot AI balanced review requested due to automatic review settings September 11, 2026 14:38
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread .pipelines/v2/templates/stages-java.yml
Comment thread sdk_v2/build_and_test_all.ps1
Comment thread sdk_v2/java/src/main/java/com/microsoft/foundry/local/AudioSession.java Outdated
Comment thread sdk_v2/DEVELOPMENT.md Outdated
@jiec-msft

Mason Chen (jiec-msft) commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

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.

@jiec-msft

Copy link
Copy Markdown
Member Author

Fixed-head validation is green on Windows x64/ARM64, Linux x64/ARM64, and macOS ARM64 (run); all five native jobs completed NativeAsrTest, including manager recreation. The four Copilot findings are fixed in 6615fa9 and resolved. Ready for review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread sdk_v2/java/src/main/java/com/microsoft/foundry/local/Transcription.java Outdated
Comment thread sdk_v2/java/src/main/java/com/microsoft/foundry/local/Transcription.java Outdated
Comment thread sdk_v2/java/src/main/java/com/microsoft/foundry/local/Catalog.java Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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>
@baijumeswani

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
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.

@jiec-msft

Copy link
Copy Markdown
Member Author

Continuation is now available in #1113 from the team-owned preview branch, merged with the current main pipeline layout. It preserves the original commits and attribution from this PR. Keeping #1100 unchanged for history.

@jiec-msft

Copy link
Copy Markdown
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants