blob: 6eb8c3d932d10cb5ae74831d16b8ecab175c8dc3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
---
title: SpeechRecognitionAlternative.transcript
slug: Web/API/SpeechRecognitionAlternative/transcript
tags:
- API
- Experimental
- Property
- Reference
- SpeechRecognitionAlternative
- Web Speech API
- recognition
- speech
- transcript
translation_of: Web/API/SpeechRecognitionAlternative/transcript
---
<p>{{APIRef("Web Speech API")}}{{ SeeCompatTable() }}</p>
<p>{{domxref("SpeechRecognitionResult")}} インターフェースの <code><strong>transcript</strong></code> 読み取り専用プロパティは、認識したワードの記録を含む文字列を返します。</p>
<p>連続認識において、連続した {{domxref("SpeechRecognitionResult")}} の連結がセッションの適切な記録を生成するように、必要に応じて先頭または末尾の空白が含まれます。</p>
<h2 id="構文">構文</h2>
<pre class="syntaxbox">var myTranscript = speechRecognitionAlternativeInstance.transcript;</pre>
<h3 id="戻り値">戻り値</h3>
<p>{{domxref("DOMString")}}。</p>
<h2 id="例">例</h2>
<p>このコードは、<a href="https://github.com/mdn/web-speech-api/blob/master/speech-color-changer/script.js">Speech color changer</a> から抜き出しています。</p>
<pre class="brush: js">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;
}</pre>
<h2 id="仕様">仕様</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">仕様</th>
<th scope="col">ステータス</th>
<th scope="col">コメント</th>
</tr>
<tr>
<td>{{SpecName('Web Speech API', '#dfn-transcript', 'transcript')}}</td>
<td>{{Spec2('Web Speech API')}}</td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="ブラウザー実装状況">ブラウザー実装状況</h2>
<p>{{Compat("api.SpeechRecognitionAlternative.transcript")}}</p>
<ul>
<li>[1] Chrome では、SpeechRecognitionare インターフェースにプレフィックスが必要です。そのため、インターフェース名に <code>webkitSpeechRecognition</code> のようなプレフィックスが必要です; また、認識を動作させるには、Web サーバ上から提供する必要があります。</li>
<li>[2] <a>about:config</a> の <code>media.webspeech.recognition.enable</code> フラグで有効にできますが、現在の音声認識はデスクトップ版の Firefox では機能しません - 必要な内部権限が整理されればすぐに適切に公開されます。</li>
</ul>
<h3 id="Firefox_OS_許可">Firefox OS 許可</h3>
<p>アプリで音声認識を使用するには、<a href="/ja/docs/Web/Apps/Build/Manifest">manifest</a> で次の許可が必要です:</p>
<pre class="brush: json">"permissions": {
"audio-capture" : {
"description" : "Audio capture"
},
"speech-recognition" : {
"description" : "Speech recognition"
}
}</pre>
<p>特権アプリも必要なため、次のものも含める必要があります。</p>
<pre class="brush: json"> "type": "privileged"</pre>
<h2 id="関連項目">関連項目</h2>
<ul>
<li><a href="/ja/docs/Web/API/Web_Speech_API">Web Speech API</a></li>
</ul>
|