-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Core speech to speech implementation #5654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pranavjoshi001
wants to merge
27
commits into
microsoft:main
Choose a base branch
from
pranavjoshi001:feature/core-s2s-composer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Core speech to speech implementation #5654
pranavjoshi001
wants to merge
27
commits into
microsoft:main
from
pranavjoshi001:feature/core-s2s-composer
+3,809
−59
Conversation
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
…joshi001/BotFramework-WebChat into feature/core-s2s-composer
OEvgeny
reviewed
Jan 13, 2026
compulim
reviewed
Jan 13, 2026
packages/api/src/providers/SpeechToSpeech/private/useRecorder.ts
Outdated
Show resolved
Hide resolved
compulim
reviewed
Jan 13, 2026
…joshi001/BotFramework-WebChat into feature/core-s2s-composer
compulim
reviewed
Jan 22, 2026
packages/api/src/decorator/ActivityBorder/private/ActivityBorderDecoratorRequestContext.ts
Outdated
Show resolved
Hide resolved
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
packages/api/src/providers/SpeechToSpeech/private/VoiceHandlerBridge.tsx
Outdated
Show resolved
Hide resolved
compulim
reviewed
Jan 22, 2026
packages/api/src/providers/SpeechToSpeech/private/VoiceRecorderBridge.tsx
Outdated
Show resolved
Hide resolved
compulim
reviewed
Jan 22, 2026
packages/api/src/providers/SpeechToSpeech/private/useRecorder.ts
Outdated
Show resolved
Hide resolved
compulim
reviewed
Jan 22, 2026
packages/api/src/providers/SpeechToSpeech/private/useRecorder.ts
Outdated
Show resolved
Hide resolved
compulim
reviewed
Jan 22, 2026
packages/api/src/providers/SpeechToSpeech/private/useRecorder.ts
Outdated
Show resolved
Hide resolved
compulim
reviewed
Jan 22, 2026
packages/api/src/providers/SpeechToSpeech/private/useRecorder.ts
Outdated
Show resolved
Hide resolved
compulim
reviewed
Jan 22, 2026
packages/api/src/providers/SpeechToSpeech/private/useRecorder.ts
Outdated
Show resolved
Hide resolved
compulim
reviewed
Jan 22, 2026
packages/api/src/providers/SpeechToSpeech/private/useAudioPlayer.ts
Outdated
Show resolved
Hide resolved
compulim
reviewed
Jan 22, 2026
packages/api/src/providers/SpeechToSpeech/private/useAudioPlayer.ts
Outdated
Show resolved
Hide resolved
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
compulim
reviewed
Jan 22, 2026
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.
Changelog Entry
Description
This PR introduces Speech-to-Speech (S2S) functionality in Web Chat, enabling real-time voice conversations with bots. The implementation includes audio recording via AudioWorklet, audio playback with buffer queueing, and speech state management. This foundation supports upcoming MMRT (Multi-Modal Real-Time), ABS (Azure Bot Service), and CCV2 integration changes.
Activity structure - microsoft/Agents#377
Design
The Speech-to-Speech feature is built on three main components:
Voice State Management (
voiceActivityreducer) - Manages:voiceState: Current speech state (idle,listening,user_speaking,processing,bot_speaking)voiceHandlers: Registered audio handler functions (supports multiple handlers)SpeechToSpeech Provider (
SpeechToSpeechComposer.tsx) - A React component that manages:VoiceHandlerBridge- Registers audio playback functions (queueAudio,stopAllAudio) with ReduxVoiceRecorderBridge- Bridges Redux voice state with microphone recording, sends audio chunks viapostVoiceActivityExposed control hooks:
useVoiceStart.ts- Hook to start s2s interactionuseVoiceStop.ts- Hook to stop s2s interaction (mic + audio stop)useVoiceState.ts- Current state of voice interactionSpeech State Flow
idle → listening → user_speaking → processing → bot_speaking → listening
Voice Activity Flow (Fire-and-Forget Pattern)
Outgoing (User → Bot):
postVoiceActivityaction →postVoiceActivitySaga→ DirectLine (no Redux storage)Incoming (Bot → User):
observeActivitySaga→ callsvoiceHandlers.queueAudio()directly (no Redux storage)Performance Optimization
Voice activities use a fire-and-forget pattern to optimize performance:
stream.chunk) are NOT stored in Redux - they flow directly to/from audio handlersqueueAudio,stopAllAudio), not datapostVoiceActivitySagasends without waiting for echo-back or dispatching PENDING/FULFILLED actionsSpecific Changes
New Files Added:
Core Utilities (packages/core)
isVoiceActivity.ts- Type guard for voice/DTMF activitiesisVoiceTranscriptActivity.ts- Type guard for transcript activitiesgetVoiceActivityRole.ts- Extract role (user/bot) from voice activitygetVoiceActivityText.ts- Extract transcription text from voice activityActions (packages/core/src/actions)
setVoiceState.ts- Set voice state actionstartVoiceRecording.ts- Start recording action (transitions tolistening)stopVoiceRecording.ts- Stop recording action (transitions toidle)registerVoiceHandler.ts- Register audio handler with unique IDunregisterVoiceHandler.ts- Unregister audio handler by IDpostVoiceActivity.ts- Fire-and-forget voice activity postingReducer (packages/core/src/reducers)
voiceActivity.ts- ManagesvoiceStateandvoiceHandlers(Map<string, VoiceHandler>)Sagas (packages/core/src/sagas)
postVoiceActivitySaga.ts- Handles outgoing voice activities (fire-and-forget)observeActivitySaga.ts- Routes incoming voice activities to handlersProvider & Hooks (packages/api)
SpeechToSpeechComposer.tsx- Main S2S provider (integrated into Composer)VoiceHandlerBridge.tsx- Registers audio player with ReduxVoiceRecorderBridge.tsx- Bridges recording state with microphoneuseRecorder.ts- AudioWorklet-based recording (CSP compliant)useAudioPlayer.ts- Audio playback with buffer queueinguseVoiceHandlers.ts- Hook to get registered voice handlersuseRegisterVoiceHandler.ts- Hook to register a voice handler (returns unregister function)useSetVoiceState.ts- Hook to set voice stateusePostVoiceActivity.ts- Hook to post voice activitiesTest Coverage Added:
useRecorderanduseAudioPlayerhooksCHANGELOG.mdReview Checklist
z-index)package.jsonandpackage-lock.jsonreviewed