-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
SpeechUI.xml
154 lines (135 loc) · 7.71 KB
/
SpeechUI.xml
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<Type Name="SpeechUI" FullName="System.Speech.Recognition.SpeechUI">
<TypeSignature Language="C#" Value="public class SpeechUI" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit SpeechUI extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.Speech.Recognition.SpeechUI" />
<TypeSignature Language="VB.NET" Value="Public Class SpeechUI" />
<TypeSignature Language="F#" Value="type SpeechUI = class" />
<TypeSignature Language="C++ CLI" Value="public ref class SpeechUI" />
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Provides text and status information on recognition operations to be displayed in the Speech platform user interface.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The members of the <xref:System.Speech.Recognition.SpeechUI> class can be used to indicate exact feedback to the end user through the speech recognition user interface. An application can return arbitrary text and success/failure information using this class.
## Examples
The following example is a handler for the <xref:System.Speech.Recognition.Grammar.SpeechRecognized> event. This event is used by a <xref:System.Speech.Recognition.Grammar> that is designed to handle password input in the form "My password is …".
If a password is not present, or not valid, <xref:System.Speech.Recognition.SpeechUI.SendTextFeedback%2A> sends error information to the Speech platform user interface.
```
grammar.SpeechRecognized +=
delegate(object sender, SpeechRecognizedEventArgs eventArgs)
{
SemanticValue semantics = eventArgs.Result.Semantics;
RecognitionResult result=eventArgs.Result;
if (!semantics.ContainsKey("Password"))
{
SpeechUI.SendTextFeedback(eventArgs.Result, "No Password Provided", false);
}
else
{
RecognizedAudio pwdAudio = result.GetAudioForWordRange(
result.Words[3],
result.Words[result.Words.Count - 1]);
MemoryStream pwdMemoryStream = new MemoryStream();
pwdAudio.WriteToAudioStream(pwdMemoryStream);
if (!IsValidPwd(pwdMemoryStream))
{
string badPwd = System.IO.Path.GetTempPath() +
"BadPwd" + (new Random()).Next().ToString() + ".wav";
FileStream waveStream = new FileStream(badPwd, FileMode.Create);
pwdAudio.WriteToWaveStream(waveStream);
waveStream.Flush();
waveStream.Close();
SpeechUI.SendTextFeedback(eventArgs.Result, "Invalid Password", false);
}
}
};
```
]]></format>
</remarks>
</Docs>
<Members>
<Member MemberName="SendTextFeedback">
<MemberSignature Language="C#" Value="public static bool SendTextFeedback (System.Speech.Recognition.RecognitionResult result, string feedback, bool isSuccessfulAction);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig bool SendTextFeedback(class System.Speech.Recognition.RecognitionResult result, string feedback, bool isSuccessfulAction) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Speech.Recognition.SpeechUI.SendTextFeedback(System.Speech.Recognition.RecognitionResult,System.String,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function SendTextFeedback (result As RecognitionResult, feedback As String, isSuccessfulAction As Boolean) As Boolean" />
<MemberSignature Language="F#" Value="static member SendTextFeedback : System.Speech.Recognition.RecognitionResult * string * bool -> bool" Usage="System.Speech.Recognition.SpeechUI.SendTextFeedback (result, feedback, isSuccessfulAction)" />
<MemberSignature Language="C++ CLI" Value="public:
 static bool SendTextFeedback(System::Speech::Recognition::RecognitionResult ^ result, System::String ^ feedback, bool isSuccessfulAction);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="result" Type="System.Speech.Recognition.RecognitionResult" />
<Parameter Name="feedback" Type="System.String" />
<Parameter Name="isSuccessfulAction" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="result">A valid <see cref="T:System.Speech.Recognition.RecognitionResult" /> instance.</param>
<param name="feedback">A <see cref="T:System.String" /> containing a comment about the recognition operation that produced the <see cref="T:System.Speech.Recognition.RecognitionResult" /><paramref name="result" />.</param>
<param name="isSuccessfulAction">A <see langword="bool" /> indicating whether the application deemed the recognition operation a success.</param>
<summary>Sends status and descriptive text to the Speech platform user interface about the status of a recognition operation.</summary>
<returns>
<see langword="true" /> if the information provided to the method (<paramref name="Feedback" />, and <paramref name="isSuccessfulAction" />) was successfully made available to the Speech platform user interface, and <see langword="false" /> if the operation failed.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Speech.Recognition.SpeechUI.SendTextFeedback%2A> can be used to indicate that a recognition operation failed to meet certain criteria, even if the input was recognized.
An example is the verification of security code information, where the input was fully recognized, but the verification information was wrong.
## Examples
The following example is a handler for a <xref:System.Speech.Recognition.Grammar.SpeechRecognized> event. This event is used by a <xref:System.Speech.Recognition.Grammar> that is designed to handle password input of the form, "My password is …".
If a password is not present, or not valid, **SendTextFeedback** is used to send error information to the Speech platform user interface.
```
grammar.SpeechRecognized +=
delegate(object sender, SpeechRecognizedEventArgs eventArgs)
{
SemanticValue semantics = eventArgs.Result.Semantics;
RecognitionResult result=eventArgs.Result;
if (!semantics.ContainsKey("Password"))
{
SpeechUI.SendTextFeedback(eventArgs.Result, "No Password Provided", false);
}
else
{
RecognizedAudio pwdAudio = result.GetAudioForWordRange(
result.Words[3],
result.Words[result.Words.Count - 1]);
MemoryStream pwdMemoryStream = new MemoryStream();
pwdAudio.WriteToAudioStream(pwdMemoryStream);
if (!IsValidPwd(pwdMemoryStream))
{
string badPwd = System.IO.Path.GetTempPath() + "BadPwd" +
(new Random()).Next().ToString() + ".wav";
FileStream waveStream = new FileStream(badPwd, FileMode.Create);
pwdAudio.WriteToWaveStream(waveStream);
waveStream.Flush();
waveStream.Close();
SpeechUI.SendTextFeedback(eventArgs.Result, "Invalid Password", false);
}
}
};
```
]]></format>
</remarks>
</Docs>
</Member>
</Members>
</Type>