Skip to content

Commit b379679

Browse files
Synchronize real-time audio API names (#692)
### Description This PR standardizes the names of several real-time audio APIs across the Foundry Local SDK language bindings. It also removes an extra unused API in the JS SDK. ### Motivation and Context The API names and their usage should be similar across the language bindings. This ensures one language binding is not favored over another language binding due to API usage. ### Copilot Summary This pull request standardizes the naming of the real-time transcription stream method across all SDKs by renaming methods like `GetTranscriptionStream`, `getTranscriptionStream`, and `get_transcription_stream` to `GetStream`, `getStream`, and `get_stream` respectively. It also renames related files and updates all references in documentation, tests, and code to match the new naming. Additionally, C++ and JS client files are renamed for consistency. These changes improve API clarity and make the SDKs more consistent across languages. **SDK method and API renaming:** * Renamed all real-time transcription stream methods to `GetStream`/`getStream`/`get_stream` in C#, JS, Python, and Rust SDKs, replacing previous names like `GetTranscriptionStream` and `getTranscriptionStream`. All usages and documentation references are updated accordingly. **File and import renaming for consistency:** * Renamed C++ and JS client files from `openai_live_audio_client.*` and `liveAudioTranscriptionClient.js` to `openai_live_audio_session.*` and `liveAudioSession.js`, updating all includes/imports throughout the codebase. **Interface and API cleanup:** * Removed the `createLiveTranscriptionSession` method from the JS `IModel` interface, reflecting the new naming and usage patterns. These changes ensure a consistent and predictable developer experience across all supported languages. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 58bba93 commit b379679

42 files changed

Lines changed: 88 additions & 95 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ logs/
3838

3939
# Local NuGet packages built from source
4040
local-packages/
41+
42+
# JS SDK downloaded native core binaries
43+
sdk/js/foundry-local-core/

samples/cs/live-audio-transcription/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ await model.DownloadAsync(progress =>
5252
{
5353
try
5454
{
55-
await foreach (var result in session.GetTranscriptionStream())
55+
await foreach (var result in session.GetStream())
5656
{
5757
var text = result.Content?[0]?.Text;
5858
if (result.IsFinal)

samples/cs/live-audio-transcription/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dotnet run -- --synth
3636
2. Creates a `LiveAudioTranscriptionSession` with 16kHz/16-bit/mono PCM settings
3737
3. Captures microphone audio via `NAudio.WaveInEvent` (or generates synthetic audio as fallback)
3838
4. Pushes PCM chunks to the SDK via `session.AppendAsync()` through a bounded channel for backpressure
39-
5. Reads transcription results via `await foreach (var result in session.GetTranscriptionStream())`
39+
5. Reads transcription results via `await foreach (var result in session.GetStream())`
4040
6. Access text via `result.Content[0].Text` (OpenAI Realtime ConversationItem pattern)
4141

4242
## API
@@ -54,7 +54,7 @@ await session.StartAsync();
5454
await session.AppendAsync(pcmBytes);
5555

5656
// Read results
57-
await foreach (var result in session.GetTranscriptionStream())
57+
await foreach (var result in session.GetStream())
5858
{
5959
Console.WriteLine(result.Content[0].Text); // transcribed text
6060
Console.WriteLine(result.Content[0].Transcript); // alias (OpenAI compat)

samples/js/live-audio-transcription/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Speak into your microphone. Transcription appears in real-time. Press `Ctrl+C` t
3030
2. Creates a `LiveAudioTranscriptionSession` with 16kHz/16-bit/mono PCM settings
3131
3. Captures microphone audio via `naudiodon2` (or generates synthetic audio as fallback)
3232
4. Pushes PCM chunks to the SDK via `session.append()`
33-
5. Reads transcription results via `for await (const result of session.getTranscriptionStream())`
33+
5. Reads transcription results via `for await (const result of session.getStream())`
3434
6. Access text via `result.content[0].text` (OpenAI Realtime ConversationItem pattern)
3535

3636
## API
@@ -48,7 +48,7 @@ await session.start();
4848
await session.append(pcmBytes);
4949

5050
// Read results
51-
for await (const result of session.getTranscriptionStream()) {
51+
for await (const result of session.getStream()) {
5252
console.log(result.content[0].text); // transcribed text
5353
console.log(result.content[0].transcript); // alias (OpenAI compat)
5454
console.log(result.is_final); // true for final results

samples/js/live-audio-transcription/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ console.log();
1515
// Initialize the Foundry Local SDK
1616
console.log('Initializing Foundry Local SDK...');
1717
const manager = FoundryLocalManager.create({
18-
appName: 'foundry',
18+
appName: 'foundry_local_samples',
1919
logLevel: 'info'
2020
});
2121
console.log('✓ SDK initialized');
@@ -55,7 +55,7 @@ console.log('✓ Session started');
5555
// Read transcription results in background
5656
const readPromise = (async () => {
5757
try {
58-
for await (const result of session.getTranscriptionStream()) {
58+
for await (const result of session.getStream()) {
5959
const text = result.content?.[0]?.text;
6060
if (!text) continue;
6161

samples/python/live-audio-transcription/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ python src/app.py --synth
4141
2. Creates a `LiveAudioTranscriptionSession` with 16kHz/16-bit/mono PCM settings
4242
3. Captures microphone audio via `pyaudio` (or generates synthetic audio as fallback)
4343
4. Pushes PCM chunks to the SDK via `session.append()`
44-
5. Reads transcription results in a background thread via `for result in session.get_transcription_stream()`
44+
5. Reads transcription results in a background thread via `for result in session.get_stream()`
4545
6. Access text via `result.content[0].text` (OpenAI Realtime ConversationItem pattern)
4646

4747
## API
@@ -59,7 +59,7 @@ session.start()
5959
session.append(pcm_bytes)
6060

6161
# Read results (typically on a background thread)
62-
for result in session.get_transcription_stream():
62+
for result in session.get_stream():
6363
print(result.content[0].text) # transcribed text
6464
print(result.content[0].transcript) # alias (OpenAI compat)
6565
print(result.is_final) # True for final results

samples/python/live-audio-transcription/src/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
# --- Background thread reads transcription results (mirrors JS readPromise) ---
5454

5555
def read_results():
56-
for result in session.get_transcription_stream():
56+
for result in session.get_stream():
5757
text = result.content[0].text if result.content else ""
5858
if result.is_final:
5959
print()

samples/rust/live-audio-transcription/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
6262
println!("✓ Session started\n");
6363

6464
// --- Background task reads transcription results (mirrors JS readPromise) ---
65-
let mut stream = session.get_transcription_stream().await?;
65+
let mut stream = session.get_stream().await?;
6666
let read_task = tokio::spawn(async move {
6767
while let Some(result) = stream.next().await {
6868
match result {

sdk/cpp/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ endif()
5252
add_library(CppSdk STATIC
5353
src/model.cpp
5454
src/catalog.cpp
55-
src/openai_chat_client.cpp
56-
src/openai_audio_client.cpp
57-
src/openai_live_audio_types.cpp
58-
src/openai_live_audio_client.cpp
55+
src/chat_client.cpp
56+
src/audio_client.cpp
57+
src/live_audio_types.cpp
58+
src/live_audio_session.cpp
5959
src/foundry_local_manager.cpp
6060
)
6161

sdk/cpp/include/foundry_local.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include "model.h"
1414
#include "catalog.h"
1515
#include "foundry_local_manager.h"
16-
#include "openai/openai_tool_types.h"
17-
#include "openai/openai_chat_client.h"
18-
#include "openai/openai_audio_client.h"
19-
#include "openai/openai_live_audio_types.h"
20-
#include "openai/openai_live_audio_client.h"
16+
#include "openai/tool_types.h"
17+
#include "openai/chat_client.h"
18+
#include "openai/audio_client.h"
19+
#include "openai/live_audio_types.h"
20+
#include "openai/live_audio_session.h"

0 commit comments

Comments
 (0)