KeenASR React Native Plugin (v2.2)
    Preparing search index...

    Function createContextualDecodingGraphFromPhrases

    • Create a contextual decoding graph from multiple phrase groups.

      A contextual decoding graph contains multiple "contexts" (phrase sets) that can be switched at runtime without rebuilding the graph. This is useful for multi-page reading, multi-step workflows, or any scenario where the expected vocabulary changes dynamically.

      After creation, activate a specific context using prepareForListeningWithContextualDecodingGraph.

      Parameters

      • dgName: string

        Unique name for this graph. Must not contain the - (hyphen) character.

      • contextsPhrases: string[][]

        Array of phrase arrays, one per context. contextsPhrases[0] is context 0, contextsPhrases[1] is context 1, etc.

      • Optionaloptions: {
            task?: SpeakingTask;
            alternativePronunciations?: (
                | WordPronunciation
                | { word: string; pronunciation: string; tag?: string }
            )[];
            spokenNoiseProbability?: number;
        }

        Optional configuration (same as createDecodingGraphFromPhrases).

      Returns Promise<boolean>

      true if the graph was created successfully.

      await createContextualDecodingGraphFromPhrases('reading', [
      ['Alice was beginning to get very tired'], // page 0
      ['And what is the use of a book'], // page 1
      ['When suddenly a White Rabbit appeared'], // page 2
      ]);

      // Switch to page 1
      await prepareForListeningWithContextualDecodingGraph('reading', 1);