Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. SpeechRecognitionPhrase

SpeechRecognitionPhrase

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

TheSpeechRecognitionPhrase interface of theWeb Speech API represents a phrase that can be passed to the speech recognition engine forcontextual biasing.

Instance properties

SpeechRecognitionPhrase.boostRead onlyExperimental

A floating point number representing the amount of boost you want to apply to the correspondingphrase.

SpeechRecognitionPhrase.phraseRead onlyExperimental

A string containing the word or phrase you want boosted in the recognition engine's bias.

Examples

Basic usage

The following code first creates an array containing the phrases to boost and theirboost values. We convert this data into anObservableArray ofSpeechRecognitionPhrase objects by mapping the original array elements toSpeechRecognitionPhrase() constructor calls:

js
const phraseData = [  { phrase: "azure", boost: 5.0 },  { phrase: "khaki", boost: 3.0 },  { phrase: "tan", boost: 2.0 },];const phraseObjects = phraseData.map(  (p) => new SpeechRecognitionPhrase(p.phrase, p.boost),);

After creating aSpeechRecognition instance, we add our contextual biasing phrases by setting thephraseObjects array as the value of theSpeechRecognition.phrases property:

js
const recognition = new SpeechRecognition();recognition.continuous = false;recognition.lang = "en-US";recognition.interimResults = false;recognition.processLocally = true;recognition.phrases = phraseObjects;// …

This code is excerpted from ouron-device speech color changer (run the demo live). SeeUsing the Web Speech API for a full explanation.

Specifications

Specification
Web Speech API
# speechrecognitionphrase

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp