useTrackTranscription(voiceAssistant.audioTrack) n...
# ask-ai
b
useTrackTranscription(voiceAssistant.audioTrack) not work
t
Thanks for reaching out, RikuKomiya. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Just a quick heads-up: the
useTrackTranscription
function is now deprecated. We recommend switching over to
useTranscriptions
instead when you're grabbing transcription segments. It’s a bit more flexible and lets you filter by participant or track SID, which can be super handy. If you’re sticking with
useTrackTranscription
for now, here are a few things to double-check: • Make sure the
trackRef
parameter is correctly pointing to the audio track you want to transcribe. • The audio track should be actively published and processed by a Speech-to-Text (STT) agent. • Transcription events need to be firing and handled properly in your room setup. If you’re not seeing any transcriptions, it’s worth verifying that the audio track is valid and transcription is enabled for your room. Feel free to reach out if you want a hand or need more info on moving over to `useTranscriptions`—I’m here to help! Sources: src/hooks.ts | packages/react/src/hooks/useTranscriptions.ts | src/components/playground/Playground.tsx | livekit-agents/livekit/agents/voice/room_io/_output.py | hooks/use-transcriber.ts
b
the way to use useTranscriptions like this useTrackTranscription(voiceAssistant.audioTrack)
t
If you want to use
useTranscriptions
in a way that’s similar to
useTrackTranscription(voiceAssistant.audioTrack)
, you can simply filter the transcriptions by the specific track SID of
voiceAssistant.audioTrack
. Here’s a quick example to help you out:
Copy code
import { useTranscriptions } from '@livekit/components-react';

const transcriptions = useTranscriptions({
  trackSids: [voiceAssistant.audioTrack.sid],
});

return (
  <div>
    {transcriptions.map((transcription) => (
      <p key={transcription.streamInfo.sid}>{transcription.text}</p>
    ))}
  </div>
);
This way, you’ll get transcriptions only for that specific audio track. If anything’s unclear or you want me to walk you through it, just let me know—I’m here to help! Sources: packages/react/src/hooks/useTrackTranscription.ts | hooks/useChatAndTranscription.ts | complex-agents/turn-taking/turn-taking-frontend/hooks/useCombinedTranscript... | Transcriptions | LiveKit Docs
b
プロパティ 'sid' は型 'TrackReference' に存在しません。ts(2339)
t
To get the track SID from a
TrackReference
, you just need to use the
publication.trackSid
property. Here’s a quick example:
Copy code
const trackSid = voiceAssistant.audioTrack.publication.trackSid;
If you’re running into a TypeScript error, double-check that
voiceAssistant.audioTrack
is a valid
TrackReference
object and that the
publication
property is properly set. Feel free to reach out if you want me to help you troubleshoot further! Sources: Sources/LiveKit/Types/Track+Types.swift | Runtime/Scripts/Proto/Track.cs | Runtime/Scripts/Room/Track/Track.cs | Rooms, participants, and tracks | LiveKit Docs | packages/core/src/utilis.test.ts
b
lk.transcrpitonにおいて、reader.infoのlk.segment_idとlk.transcribed_track_idの違いは?
t
lk.segment_id
と
lk.transcribed_track_id
の違いについて、わかりやすくご説明しますね: •
lk.segment_id
: これは1つの発話やメッセージを表すユニークなIDです。同じ発話に対する途中の更新(例えば、ユーザーが話している途中のリアルタイム文字起こし)をまとめるために使われます。発話が終わるまで、ずっと同じ
segment_id
が使われますよ。 •
lk.transcribed_track_id
: こちらは文字起こしが作られた音声トラック(例えばマイクの音声)のIDです。これを使うと、どの参加者やトラックからの文字起こしかがわかります。 例えば、こんな感じです:
Copy code
{ "lk.segment_id": "SG_abc123", "text": "Hello" }
{ "lk.segment_id": "SG_abc123", "text": "Hello world!" }
この例では、`lk.segment_id` が同じなので、同じ発話の途中経過なんだなとわかりますよね。一方で、`lk.transcribed_track_id` を見ると、どの参加者の音声トラックからの文字起こしかが特定できます。 この2つの情報を組み合わせると、リアルタイムの文字起こしをしっかり管理して、参加者ごとにちゃんと表示できるんです。もしもっと詳しく知りたいことがあれば、いつでも気軽に教えてくださいね! Sources: app/src/main/java/io/livekit/android/example/voiceassistant/datastreams/Rem... | VoiceAgent/Chat/Receive/TranscriptionStreamReceiver.swift | hooks/useDataStreamTranscriptions.ts | packages/react/src/hooks/useTranscriptions.ts | lib/src/proto/livekit_models.pb.dart