feat(inference): propagate STT extra to SpeechData.metadata#1389
Open
toubatbrian wants to merge 3 commits intomainfrom
Open
feat(inference): propagate STT extra to SpeechData.metadata#1389toubatbrian wants to merge 3 commits intomainfrom
toubatbrian wants to merge 3 commits intomainfrom
Conversation
Port of livekit/agents#5639. Adds an optional `metadata` field on `SpeechData` and plumbs the inference gateway's per-transcript `extra` field through to it, exposing provider-specific signals (e.g. Inworld voice profile, xAI speech_final) to downstream consumers.
|
|
🦋 Changeset detectedLatest commit: 1c4ba58 The changes in this PR will be included in the next version bump. This PR includes changesets to release 31 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
tinalenguyen
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Port of livekit/agents#5639 ("feat(inference): propagate STT extra to SpeechData.metadata").
This plumbs the inference gateway's per-transcript
extrafield ontoSpeechData.metadata, unblocking consumers of provider-specific STT signals — most immediately Inworld STT 1's voice profile (age, emotion, pitch, vocal style, accent, gender), which the gateway emits underextra["voice_profile"]. xAI STT, which already emitsextra["speech_final"], will also start surfacing onSpeechData.metadataafter this lands. The change is generic, not provider-specific.Ported changes
agents/src/stt/stt.ts— Add an optionalmetadata?: Record<string, unknown>field to theSpeechDatainterface, mirroring the newmetadata: dict[str, Any] | Nonefield on the PythonSpeechDatadataclass.agents/src/inference/stt.ts— InprocessTranscript, extractdata.extra(already part of thesttInterimTranscriptEventSchema/sttFinalTranscriptEventSchemazod schemas asz.unknown().nullable().optional()) and surface it onSpeechData.metadatawhenever it is a non-empty object.Implementation nuances
The Python upstream is a 5-line change:
The JS port is a few lines longer because the schemas already typed
extraasz.unknown().nullable().optional()(vs. Python'sdict.get), so the JS guard has to widen the runtime check to TypeScript's structural type system:Behavior matches the Python semantics 1:1:
null, non-objects, arrays, and empty objects all collapse toundefined(Python'sNone); only non-empty plain object payloads are forwarded.The
SpeechDatainterface field usesRecord<string, unknown>rather thanRecord<string, any>to comply with the repo's strict ESLint rules (the repo bansany).Test plan
pnpm build:agentspassespnpm test -- --run agents/src/inference/sttpasses (43/43)pnpm lintproduces no new warnings onagents/src/inference/stt.tsoragents/src/stt/stt.tspnpm format:writeclean on the touched files.changeset/inference-stt-metadata.mdalt.metadata["voice_profile"]is populated onFINAL_TRANSCRIPTevents🤖 This PR was opened by an automated Claude Code routine that ports merged PRs from livekit/agents (Python) to livekit/agents-js. The routine is in experimentation — please flag anything that looks off.
cc @toubatbrian @livekit/agent-devs
🤖 Generated with Claude Code
Generated by Claude Code