m
Hi
t
Thanks for reaching out, Rahib. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'd love to help you out! Could you please share a bit more about what you're experiencing or what you need? That way, I can make sure to assist you in the best possible way.
m
Hey so for some reason Cartesian stt is getting user input wrong most of the time.
t
I'm here to help you improve the accuracy issues with Cartesian STT. Let's take a look at a few important points together: • Model Selection: It’s really important to make sure the correct language code is set during initialization. Using the wrong or unsupported language can definitely impact accuracy. • Audio Input Settings: Double-check that your audio encoding is PCM S16LE and the sample rate is 16000 Hz. When these settings don’t match, it can affect how well the transcription works. • Stream Configuration: If you’re updating models or languages on the fly during streams, please ensure those updates are applied properly. • Integration Context: It might be helpful to test with other STT providers integrated with LiveKit to see how their accuracy compares. • Agent Session Behavior: Take a look at the endpointing delays in your
AgentSession
configuration, making sure they’re tuned to fit your specific use case. Also, don’t forget to check the quality of your input audio and confirm proper silence trimming is in place. If you’re still facing issues after trying these steps, please reach out—I’m here to help you troubleshoot further and find the best solution. Sources: Live Conversations with AI using ChatGPT and WebRTC | Live Conversations with AI using ChatGPT and WebRTC | Cartesia STT | LiveKit Docs | livekit-agents/livekit/agents/voice/audio_recognition.py | Live Conversations with AI using ChatGPT and WebRTC
m
What is the new inference model?
t
I'm happy to share that the new inference model for Cartesian STT is Ink Whisper, with the model ID
cartesia/ink-whisper
. To use this model, you can simply specify it along with the language in the
stt
argument of an
AgentSession
. For example:
stt: 'cartesia/ink-whisper:en'
. If you need any help setting this up, feel free to ask! Sources: Cartesia STT | LiveKit Docs | agents/src/inference/stt.ts
m
Is Cartesian better or assembly ai ?
t
When it comes to comparing Cartesian STT and AssemblyAI, it really depends on what you’re looking for: • Accuracy: While there aren’t direct benchmarks available, both providers are known to be reliable. A great way to see how they perform for you is by using LiveKit's metrics system to check accuracy and latency in your own environment. • Real-Time Responsiveness: Cartesian offers interim results, which can give you quicker feedback during speech, whereas AssemblyAI focuses more on complete segments. • Language Support: Cartesian supports a wider range of languages, while AssemblyAI currently supports only English. • Pricing: AssemblyAI is a bit more affordable at $0.150 per hour, compared to Cartesian’s $0.180 per hour. If you like, I’d be happy to walk you through setting up a side-by-side evaluation using LiveKit’s metrics system so you can see firsthand how they perform in your application. Just let me know! Sources: metrics/metrics_stt.py | livekit-plugins/livekit-plugins-assemblyai/livekit/plugins/assemblyai/stt.p... | AssemblyAI plugin guide | LiveKit Docs | AssemblyAI STT | LiveKit Docs | How does end-of-utterance detection work in conversations?
m
When collecting info using AgentTask what should be the instructions if I want to collect some information in an order? Where after getting user input agent should validate character by character as well
t
I'd love to help you with this! Could you please share a bit more about the type of information you're looking to collect and how you'd like the character-by-character validation to work? For instance, are you aiming to validate against a specific format or certain criteria? Your details will really help me guide you better.
m
So I want to collect name email phone company name and ask if they are a proxy caller
t
I'd be happy to help you collect the name, email, phone, company name, and proxy caller status in order using
AgentTask
. You can create a custom task that gently guides you through each input step-by-step. Here's a simple outline to get you started: • Sequential Collection: We can use methods like
_ask_name()
,
_ask_email()
, and so on, to prompt for each piece of information one at a time. • Validation: At each step, we'll make sure the input is valid—for example, checking the email format with regex and confirming the phone number is numeric and exactly 10 digits. • State Management: We'll keep track of all the collected data in a dictionary, so nothing gets missed and you know exactly where you are in the process. • Completion: Once everything looks good and all fields are filled, we'll return the data neatly packaged as a structured result. If you'd like, I can walk you through a detailed Python implementation for this task. Just let me know, and I'll be here to assist you every step of the way! Sources: Workflows | LiveKit Docs | complex-agents/nova-sonic/form_agent.py | examples/voice_agents/restaurant_agent.py
m
Can you give me complete examples of this AgentTask
t
I'm happy to share a complete Python implementation of an
AgentTask
that gently guides you through collecting your name, email, phone, company name, and proxy caller status, validating each step along the way:
Copy code
from dataclasses import dataclass
from typing import Optional
import re
from livekit.agents.voice import AgentTask
from livekit.agents.llm import function_tool
from livekit.agents.voice.events import RunContext

@dataclass
class ContactInfoResult:
    name: str
    email: str
    phone: str
    company: str
    is_proxy: bool

def proper_capitalize(text: str) -> str:
    minor_words = {'of', 'in', 'at', 'and', 'or', 'the', 'a', 'an', 'for', 'with', 'on'}
    words = text.split()
    return ' '.join(
        word.capitalize() if i == 0 or word.lower() not in minor_words else word.lower()
        for i, word in enumerate(words)
    )

class CollectContactInfoTask(AgentTask[ContactInfoResult]):
    def __init__(self):
        super().__init__(
            instructions="Collect user information step by step: name, email, phone, company, and proxy status."
        )
        self.collected_data = {}

    async def on_enter(self):
        await self._ask_name()

    async def _ask_name(self):
        self.session.generate_reply("Hello! Could you please tell me your full name?")

    @function_tool
    async def provide_name(self, name: str):
        if not name or len(name.strip()) < 2:
            self.session.generate_reply("Please provide a valid name.")
            return
        self.collected_data["name"] = proper_capitalize(name.strip())
        await self._ask_email()

    async def _ask_email(self):
        self.session.generate_reply("Thank you. Now, please provide your email address.")

    @function_tool
    async def provide_email(self, email: str):
        EMAIL_REGEX = r"^[A-Za-z0-9][A-Za-z0-9._%+-]*@(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z]{2,}$"
        if not re.match(EMAIL_REGEX, email):
            self.session.generate_reply("That email seems invalid. Please try again.")
            return
        self.collected_data["email"] = email
        await self._ask_phone()

    async def _ask_phone(self):
        self.session.generate_reply("Now, please tell me your phone number.")

    @function_tool
    async def provide_phone(self, phone: str):
        cleaned = re.sub(r'[\s\-\(\)\.\+\s]', '', phone)
        if not cleaned.isdigit() or len(cleaned) < 10:
            self.session.generate_reply("Please provide a valid 10-digit phone number.")
            return
        self.collected_data["phone"] = phone
        await self._ask_company()

    async def _ask_company(self):
        self.session.generate_reply("What company do you represent?")

    @function_tool
    async def provide_company(self, company: str):
        if not company or len(company.strip()) < 2:
            self.session.generate_reply("Please provide a valid company name.")
            return
        self.collected_data["company"] = proper_capitalize(company.strip())
        await self._ask_proxy_status()

    async def _ask_proxy_status(self):
        self.session.generate_reply(
            "Are you calling on behalf of someone else? Please say yes or no."
        )

    @function_tool
    async def provide_proxy_status(self, is_proxy: bool):
        self.collected_data["is_proxy"] = is_proxy
        result = ContactInfoResult(**self.collected_data)
        self.complete(result)
Usage: When you're ready to use this task in an agent session, you can do the following:
Copy code
task = CollectContactInfoTask()
result = await task  # This will return a ContactInfoResult once everything is complete
print(result.name, result.email, result.phone, result.company, result.is_proxy)
If you have any questions or would like me to help adjust this for your needs, just let me know—I'm here to help!
m
Does this task handles user provided updates ? If agent got something wrong?
t
Absolutely! The task can definitely handle updates from users if the agent makes a mistake. Here’s how you can manage corrections smoothly: • Function Tools: You can use specific tools like
update_name
,
update_email_address
, or
update_phone
to process and validate any corrections. • Context Updates: It’s helpful to dynamically adjust the conversation context with
update_chat_ctx()
so the corrected info is properly reflected. • Verbal Confirmation: Don’t forget to acknowledge the update to the user using
session.generate_reply()
or `session.say()`—this really helps them feel heard. • Validation: Make sure to validate corrections (like checking email format or phone number length) before moving forward. If you’d like, I’d be more than happy to assist you in integrating these features into your task or guide you through implementing corrections for any specific fields. Just let me know! Sources: Agents v0.x migration guide - Node.js | LiveKit Docs | Agents v0.x migration guide - Python | LiveKit Docs | External data and RAG | LiveKit Docs | livekit-agents/livekit/agents/voice/agent.py | examples/src/restaurant_agent.ts
m
Can you build this complete agent?
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!
m
How can we achieve that?