video sdk logo

Login

Python Audio Rooms Tutorial

Build audio-only rooms in Python with asyncio. Join a room with video disabled, subscribe to each speaker's audio, and manage who is allowed to talk from your own application code.
Python SDK for server-side video calls, audio rooms, and AI voice agents

Trusted by 300+ global business & tech leaders

Build an Audio-Only Session in Python

Learn how to build an audio-only session in Python using the VideoSDK Python SDK. This tutorial covers room setup, subscribing to participant audio frames, publishing your own audio track, and speaker and moderation controls.


No participant video is published. The meeting joins with the microphone enabled and the camera disabled, which is the technical foundation for a voice-only Python client — a server-side audio participant, a voice bot, or an audio-only companion to your web and mobile apps.

Prerequisites

Before proceeding, ensure that your development environment meets the following requirements:

  • VideoSDK Developer Account (Not having one? Follow VideoSDK Dashboard)
  • Basic understanding of Python
  • Python installed on your device.
  • Python VideoSDK
  • Python asyncio (optional)

Important

You need a VideoSDK account to generate a token. Visit the VideoSDK dashboard to generate a token.

Getting Started with the Code!

Follow the steps to create the environment necessary to add audio calls to your app. You can also find the code sample for quickstart here.

Create a New Python Project

Create a new Python project using the below command.

1mkdir videosdk-python && cd videosdk-python
2

Install VideoSDK

Install the VideoSDK using the pip command below.

1pip install videosdk
2

Project Structure

Your project structure should look like this:

1videosdk-python
2├── main.py
3├── meeting_events.py
4├── participant_events.py
5├── api.py
6
  • api.py creates a meeting with the VideoSDK Rooms API and prints the meetingId.
  • main.py builds the meeting configuration, initializes the meeting, registers the event handler, and joins.
  • meeting_events.py handles meeting lifecycle events and attaches a participant handler to every participant who joins.
  • participant_events.py handles per-participant stream events.

App Architecture

The app uses this flow:

1api.py                       → creates a room and returns the meetingId
2main.py
3├── MeetingConfig            → mic_enabled=True, webcam_enabled=False
4├── VideoSDK.init_meeting()  → creates the Meeting instance
5├── MyMeetingEventHandler    → meeting joined / left, participant joined / left
6│   └── MyParticipantEventHandler   → per-participant stream enabled / disabled
7└── meeting.join()           → joins the room
8

The core VideoSDK concepts used in this tutorial are:

  • A room is uniquely identified by its meeting_id (the roomId returned by the Rooms API).
  • Every remote user is represented by a Participant with a unique id.
  • Microphone media is carried as a Stream. The kind attribute tells you whether a stream is audio or video.
  • MeetingEventHandler and ParticipantEventHandler are the two callback classes you subclass to react to what happens in the room.

Step 1: Create an API Call

Before moving on, create an API request to generate a unique meetingId. You will need an authentication token, which you can create either through the videosdk-rtc-api-server-examples or directly from the VideoSDK Dashboard for developers.

api.py

1import requests
2
3# This is the Auth token, you will use it to generate a meeting and connect to it
4token = "<Your-Token>"
5
6# API call to create a meeting
7def create_meeting(token):
8    url = "https://api.videosdk.live/v2/rooms"
9    headers = {
10        "authorization": token,
11        "Content-Type": "application/json"
12    }
13    response = requests.post(url, headers=headers, json={})
14    response_data = response.json()
15    room_id = response_data.get("roomId")
16    return room_id
17
18# Example usage
19meeting_id = create_meeting(token)
20print("Meeting ID:", meeting_id)
21

Run it once to get a meeting ID:

1python api.py
2

Note

Don't confuse the Room and Meeting keywords, both are the same thing 😃

Step 2: Join the Meeting

The important audio-only configuration is:

1mic_enabled=True,
2webcam_enabled=False,
3

mic_enabled=True allows the participant to publish microphone audio. webcam_enabled=False prevents the camera from being enabled when the participant joins the meeting.

main.py

1import asyncio
2from videosdk import MeetingConfig, VideoSDK
3
4VIDEOSDK_TOKEN = "<TOKEN>"
5MEETING_ID = "<MEETING_ID>"
6NAME = "<NAME>"
7loop = asyncio.get_event_loop()
8
9def main():
10    meeting_config = MeetingConfig(
11        meeting_id=MEETING_ID,
12        name=NAME,
13        mic_enabled=True,
14        webcam_enabled=False,
15        token=VIDEOSDK_TOKEN
16    )
17
18    # Initialize the meeting
19    meeting = VideoSDK.init_meeting(**meeting_config)
20
21    print("Joining the meeting...")
22
23    # Join the meeting
24    meeting.join()
25
26    print("Joined successfully")
27
28if __name__ == '__main__':
29    main()
30    loop.run_forever()
31

Important

Replace <TOKEN> with the token generated from the VideoSDK Dashboard and <MEETING_ID> with the meeting ID printed by api.py.

Step 3: Listen to Meeting Events

meeting_events.py

1from videosdk import Participant, MeetingEventHandler
2from participant_events import MyParticipantEventHandler
3
4class MyMeetingEventHandler(MeetingEventHandler):
5    def __init__(self):
6        super().__init__()
7
8    def on_meeting_joined(self, data):
9        print("Meeting joined:", data)
10
11    def on_meeting_left(self, data):
12        print("Meeting left:", data)
13
14    def on_participant_joined(self, participant: Participant):
15        print("Participant joined:", participant)
16        participant.add_event_listener(MyParticipantEventHandler(participant_id=participant.id))
17
18    def on_participant_left(self, participant: Participant):
19        print("Participant left:", participant)
20

on_participant_joined attaches a MyParticipantEventHandler to each participant, which is what lets you observe their microphone stream in the next step.

Step 4: Listen to Participant Events

participant_events.py

1from videosdk import ParticipantEventHandler, Stream
2
3class MyParticipantEventHandler(ParticipantEventHandler):
4    def __init__(self, participant_id: str):
5        super().__init__()
6        self.participant_id = participant_id
7
8    def on_stream_enabled(self, stream: Stream):
9        print("Participant stream enabled:", self.participant_id, stream.kind)
10
11    def on_stream_disabled(self, stream: Stream):
12        print("Participant stream disabled:", self.participant_id, stream.kind)
13

In an audio call, stream.kind will be audio when a participant unmutes and their microphone stream becomes available.

Step 5: Add Event Listeners

Update main.py to include event listeners before joining:

1from meeting_events import MyMeetingEventHandler
2
3# Add this line
4meeting.add_event_listener(MyMeetingEventHandler())
5
6# Before joining the meeting
7meeting.join()
8

Step 6: Run Your Code

Execute the application using:

1python main.py
2

Complete Code

For easy copying, this is the completed main.py after implementing Steps 2 and 5. The other three files are already complete as shown above.

main.py

1import asyncio
2from videosdk import MeetingConfig, VideoSDK
3from meeting_events import MyMeetingEventHandler
4
5VIDEOSDK_TOKEN = "<TOKEN>"
6MEETING_ID = "<MEETING_ID>"
7NAME = "<NAME>"
8loop = asyncio.get_event_loop()
9
10def main():
11    meeting_config = MeetingConfig(
12        meeting_id=MEETING_ID,
13        name=NAME,
14        mic_enabled=True,
15        webcam_enabled=False,
16        token=VIDEOSDK_TOKEN
17    )
18
19    # Initialize the meeting
20    meeting = VideoSDK.init_meeting(**meeting_config)
21
22    # Add event listener before joining the meeting
23    meeting.add_event_listener(MyMeetingEventHandler())
24
25    print("Joining the meeting...")
26
27    # Join the meeting
28    meeting.join()
29
30    print("Joined successfully")
31
32if __name__ == '__main__':
33    main()
34    loop.run_forever()
35

Final Output

Run python api.py to create a room, put the printed meeting ID and your token into main.py, then run python main.py.

The console prints the meeting lifecycle as it happens:

1Joining the meeting...
2Joined successfully
3Meeting joined: ...
4Participant joined: ...
5Participant stream enabled: <participant-id> audio
6

To see remote participants appear, open the same meeting ID from a second client — for example the VideoSDK web or mobile quickstart app — and join with the same token. Each join, leave, mute, and unmute shows up in your Python console through the two handlers.

Your completed Python audio client can now:

  • Create a new VideoSDK room with the Rooms API
  • Join an existing room using a meeting ID
  • Publish microphone audio without enabling the camera
  • React to meeting joined and meeting left events
  • React to participants joining and leaving
  • React to each participant's audio stream being enabled or disabled

You have completed the implementation of an audio call using VideoSDK in Python. To explore more features go through the upcoming detailed guides.

Tip

You can check out the complete quick start example here.

Summarize with

ChatGPTClaudePerplexityGoogleGrok
Prefer VideoSDK on Google

Table of Contents

Start Building Now With $20 Free Balance

No credit card required to start.

Documentation →Github Repo →

Share This Article

TwitterLinkedInFacebookHacker News

Get started for free today

Grab your API keys and start building with free $20 included in your account. Need enterprise-grade security or custom workloads? Talk to an expert!

Book a demo

Video SDK Logo

United States

28 Geary St, Suite 650,
San Francisco, CA 94108, United States

India flag

India

18th Floor, 1812, The Junomoneta Tower,
Adajan-Hazira Rd, Surat, Gujarat 395009, India

Video SDK Logo
Video SDK Logo
Video SDK Logo
Video SDK Logo
SOLUTIONS

Video KYC

Video Banking

Virtual Claim

Video MER

Telehealth

Astrology

Gaming

Dating

Live Commerce

Auto Proctoring

Interview-as-a-service

Virtual Events

Live Audio Streaming

Ed-Tech

PRODUCTS

AI-Agents

Real-time Audio & Video SDK

Interactive Live Streaming SDK

Real-time Transcription SDK

Character SDK

Open Source Examples

SUCCESS STORIES

Examedi

Coderschool

TYHO

ForagerOne

Immigo

DEVELOPERS

Documentation

Code Samples

Developer Updates

Developer Hub

TOP ARTICLES

What is WebRTC?

Build a React Native Video Calling App

Build a Flutter Video Calling App

RESOURCES

The Protocol by Video SDK

AI Apps

Creator Program

LEGAL

Terms Of Service

Privacy Policy

Cookie Notice

CCPA Notice

Subprocessors

DPA

RSS

COMPANY

Contact Us

Pricing

Support

Blog

Press Kit