flaky-london-71715
02/13/2025, 4:15 PMgray-monkey-83525
02/13/2025, 4:15 PMflaky-london-71715
02/13/2025, 4:20 PMflaky-london-71715
02/13/2025, 4:21 PMgray-monkey-83525
02/13/2025, 4:21 PMflaky-london-71715
02/18/2025, 12:30 PMgray-monkey-83525
02/18/2025, 12:30 PMconst express = require('express');
const { Worker } = require('@livekit/agents');
const { STT } = require('@livekit/agents-plugin-deepgram');
const app = express();
const port = 3000;
// Configure your LiveKit server details
const LIVEKIT_URL = 'your_livekit_url';
const LIVEKIT_API_KEY = 'your_api_key';
const LIVEKIT_API_SECRET = 'your_api_secret';
// Create a new worker
const worker = new Worker({
url: LIVEKIT_URL,
apiKey: LIVEKIT_API_KEY,
apiSecret: LIVEKIT_API_SECRET,
});
// Define the agent
worker.defineAgent('stt-agent', async (agent) => {
// Use the Deepgram STT plugin
const stt = new STT({ apiKey: 'your_deepgram_api_key' });
// Subscribe to all audio tracks in the room
agent.on('trackSubscribed', async (track) => {
if (track.kind === 'audio') {
const transcription = await stt.transcribe(track);
console.log('Transcription:', transcription);
}
});
});
// Start the worker
worker.start();
app.listen(port, () => {
console.log(`Express server running on port ${port}`);
});
This code sets up an Express.js server and a LiveKit agent using the Deepgram STT plugin. The agent subscribes to all audio tracks in the room and performs transcription. Note that you need to replace placeholders like your_livekit_url
, your_api_key
, your_api_secret
, and your_deepgram_api_key
with your actual credentials.
Would you like more detailed guidance on setting up this environment?
Sources:
- https://livekit-users.slack.com/archives/C048FRL1N2C/p1728484288.395119 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.flaky-london-71715
02/28/2025, 1:33 PMgray-monkey-83525
02/28/2025, 1:33 PMconst fetch = require('node-fetch');
async function getRoomBandwidth(projectId, sessionId, token) {
const endpoint = `https://cloud-api.livekit.io/api/project/${projectId}/sessions/${sessionId}`;
try {
const response = await fetch(endpoint, {
method: 'GET',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
});
if (!response.ok) throw new Error('Network response was not ok');
const data = await response.json();
console.log('Bandwidth In:', data.bandwidthIn);
console.log('Bandwidth Out:', data.bandwidthOut);
} catch (error) {
console.error('There was a problem:', error.message);
}
}
// Example usage
const projectId = 'your_project_id';
const sessionId = 'your_session_id';
const token = 'your_access_token';
getRoomBandwidth(projectId, sessionId, token);
This script fetches session details, including bandwidthIn
and bandwidthOut
, which represent the bytes of bandwidth uploaded and downloaded, respectively. Ensure you replace your_project_id
, your_session_id
, and your_access_token
with your actual project ID, session ID, and access token.
Would you like more detailed instructions on generating the access token or any other part of the process?
Sources:
- Analytics API 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.flaky-london-71715
02/28/2025, 1:34 PMflaky-london-71715
02/28/2025, 1:34 PMgray-monkey-83525
02/28/2025, 1:34 PMbandwidthOut
data, it might be due to the JSON package used by LiveKit, which excludes fields with no value or zero, as discussed in a Slack conversation. This could mean that the bandwidth data is not being recorded or is below a certain threshold.
To address this, you can try the following:
1. Verify Session Data: Ensure that the session in question has significant data transfer. Sessions with minimal data might not report bandwidth usage.
2. Use LiveKit Stats API: If available, the LiveKit Stats API might provide more detailed information about bandwidth usage. However, this API is not explicitly documented in the provided sources.
3. Contact Support: If the issue persists, consider reaching out to LiveKit support for assistance. They might provide insights or solutions specific to your setup.
Would you like more information on any of these steps?
Sources:
- Slack conversation on bandwidth issues 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.flaky-london-71715
02/28/2025, 1:45 PMgray-monkey-83525
02/28/2025, 1:45 PMflaky-london-71715
02/28/2025, 1:47 PMgray-monkey-83525
02/28/2025, 1:47 PMlastActive
timestamp or numActiveParticipants
.
Here's a basic approach using Node.js to list sessions and filter for active ones:
const fetch = require('node-fetch');
async function getActiveSessionId(projectId, roomName, token) {
const endpoint = `https://cloud-api.livekit.io/api/project/${projectId}/sessions`;
try {
const response = await fetch(endpoint, {
method: 'GET',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
});
if (!response.ok) throw new Error('Network response was not ok');
const data = await response.json();
const activeSession = data.sessions.find(session =>
session.roomName === roomName && session.numActiveParticipants > 0
);
if (activeSession) {
console.log('Active Session ID:', activeSession.sessionId);
return activeSession.sessionId;
} else {
console.log('No active session found for the specified room.');
return null;
}
} catch (error) {
console.error('There was a problem:', error.message);
}
}
// Example usage
const projectId = 'your_project_id';
const roomName = 'your_room_name';
const token = 'your_access_token';
getActiveSessionId(projectId, roomName, token);
This script fetches all sessions and filters them to find an active session for the specified room name. Ensure you replace your_project_id
, your_room_name
, and your_access_token
with your actual project ID, room name, and access token.
Would you like more detailed guidance on any part of this process?
Sources:
- Analytics API 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.flaky-london-71715
03/06/2025, 7:43 AMtall-airline-16756
03/06/2025, 7:44 AMtall-airline-16756
03/06/2025, 7:44 AM