polite-dog-12152
09/02/2025, 1:27 PMtall-airline-16756
09/02/2025, 1:27 PMtall-airline-16756
09/02/2025, 1:27 PMpolite-dog-12152
09/02/2025, 1:27 PMtall-airline-16756
09/02/2025, 1:28 PMconversation_item_added to catch messages as they happen and upload them right away.
If you want, I’d be happy to walk you through detailed steps or share some code examples to get you started—just let me know!
Sources: README.md | Auto egress | LiveKit Docs | livekit/livekit_egress.pb.go | s3.go | Sending text | LiveKit Docspolite-dog-12152
09/02/2025, 1:34 PMtall-airline-16756
09/02/2025, 1:35 PMfrom livekit import api
async def start_recording():
# Set up the recording request
req = api.RoomCompositeEgressRequest(
room_name="your-room-name",
audio_only=True, # Switch to False if you want video + audio
file_outputs=[
api.EncodedFileOutput(
file_type=api.EncodedFileType.OGG, # Use MP4 if you’re recording video
filepath="recordings/{room_name}-{time}.ogg",
s3=api.S3Upload(
bucket="your-s3-bucket",
region="us-east-1",
access_key="your-access-key",
secret="your-secret-key",
),
),
],
)
# Kick off the recording
lkapi = api.LiveKitAPI()
egress_info = await lkapi.egress.start_room_composite_egress(req)
await lkapi.aclose()
print(f"Recording started: {egress_info.url}")
# Let’s run it
import asyncio
asyncio.run(start_recording())
Here’s what to do next:
1. Swap out your-room-name, your-s3-bucket, your-access-key, and your-secret-key with your actual details.
2. Make sure you’ve installed the LiveKit Python SDK if you haven’t already.
3. Run the script and watch your recording start and upload to S3 seamlessly.
If you want to chat about storing text transcripts or need help tweaking this further, just give me a shout—I’m here to help!polite-dog-12152
09/02/2025, 1:45 PMtall-airline-16756
09/02/2025, 1:46 PMpolite-dog-12152
09/02/2025, 1:51 PMtall-airline-16756
09/02/2025, 1:51 PMprefix field in your storage configuration. This prefix will be added to all the filenames you upload to S3, keeping things nice and organized.
Here’s a quick example:
storage:
prefix: "your-s3-prefix/" # This will prepend all uploaded file paths
s3:
access_key: "your-access-key"
secret: "your-secret"
region: "your-region"
bucket: "your-bucket"
Want to get fancy with dynamic prefixes? You can use filename templates like {room_name} or {time} to create prefixes on the fly. For example:
filepath: "{room_name}/{time}-recording.mp4"
This means your recordings would be saved in paths like my-room/2022-10-04T150405-recording.mp4, which is super handy!
If you have any questions or need a hand setting this up, just let me know—I’m here to help!
Sources: README.md | cmd/lk/examples/track-composite-file.json | Kubernetes & Helm Charts | livekit/livekit_composite | DeepWikipolite-dog-12152
09/02/2025, 2:03 PMtall-airline-16756
09/02/2025, 2:04 PMimport json\nfrom datetime import datetime\n\ndef save_transcript(session):\n filename = f"/tmp/{session.room.name}_transcript.json"\n with open(filename, 'w') as f:\n json.dump(session.history.to_dict(), f, indent=2)\n return filename
2. Upload JSON to S3:
You can use an S3 SDK like Boto3 for Python to upload your JSON file to the folder you want:
import boto3\n\ndef upload_to_s3(local_file, bucket, s3_path):\n s3 = boto3.client('s3', aws_access_key_id='your-access-key', aws_secret_access_key='your-secret-key')\n s3.upload_file(local_file, bucket, s3_path)\n print(f"Uploaded {local_file} to s3://{bucket}/{s3_path}")\n\n# Example usage\nlocal_file = save_transcript(session)\nupload_to_s3(local_file, 'your-s3-bucket', 'transcripts/room123/session.json')
3. Dynamic Directory Paths:
Want to organize things automatically? You can create S3 paths that change based on the room name or time, like this:
s3_path = f"transcripts/{session.room.name}/{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
If you’d like a hand with setting this up or have any questions, just let me know—I’m here to help!
Sources: Session recording and transcripts | LiveKit Docs | storage_test.go | Egress output types | LiveKit Docspolite-dog-12152
09/02/2025, 2:05 PMtall-airline-16756
09/02/2025, 2:05 PMaudio_only parameter to True and pick the audio file format you want (like OGG or MP4).
from livekit import api
async def start_audio_recording():
req = api.RoomCompositeEgressRequest(
room_name="your-room-name",
audio_only=True, # This makes sure only audio is recorded
file_outputs=[
api.EncodedFileOutput(
file_type=api.EncodedFileType.OGG, # Use MP4 if you want AAC audio
filepath="recordings/{room_name}-{time}.ogg",
s3=api.S3Upload(
bucket="your-s3-bucket",
region="us-east-1",
access_key="your-access-key",
secret="your-secret-key",
),
),
],
)
lkapi = api.LiveKitAPI()
egress_info = await lkapi.egress.start_room_composite_egress(req)
await lkapi.aclose()
print(f"Audio recording started: {egress_info.url}")
# Run the function
import asyncio
asyncio.run(start_audio_recording())
2. Supported Audio Formats:
• OGG - Great choice for Opus audio encoding.
• MP4 - Perfect if you’re using AAC audio encoding.
3. Dynamic File Paths:
Feel free to use templates like {room_name} and {time} to keep your recordings nicely organized in your S3 bucket.
If you have any questions or want me to walk you through anything else, just let me know—I’m here to help!polite-dog-12152
09/02/2025, 3:44 PMtall-airline-16756
09/02/2025, 3:45 PMpolite-dog-12152
09/02/2025, 3:46 PMtall-airline-16756
09/02/2025, 3:46 PMpolite-dog-12152
09/04/2025, 8:39 AMtall-airline-16756
09/04/2025, 8:40 AMSpeechData.confidence field inside the SpeechEvent object. This score goes from 0.0 to 1.0 and basically shows how sure the model is about the transcription.
Here’s a quick example:
async def on_transcript(event: SpeechEvent):\n if event.alternatives:\n text = event.alternatives[0].text\n confidence = event.alternatives[0].confidence\n print(f\"Transcript: {text}, Confidence: {confidence}\")
This works smoothly with supported STT plugins like AWS, Google, Deepgram, and AssemblyAI. If you want me to walk you through a specific example or need any more help, just let me know—I’m here for you!
Sources: livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram/stt.py | AssemblyAI integration guide | LiveKit Docspolite-dog-12152
09/04/2025, 8:52 AMtall-airline-16756
09/04/2025, 8:53 AMSpeechData object is always set to 0 because the OpenAI API doesn’t send that info back.
If having confidence scores is important for you, you might want to check out other STT providers like AWS, Google, or AssemblyAI—they include confidence data in their transcriptions. And hey, if you want a hand switching providers or figuring out a workaround, I’m here to help!
Sources: plugins/openai/src/stt.ts | livekit-plugins/livekit-plugins-assemblyai/livekit/plugins/assemblyai/stt.p...polite-dog-12152
09/04/2025, 8:54 AMtall-airline-16756
09/04/2025, 8:54 AMdef calculate_confidence(transcription, reference):
transcription_words = transcription.split()
reference_words = reference.split()
matches = sum(1 for t, r in zip(transcription_words, reference_words) if t == r)
return matches / max(len(reference_words), 1)
This will give you a confidence score based on how many words match the reference.
2. Language Model Probability:
If you have access to a language model, you can figure out how likely the transcription is correct and scale that to a 0-1 confidence score.
3. Length and Completeness:
Another approach is to look at the length of the transcription and check for expected keywords to get an idea of confidence.
Feel free to reach out if you want a hand with implementing a specific formula or plugging it into your workflow—I’m here to help!polite-dog-12152
09/07/2025, 8:44 AMtall-airline-16756
09/07/2025, 8:45 AMpolite-dog-12152
09/07/2025, 8:46 AMpolite-dog-12152
09/07/2025, 9:00 AM