-
Notifications
You must be signed in to change notification settings - Fork 222
Open
Description
π¨ iOS: No Remote Audio Output When Using Speech-to-Text with LiveKit
(AVAudioSession conflict with playAndRecord + measurement mode)
π Description
I am building a Flutter chat application using:
- π₯ LiveKit for real-time audio/video
- ποΈ A WebSocket-based Speech-to-Text (STT) service
The goal is to run both simultaneously:
- Bi-directional audio via LiveKit
- Microphone capture for transcription
- Send transcription result to
lk.chattopic - Hear remote participants while STT runs
π§© Use Case Flow
- User joins a LiveKit room (audio/video enabled).
- User speaks in their native language.
- Microphone audio is captured.
- Audio is sent to a managed STT service via WebSocket.
- Transcription result is sent to
lk.chat. - User should simultaneously hear remote participant audio.
β Problem
When I initialize Speech-to-Text during an active LiveKit session:
- β Transcription works correctly
- β Remote audio stops playing
- β No sound from speaker or connected output device
- β Microphone continues to work
If I remove STT initialization:
- β LiveKit audio works perfectly
This strongly suggests an AVAudioSession configuration conflict.
π Current Audio Session Configuration
I am manually configuring the audio session as follows:
Future configureAudioSession() async {
final session = await AudioSession.instance;
await session.configure(
AudioSessionConfiguration(
avAudioSessionCategory: AVAudioSessionCategory.playAndRecord,
avAudioSessionCategoryOptions:
AVAudioSessionCategoryOptions.allowBluetooth |
AVAudioSessionCategoryOptions.defaultToSpeaker,
avAudioSessionMode: AVAudioSessionMode.measurement,
avAudioSessionRouteSharingPolicy:
AVAudioSessionRouteSharingPolicy.defaultPolicy,
androidAudioAttributes: const AndroidAudioAttributes(
contentType: AndroidAudioContentType.speech,
usage: AndroidAudioUsage.voiceCommunication,
),
androidAudioFocusGainType: AndroidAudioFocusGainType.gain,
androidWillPauseWhenDucked: false,
),
);
}π§ͺ What I Tried
- Calling
configureAudioSession()before initializing STT - Calling it after initializing STT
- Changing
AVAudioSessionMode - Re-configuring session after STT starts
- Multiple ordering combinations
None of these resolved the issue.
π Observations
- STT works fine independently
- LiveKit works fine independently
- Issue only occurs when both are active
- STT likely reconfigures
AVAudioSessioninternally - Possible conflict between:
AVAudioSessionMode.measurementvoiceCommunication- LiveKitβs internal audio handling
β Questions
- Does LiveKit internally override
AVAudioSessionafter room connection? - Is there a recommended approach to use:
- LiveKit (bi-directional audio)
- Simultaneous mic capture for STT
- Should
AVAudioSessionMode.measurementbe avoided in this case? - Is there a known working configuration for:
playAndRecord- Speaker output
- Bluetooth support
- LiveKit
- Parallel microphone capture for STT?
π§Ύ Environment
- Flutter version: [add version]
livekit_clientversion: [add version]- iOS version: [add version]
- Device: [add device model]
π Additional Context
If there is any recommended pattern, sample implementation, or best practice for running LiveKit audio + Speech-to-Text simultaneously on iOS, that would be greatly appreciated.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels