How to get call recordings and call transcriptions...
# ask-ai
d
How to get call recordings and call transcriptions from telephony ?
t
Thanks for reaching out, Ibragim. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To obtain call recordings and transcriptions from telephony sessions in LiveKit, follow these steps: Call Recordings 1. Manual Recording Setup:
Copy code
from livekit import api

async def entrypoint(ctx: JobContext):
    req = api.RoomCompositeEgressRequest(
        room_name=ctx.room.name,
        audio_only=True,
        file_outputs=[api.EncodedFileOutput(
            file_type=api.EncodedFileType.OGG,
            filepath="livekit/my-room-test.ogg",
            s3=api.S3Upload(
                bucket="<s3 bucket name>",
                region="<s3 region>",
                access_key="<s3 access key>",
                secret="<s3 secret key>",
            ),
        )],
    )

    lkapi = api.LiveKitAPI()
    res = await lkapi.egress.start_room_composite_egress(req)
    await lkapi.aclose()
◦ Use LiveKit's Egress API to programmatically start recording. ◦ Example code snippet: 1. Auto-Egress with SIP: ◦ Enable automatic recording by configuring
room_config.egress
in SIP dispatch rules. ◦ This will automatically start recording based on the egress configuration. 1. Storage Requirements: ◦ Recordings are stored in your chosen cloud storage provider (e.g., Google Cloud Storage, Amazon S3, Azure Blob Storage). Call Transcriptions 1. Real-time Transcript Access: Example:
Copy code
from datetime import datetime
import json

async def entrypoint(ctx: JobContext):
    def save_transcript():
        timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
        filename = f"transcript_{timestamp}.json"

        with open(filename, 'w') as f:
            json.dump(session.history, f, indent=2)

    ctx.add_shutdown_callback(save_transcript)
◦ Access the
session.history
property to retrieve the entire conversation history. ◦ Use the
add_shutdown_callback
method to save the conversation history to a file after the session ends. 1. Event-Based Transcript Capture: ◦ Listen for events like
conversation_item_added
and
user_input_transcribed
for real-time updates. 1. Pipeline Node Access: ◦ Use
llm_node
or
transcription_node
for real-time transcription access. Backend API Integration • When phone calls are routed through SIP into LiveKit rooms, the backend API provides access to transcriptions, recordings, and other features. Notes: • Ensure proper storage configuration for recording files. • Recording starts when the agent enters the room and ends when all participants leave. This setup allows for both automated and programmatic control over recordings and transcriptions.
d
[ERROR] Failed to start audio recording: TwirpError(code=invalid_argument, message=request has missing or invalid field: output, status=400) What is this error?
t
Hey there! 👋 Looks like you're running into a tricky little error with your audio recording request. Don't worry – we'll sort this out together! The TwirpError(code=invalid_argument, message=request has missing or invalid field: output, status=400) basically means something's not quite right with how you're telling the system where to save or send your recording. Let's troubleshoot the common culprits: 1. Missing Output Configuration: - Think of this like telling a friend where to drop off a package. You need to specify exactly where you want your recording to go: - Saving to a cloud storage spot like S3 or Google Cloud - Streaming to a live endpoint - Creating segmented files - Sending via WebSocket 2. Invalid Output Format: - Sometimes the destination is there, but the directions are a bit fuzzy. Double-check that all the details are crystal clear. Here's a friendly example of getting it right:
Copy code
const fileOutput = new EncodedFileOutput({
  filepath: `recording-${roomName}.mp4`,
  output: {
    case: 's3',
    value: new S3Upload({
      endpoint: S3_ENDPOINT,
      accessKey: S3_KEY_ID,
      secret: S3_KEY_SECRET,
      region: S3_REGION,
      bucket: S3_BUCKET,
    }),
  },
});
The key is making sure your request has a clear, complete roadmap for where that recording should end up. Think of it like giving precise directions to a friend – the more specific, the better! 😊 Need any help walking through this? I'm right here to help you get it sorted! 🤝 Sources: errors.go | app/api/record/start/route.ts | pkg/errors/errors.go
d
[ERROR] Failed to start audio recording: Expected a field name, but got oneof name output.
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!