Hi There, I am using Livekit with my personal TTS ...
# ask-ai
a
Hi There, I am using Livekit with my personal TTS Fined Tuned on english voice. I am trying to Play a sentence when calling a Tool. But the Problem is it only speaks one first sentence and misses next. But when using open AI TTS it speaks complete. What could be the possible issue?
Copy code
@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)}"
t
Thanks for reaching out, Ali. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
When using a custom fine-tuned TTS, only the first sentence playing (while OpenAI TTS plays all) is often caused by incomplete or incorrect handling of audio segmentation and finalization in your TTS integration. LiveKit expects segmented, incremental audio output when streaming TTS is used, while OpenAI TTS processes whole utterances at once. To troubleshoot and resolve this issue with your custom TTS, follow these steps: • Validate audio frame output: Ensure that all but the last audio event are marked non-final, and that the last is marked final. Each audio frame should be 0.05–0.25 seconds, and the last frame must not be empty. • Check segment handling: Confirm that
request_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