important-judge-78504
06/06/2025, 6:26 PMtall-airline-16756
06/06/2025, 6:26 PMtall-airline-16756
06/06/2025, 6:26 PMAutoSubscribe.AUDIO_ONLY
to automatically subscribe to all audio tracks.
This setup allows you to transcribe audio from multiple participants simultaneously, with each participant's audio being processed in a separate task. If you'd like more detailed guidance or code examples, feel free to ask!
Sources: Tree View: | dse-workbenchimportant-judge-78504
06/06/2025, 6:27 PMtall-airline-16756
06/06/2025, 6:28 PMimport asyncio
from livekit import rtc, transcription
from livekit.rtc import AutoSubscribe
async def transcribe_track(participant, track):
audio_stream = rtc.AudioStream(track)
stt_forwarder = transcription.STTSegmentsForwarder(
room=ctx.room, participant=participant, track=track
)
stt_stream = transcription.SpeechStream()
asyncio.create_task(_forward_transcription(stt_stream, stt_forwarder))
async for ev in audio_stream:
stt_stream.push_frame(ev.frame)
@ctx.room.on("track_subscribed")
def on_track_subscribed(track, publication, participant):
if track.kind == rtc.TrackKind.KIND_AUDIO:
asyncio.create_task(transcribe_track(participant, track))
async def main():
await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)
# Replace with your LiveKit server details
ctx = rtc.Context(
url="<wss://yourhost.livekit.cloud>",
api_key="livekit-api-key",
api_secret="your-api-secret"
)
asyncio.run(main())
Before running this code, ensure you have the required dependencies installed:
pip install livekit-agents>=0.12.20 livekit-plugins-deepgram>=0.7.3 python-dotenv~=1.0
Also, set up the necessary environment variables:
export LIVEKIT_URL=<wss://yourhost.livekit.cloud>
export LIVEKIT_API_KEY=livekit-api-key
export LIVEKIT_API_SECRET=your-api-secret
export OPENAI_API_KEY=your-api-key
Once everything is set up, you can run the script to start transcribing audio from multiple participants. Let me know if you need further assistance!
Sources: Tree View: | dse-workbench | Tree View: | dse-workbenchimportant-judge-78504
06/06/2025, 6:29 PMtall-airline-16756
06/06/2025, 6:29 PMimportant-judge-78504
06/06/2025, 6:31 PMtall-airline-16756
06/06/2025, 6:31 PM