React Api Reference
    Preparing search index...

    Class useTranscription

    useTranscription provides reactive APIs and events to manage real-time transcription and receive transcribed text within a meeting.

    Index

    Constructors

    Methods

    • Parameters

      • config: {
            modelConfig?: object;
            summary?: { enabled: boolean; prompt?: string };
            webhookUrl?: string;
        }
        • OptionalmodelConfig?: object

          Optional model configuration used during transcription.

        • Optionalsummary?: { enabled: boolean; prompt?: string }

          Configuration for real-time transcription summary generation.

          • enabled: boolean

            Enables or disables summary generation.

          • Optionalprompt?: string

            Custom instructions used to guide summary generation.

        • OptionalwebhookUrl?: string

          A webhook URL that will be called whenever the transcription state changes.

      Returns void

      const { startTranscription } = useTranscription();

      const run = async () => {
      await startTranscription({
      webhookUrl: "https://www.example.com",
      summary: {
      enabled: true,
      prompt: "Write summary in sections.",
      },
      });
      };

      run();
    • Returns void

      const { stopTranscription } = useTranscription();

      const run = async () => {
      await stopTranscription();
      };

      run();

    Events

      • Triggered when the state of realtime transcription changes.

      Parameters

      • data: { id: string; status: string }
        • id: string

          ID of the transcription session.

        • status: string

          status has following values:

          • TRANSCRIPTION_STARTING - Realtime Transcription is in starting phase and hasn't started yet.
          • TRANSCRIPTION_STARTED - Realtime Transcription has started successfully.
          • TRANSCRIPTION_STOPPING - Realtime Transcription is in stopping phase and hasn't stopped yet.
          • TRANSCRIPTION_STOPPED - Realtime Transcription has stopped successfully.

      Returns void

      import { Constants, useTranscription } from "@videosdk.live/react-sdk";

      function onTranscriptionStateChanged(data) {
      const { status, id } = data;

      if (status === Constants.transcriptionEvents.TRANSCRIPTION_STARTING) {
      console.log("Realtime transcription is starting", id);
      } else if (status === Constants.transcriptionEvents.TRANSCRIPTION_STARTED) {
      console.log("Realtime transcription has started", id);
      } else if (status === Constants.transcriptionEvents.TRANSCRIPTION_STOPPING) {
      console.log("Realtime transcription is stopping", id);
      } else if (status === Constants.transcriptionEvents.TRANSCRIPTION_STOPPED) {
      console.log("Realtime transcription has stopped", id);
      }
      }

      useTranscription({
      onTranscriptionStateChanged,
      });
      • Triggered when realtime transcription text is received.

      Parameters

      • data: {
            participantId: string;
            participantName: string;
            text: string;
            timestamp: number;
            type: string;
        }
        • participantId: string

          ID of the participant whose speech was transcribed.

        • participantName: string

          Name of the participant whose speech was transcribed.

        • text: string

          Transcribed text content.

        • timestamp: number

          Timestamp (in milliseconds since epoch) when the transcription was generated.

        • type: string

          Type of transcription event.

      Returns void

      import { useTranscription } from "@videosdk.live/react-sdk";

      function onTranscriptionText(data) {
      const { participantId, participantName, text, timestamp } = data;
      console.log(`${participantName}: ${text} (${timestamp})`);
      }

      useTranscription({
      onTranscriptionText,
      });