client-sdk-react-native icon indicating copy to clipboard operation
client-sdk-react-native copied to clipboard

useTrackTranscription equivalent for react native?

Open kotani123 opened this issue 1 year ago • 6 comments

I wanted to know if there was a useTrackTranscription equivalent for the react native package. The agent-playground uses this to display the chat messages for both the user and the agent.

I wanted to know if there was a built in way of achieving the same thing in a react-native app.

kotani123 avatar Jul 11 '24 15:07 kotani123

I think it might be fine to use the components-react hook? Can't test at the moment, but it's worth trying it out yourself. If it works, I'll add it to our list of exports.

davidliu avatar Jul 11 '24 16:07 davidliu

Thank you so much! I will try it out!

kotani123 avatar Jul 19 '24 04:07 kotani123

is this pertaining to closed captions / subtitles?

goatandsheep avatar Jul 21 '24 23:07 goatandsheep

the @livekit/react-native doesn't export the necessary useTrackTranscription hook. you need to add @livekit/components-react to your react native project and import it from there. once imported, you can use it like in the following:

  const { isMicrophoneEnabled, localParticipant, microphoneTrack } = useLocalParticipant();

  const localMessages = useTrackTranscription({
    publication: microphoneTrack,
    source: Track.Source.Microphone,
    participant: localParticipant,
  });

here is an example from the playground's source code.

tarikozket avatar Jan 21 '25 20:01 tarikozket

@tarikozket hey, can you confirm if this works for you? I never got around to testing this myself, but if it works, I can add it to this library's export list (not all of the component-react hooks work, so we re-export to keep a confirmed list of working hooks).

davidliu avatar Jan 22 '25 07:01 davidliu

yup, it does 👍

tarikozket avatar Jan 22 '25 07:01 tarikozket