average-account-59618
07/10/2025, 2:18 PM@function_tool()
async def disposition_dnc(self, context: RunContext):
"""
Use when customer requests no further contact OR displays aggressive/inappropriate behavior.
Explicit opt-out examples:
- "Don't ever call me again"
- "Put me on your Do Not Call list"
- "Stop calling me"
- "Remove my number"
Behavioral triggers:
- Aggressive, rude, or profane language
- Harassment, threats, or angry tone
- Yelling, mocking, or clearly annoyed behavior
- Accusations like "You're harassing me" or "This is spam"
"""
logger.info("Inside disposition_dnc")
try:
if self.session:
speech_handle = await context.session.say(
"Thank you for your time. Goodbye.",
add_to_chat_ctx=True
)
await speech_handle.wait_for_playout()
speech_handle.done()
logger.info("Disposition: DO NOT CALL (DNC)")
if self.end_call_handler:
await self.end_call_handler._handle_hangup(disposition="DNC")
return "DNC disposition applied"
except Exception as e:
# It's good practice to log the traceback for better debugging
logger.error(f"Error in disposition_dnc: {e}", exc_info=True)
return f"Error applying DNC disposition: {str(e)}"
tall-airline-16756
07/10/2025, 2:18 PMtall-airline-16756
07/10/2025, 2:21 PMrequest_id
and segment_id
are properly managed across all audio events, and that the total number of segments reflects the sentence count.
• Enable debugging: Set the LK_DUMP_TTS
environment variable to output audio frames generated by LiveKit and examine them for completeness.
• Streaming support: If your TTS does not support streaming, ensure it is wrapped with a StreamAdapter, using sentence tokenization to incrementally synthesize and deliver audio segments to LiveKit.
This approach should help your custom TTS synthesize and play the entire intended message.
Sources: livekit-plugins/livekit-plugins-playai/livekit/plugins/playai/tts.py