Add live audio transcription streaming support to Foundry Local C# SDK#485
Add live audio transcription streaming support to Foundry Local C# SDK#485
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds a new C# SDK API for live/streaming audio transcription sessions (push PCM chunks, receive incremental/final text results) and includes a Windows microphone demo sample.
Changes:
- Introduces
LiveAudioTranscriptionSession+ result/error types for streaming ASR over Core interop. - Extends Core interop to support audio stream start/push/stop (including binary payload routing).
- Adds a
samples/cs/LiveAudioTranscriptiondemo project and updates the audio client factory API.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk_v2/cs/test/FoundryLocal.Tests/Utils.cs | Replaced prior test utilities with ad-hoc top-level streaming harness code (currently breaks test build). |
| sdk_v2/cs/test/FoundryLocal.Tests/ModelTests.cs | Adds trailing blank lines (formatting noise). |
| sdk_v2/cs/src/OpenAI/LiveAudioTranscriptionTypes.cs | Adds LiveAudioTranscriptionResult and a structured Core error type. |
| sdk_v2/cs/src/OpenAI/LiveAudioTranscriptionClient.cs | Adds LiveAudioTranscriptionSession implementation (channels, retry, stop semantics). |
| sdk_v2/cs/src/OpenAI/AudioClient.cs | Adds CreateLiveTranscriptionSession() and removes the public file streaming transcription API. |
| sdk_v2/cs/src/Detail/JsonSerializationContext.cs | Registers new audio streaming types for source-gen JSON. |
| sdk_v2/cs/src/Detail/ICoreInterop.cs | Adds interop structs + methods for audio stream start/push/stop. |
| sdk_v2/cs/src/Detail/CoreInterop.cs | Implements binary command routing via execute_command_with_binary and start/stop routing via execute_command. |
| sdk_v2/cs/src/AssemblyInfo.cs | Adds InternalsVisibleTo("AudioStreamTest"). |
| samples/cs/LiveAudioTranscription/README.md | Documentation for the live transcription demo sample. |
| samples/cs/LiveAudioTranscription/Program.cs | Windows microphone demo using NAudio + new session API. |
| samples/cs/LiveAudioTranscription/LiveAudioTranscription.csproj | Adds sample project dependencies and references the SDK project (path currently incorrect). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
samples/cs/LiveAudioTranscription/LiveAudioTranscription.csproj
Outdated
Show resolved
Hide resolved
samples/cs/LiveAudioTranscription/LiveAudioTranscription.csproj
Outdated
Show resolved
Hide resolved
samples/cs/LiveAudioTranscription/LiveAudioTranscription.csproj
Outdated
Show resolved
Hide resolved
samples/cs/LiveAudioTranscription/LiveAudioTranscription.csproj
Outdated
Show resolved
Hide resolved
|
Is there any reason to add zip and dlls at LiveAudioTranscription? |
Yes, I am deleting this. It was caused by the rename a lot of folders and mistakenly upload the test folder etc,, let me revert it back. |
bb68897 to
ed9e350
Compare
Here's the updated PR description based on the latest changes (renamed types, CoreInterop routing fix, mermaid updates):
Title: Add live audio transcription streaming support to Foundry Local C# SDK
Description:
Adds real-time audio streaming support to the Foundry Local C# SDK, enabling live microphone-to-text transcription via ONNX Runtime GenAI's StreamingProcessor API (Nemotron ASR).
The existing
OpenAIAudioClientonly supports file-based transcription. This PR introducesLiveAudioTranscriptionSessionthat accepts continuous PCM audio chunks (e.g., from a microphone) and returns partial/final transcription results as an async stream.What's included
New files
src/OpenAI/LiveAudioTranscriptionClient.cs— Streaming session withStartAsync(),AppendAsync(),GetTranscriptionStream(),StopAsync()src/OpenAI/LiveAudioTranscriptionTypes.cs—LiveAudioTranscriptionResultandCoreErrorResponsetypesModified files
src/OpenAI/AudioClient.cs— AddedCreateLiveTranscriptionSession()factory methodsrc/Detail/ICoreInterop.cs— AddedStreamingRequestBufferstruct,StartAudioStream,PushAudioData,StopAudioStreaminterface methodssrc/Detail/CoreInterop.cs— Routes audio commands through existingexecute_command/execute_command_with_binarynative entry points (no separate audio exports needed)src/Detail/JsonSerializationContext.cs— RegisteredLiveAudioTranscriptionResultfor AOT compatibilitytest/FoundryLocal.Tests/Utils.cs— Updated to useCreateLiveTranscriptionSession()Documentation
API surface
Design highlights
Channel<T>serializes audio pushes from any thread (safe for mic callbacks) with backpressureStartAsync()and immutable during the sessionStopAsyncalways calls native stop even if cancelled, preventing native session leaksCancellationTokenSource, decoupled from the caller's tokenStartAudioStreamandStopAudioStreamroute throughexecute_command;PushAudioDataroutes throughexecute_command_with_binary— no new native entry points requiredCore integration (neutron-server)
The Core side (AudioStreamingSession.cs) uses
StreamingProcessor+Generator+Tokenizer+TokenizerStreamfrom onnxruntime-genai to perform real-time RNNT decoding. The native commands (audio_stream_start/push/stop) are handled as cases inNativeInterop.ExecuteCommandManaged/ExecuteCommandWithBinaryManaged.Verified working
StreamingProcessorpipeline verified with WAV file (correct transcript)TranscribeChunkbyte[] PCM path matches reference float[] path exactly