wooden-smartphone-55787
02/13/2025, 8:29 AMgray-monkey-83525
02/13/2025, 8:29 AMVoicePipelineAgent
, you can access the SIP participant's attributes. Specifically, the sip.trunkPhoneNumber
attribute contains the phone number that was dialed. You can retrieve this information by waiting for the participant and then accessing their attributes.
Here's a basic example:
participant = await ctx.wait_for_participant()
dialed_number = participant.attributes.get('sip.trunkPhoneNumber')
This code waits for a participant to join and then retrieves the dialed phone number from the participant's attributes.
Would you like more details on this process?
Sources:
- LiveKit Slack Discussion 👍 1 button 👎 0 button 💡 Hint: Mention @millions-hair-24956 in the thread for followups.wooden-smartphone-55787
02/13/2025, 11:02 AMgray-monkey-83525
02/13/2025, 11:02 AMLiveKitAPI
to remove a participant from the room and play a message before disconnection. Here's a basic approach:
1. Define a function to play a message: Use the Text-to-Speech (TTS) capabilities to play a message to the participant.
2. Remove the participant: Use the remove_participant
method to disconnect the participant after the message is played.
Here's a Python example:
async def disconnect_with_message(ctx, participant, message):
# Play the message using TTS
await ctx.tts.say(message)
# Disconnect the participant
lk_api = api.LiveKitAPI()
await lk_api.room.remove_participant(
api.RoomParticipantIdentity(
room=ctx.room.name, identity=participant.identity
)
)
This function first plays a message to the participant and then disconnects them from the room.
Would you like more details on implementing this?
Sources:
- LiveKit Slack Discussion 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.wooden-smartphone-55787
02/13/2025, 11:05 AMgray-monkey-83525
02/13/2025, 11:05 AMapi.LiveKitAPI()
, you should use the livekit
Python package. This package provides the necessary classes and methods to interact with LiveKit's API, including room management and participant control.
You can install the package using pip:
pip install livekit
Would you like more details on how to set up and use this package?
Sources:
- https://docs.livekit.io/home/quickstarts/swift/
- https://livekit-users.slack.com/archives/C07FY8WHGPM/p1727992834.783299 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.wooden-smartphone-55787
02/13/2025, 11:08 AMgray-monkey-83525
02/13/2025, 11:08 AMapi
module is part of the livekit
Python package. You can import it using:
from livekit import api
This import statement allows you to access the LiveKitAPI
class and other related functionalities provided by the livekit
package.
Would you like more details on using this module?
Sources:
- https://livekit-users.slack.com/archives/C07FY8WHGPM/p1727992834.783299 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.wooden-smartphone-55787
02/13/2025, 11:15 AMgray-monkey-83525
02/13/2025, 11:15 AMJobContext
object does not directly have a tts
attribute. To use Text-to-Speech (TTS) capabilities, you should ensure that you have initialized a TTS instance separately and are using it correctly within your code.
Here's a basic example of how you might set up and use TTS in a LiveKit agent:
from livekit import agents, rtc
from livekit.plugins import openai
async def entrypoint(ctx: agents.JobContext):
# Initialize TTS
tts = openai.TTS(api_key='your_openai_api_key')
# Connect to the room
await ctx.connect()
# Wait for a participant
participant = await ctx.wait_for_participant()
# Use TTS to say a message
await tts.synthesize("Hello, this is a test message.")
# Disconnect the participant
await ctx.room.disconnect()
Ensure that you have properly initialized the TTS instance and are calling its methods directly, rather than expecting it to be an attribute of JobContext
.
Would you like more details on setting up TTS?
Sources:
- https://docs.livekit.io/python/livekit/agents/pipeline/index.html#livekit.agents.pipeline.VoicePipelineAgent.MIN_TIME_PLAYED_FOR_COMMIT 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.