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
2Install VideoSDK
Install the VideoSDK using the pip command below.
1pip install videosdk
2Project Structure
Your project structure should look like this:
1videosdk-python
2├── main.py
3├── meeting_events.py
4├── participant_events.py
5├── api.py
6api.pycreates a meeting with the VideoSDK Rooms API and prints themeetingId.main.pybuilds the meeting configuration, initializes the meeting, registers the event handler, and joins.meeting_events.pyhandles meeting lifecycle events and attaches a participant handler to every participant who joins.participant_events.pyhandles 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
8The core VideoSDK concepts used in this tutorial are:
- A room is uniquely identified by its
meeting_id(theroomIdreturned by the Rooms API). - Every remote user is represented by a
Participantwith a uniqueid. - Microphone media is carried as a
Stream. Thekindattribute tells you whether a stream isaudioorvideo. MeetingEventHandlerandParticipantEventHandlerare 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)
21Run it once to get a meeting ID:
1python api.py
2Note
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,
3mic_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()
31Important
Replace
<TOKEN>with the token generated from the VideoSDK Dashboard and<MEETING_ID>with the meeting ID printed byapi.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)
20on_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)
13In 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()
8Step 6: Run Your Code
Execute the application using:
1python main.py
2Complete 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()
35Final 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
6To 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.
