Anyone seen issues dealing with numbers from STT a...
# agents
b
Anyone seen issues dealing with numbers from STT and the LLM? I am working with a livekit agent using deepgram for TTS and STT. I am using Anthropics claude sonnet 4 for the LLM. The problem I am having is when people are reading authorization numbers to the agent. The agent is having a hard time passing in these numbers to the tools. Example: User states Authorization Number 90454296. Deepgram STT logs: nine zero four five four two nine six. LLM then passes in 904542296 to the authorization tool. This is a critical process. I have noticed that deepgram has Transcription features. One being setting Smart Format = true. This sometimes has deepgram return a number instead of the words for each number, but it is inconsistent. How can I get around this issue?
r
To address the issue you're experiencing with Deepgram's STT and the LLM when processing authorization numbers, there are a few strategies you can consider: 1. Smart Formatting: As you mentioned, Deepgram has a feature called "Smart Formatting" that can help with the transcription of numbers. When enabled, this feature attempts to return numbers in their numeric form rather than spelling them out. You can enable this feature in your Deepgram STT configuration. Ensure that you set
smart_format
to
true
when initializing the STT instance. Here’s an example of how to do this in Python:
Copy code
stt = deepgram.STT(smart_format=True)
This should help improve the consistency of how numbers are transcribed from speech to text. 2. Post-Processing: If Smart Formatting does not yield consistent results, you might need to implement a post-processing step after receiving the transcription from Deepgram. You can use regular expressions to identify patterns that match the expected format of authorization numbers and convert them back to their numeric form. For example:
Copy code
import re

   def convert_to_number(transcription):
       # Example regex to match the pattern of numbers spelled out
       pattern = r"(?:(nine|zero|one|two|three|four|five|six|seven|eight|nine)\s*)+"
       matches = re.findall(pattern, transcription)
       # Convert matches to numeric form
       for match in matches:
           # Implement conversion logic here
           pass
       return transcription  # Return modified transcription
3. LLM Configuration: Ensure that the LLM (Anthropic's Claude Sonnet 4 in your case) is configured to handle numeric inputs effectively. You might need to provide it with specific instructions or context to treat certain phrases as numbers rather than text. This can be done by including examples in the prompt that clarify how to interpret authorization numbers. 4. Testing and Iteration: Since this is a critical process, it’s essential to test various configurations and approaches. Monitor the performance of the STT and LLM in different scenarios to identify what works best for your use case. By combining these strategies, you should be able to improve the handling of authorization numbers in your LiveKit agent using Deepgram for STT and TTS. Notes: • Make sure to check the Deepgram documentation for the latest features and best practices regarding Smart Formatting. • The regex pattern provided is a simple example; you may need to adjust it based on the specific formats of authorization numbers you expect to encounter. • Consider logging the outputs at each stage to help diagnose any further issues with the transcription and processing pipeline.
b
Did you paste my question into an LLM? Your response is almost verbatim what Grok responded with :)
r
🙂 I have an LLM trained on our source code I use.
But the answer looks generally correct to me
In case you don't know there is also this deepwiki repo I maintain that is trained on our public repo and docs: https://deepwiki.com/livekit/livekit_composite And #ask-ai is a resource too
DeepWikis response:
b
nice