Can you please help me to get the transcript and ...
# ask-ai
b
Can you please help me to get the transcript and timestamp? I had tried TimeString but it is able to import any otherway?
t
Thanks for reaching out, Yethu. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I can help with that. Quick clarification so I point you to the right solution: • Are you using Python or Node.js/TypeScript? • Do you need timestamps for the agent's TTS, the user's speech, or both? • Which TTS provider are you using (Cartesia, ElevenLabs, LiveKit Inference, or other)? If you’re on Python, I can show how to use the `TimedText`/`TimeString` output to get `start_time`/`end_time`. If you’re on Node.js,
TimedString
isn’t available — I can show alternatives (using
speech_created
+
audio_duration
or TTS metrics) once you confirm your setup. Sources: Text and transcriptions | LiveKit docs | Observability data hooks | LiveKit docs
b
I am using Python, and my models are from livekit inference STT and TTS models. My goal is, I want the transcript with accurate timestamp
t
Thanks — you're using Python with LiveKit Inference for both STT and TTS and want accurate timestamps. Here's what you can do: 1. Enable TTS-aligned transcripts in your AgentSession:
Copy code
from livekit.agents import AgentSession

session = AgentSession(
    use_tts_aligned_transcript=True,
    # other config...
)
1. Read
TimedText
objects in your
transcription_node
to get timestamps:
Copy code
from livekit.agents import TimedText
from typing import AsyncIterable

class MyAgent(Agent):
    async def transcription_node(
        self,
        text: AsyncIterable[str | TimedText],
        model_settings,
        metadata,
    ) -> AsyncIterable[str | TimedText]:
        async for chunk in text:
            if isinstance(chunk, TimedText):
                print(f"Transcript: '{chunk.text}' Start: {chunk.start_time:.3f}s End: {chunk.end_time:.3f}s")
            else:
                print(f"Transcript (no timing): {chunk}")
            yield chunk
1. Important facts about available timestamps • Agent TTS (LiveKit Inference): provides sentence-level timestamps via
TimedText
(start/end per sentence). • Agent TTS (Cartesia or ElevenLabs): support word-level alignment (per-word start/end). • User STT (LiveKit Inference): does not provide timestamps;
user_input_transcribed
gives only the transcript string. 1. Options if you need finer timestamps for user speech or word-level TTS: • Use Cartesia or ElevenLabs for TTS to get word-level timing. • Use an STT provider that returns alignment data for user speech, or estimate timings from
speech_created
+
audio_duration
. Would you like a complete example script wiring session setup,
transcription_node
, and the
user_input_transcribed
handler?
b
which version required for TimedText, because I am not able to import it.
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!
b
Ok then give me the question that I can put it in the channel and also suggest me the channel also
hi