SpeechRecognitionResult
インターフェースの transcript
読み取り専用プロパティは、認識したワードの記録を含む文字列を返します。
連続認識において、連続した SpeechRecognitionResult
の連結がセッションの適切な記録を生成するように、必要に応じて先頭または末尾の空白が含まれます。
構文
var myTranscript = speechRecognitionAlternativeInstance.transcript;
戻り値
例
このコードは、Speech color changer から抜き出しています。
recognition.onresult = function(event) {
// The SpeechRecognitionEvent results property returns a SpeechRecognitionResultList object
// The SpeechRecognitionResultList object contains SpeechRecognitionResult objects.
// It has a getter so it can be accessed like an array
// The first [0] returns the SpeechRecognitionResult at position 0.
// Each SpeechRecognitionResult object contains SpeechRecognitionAlternative objects that contain individual results.
// These also have getters so they can be accessed like arrays.
// The second [0] returns the SpeechRecognitionAlternative at position 0.
// We then return the transcript property of the SpeechRecognitionAlternative object
var color = event.results[0][0].transcript;
diagnostic.textContent = 'Result received: ' + color + '.';
bg.style.backgroundColor = color;
}
仕様
仕様 | ステータス | コメント |
---|---|---|
Web Speech API transcript の定義 |
ドラフト |
ブラウザー実装状況
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
- [1] Chrome では、SpeechRecognitionare インターフェースにプレフィックスが必要です。そのため、インターフェース名に
webkitSpeechRecognition
のようなプレフィックスが必要です; また、認識を動作させるには、Web サーバ上から提供する必要があります。 - [2] about:config の
media.webspeech.recognition.enable
フラグで有効にできますが、現在の音声認識はデスクトップ版の Firefox では機能しません - 必要な内部権限が整理されればすぐに適切に公開されます。
Firefox OS 許可
アプリで音声認識を使用するには、manifest で次の許可が必要です:
"permissions": {
"audio-capture" : {
"description" : "Audio capture"
},
"speech-recognition" : {
"description" : "Speech recognition"
}
}
特権アプリも必要なため、次のものも含める必要があります。
"type": "privileged"