You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: xml/System.Speech.Recognition.SrgsGrammar/SrgsOneOf.xml
+3-6Lines changed: 3 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -89,10 +89,9 @@
89
89
## Examples
90
90
The following example uses the <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> element to build lists of <xref:System.Speech.Recognition.SrgsGrammar.SrgsItem> elements containing country/region names, any one of which may be used to recognize the containing phrase. The example then adds one of the resulting <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> objects to their respective rules for European and South American countries/regions. Further on, the example uses the <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> object to group rule references to `ruleEurope` and `ruleSAmerica` into a list of two alternatives, either one of which may be used to recognize spoken input.
91
91
92
-
```
92
+
```csharp
93
93
public void WorldSoccerWinners ()
94
94
{
95
-
96
95
// Create an SrgsDocument, create a new rule
97
96
// and set its scope to public.
98
97
SrgsDocument document = new SrgsDocument();
@@ -121,7 +120,6 @@ public void WorldSoccerWinners ()
@@ -236,7 +234,7 @@ public void WorldSoccerWinners ()
236
234
## Examples
237
235
The following example creates a grammar that recognizes the phrase "A nation that has won the World Cup is" followed by the name of a country/region that has won the World Cup. The example uses the <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> element to build lists of acceptable country/region names from an array of <xref:System.String> objects. The example then adds one of the resulting <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> objects to their respective rules for European and South American countries/regions.
238
236
239
-
```
237
+
```csharp
240
238
public void WorldSoccerWinners ()
241
239
{
242
240
// Create a grammar from an SRGSDocument, create a new rule
@@ -305,10 +303,9 @@ public void WorldSoccerWinners ()
305
303
## Examples
306
304
The following example creates a grammar that recognizes the phrase "A nation that has won the World Cup is" followed by the name of a country/region that has won the World Cup. The example uses the <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> object to build lists of acceptable country/region names from an array of <xref:System.Speech.Recognition.SrgsGrammar.SrgsItem> objects. Using the <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf.Add%2A> method, the example appends an <xref:System.Speech.Recognition.SrgsGrammar.SrgsItem> that contains the string "Italy" to the <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> object `oneOfEurope`.
Copy file name to clipboardExpand all lines: xml/System.Speech.Recognition.SrgsGrammar/SrgsRuleRef.xml
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -105,7 +105,7 @@
105
105
## Examples
106
106
The following example creates a grammar that recognizes the phrase "A nation that has won the World Cup is" followed by the name of a country that has won the World Cup. After creating the <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> object `winnerRule` and giving it the string identifier `WorldCupWinner`, the example appends the string "A nation that has won the World Cup is" to the rule. Using <xref:System.Speech.Recognition.SrgsGrammar.SrgsOneOf> objects, the example then builds a list of European countries/regions and a list of South American countries/regions, and adds each list to its respective rule, `ruleEurope` or `ruleSAmerica`. The example then creates rule references for `ruleEurope` and `ruleSAmerica` and adds them to the `WorldCupWinner` rule.
107
107
108
-
```
108
+
```csharp
109
109
public void WorldSoccerWinners ()
110
110
{
111
111
@@ -141,7 +141,7 @@ public void WorldSoccerWinners ()
<item> A nation that has won the world cup is </item>
@@ -218,7 +218,7 @@ public void WorldSoccerWinners ()
218
218
219
219
The second method, `CreateGrammarForRoute`, creates an <xref:System.Speech.Recognition.SrgsGrammar.SrgsDocument> element named `grammar` with a rule reference specified by the `Uri` passed to it by `GrammarUrlForRoute`. Note that the variable named _route is a member of an enclosing class.
220
220
221
-
```
221
+
```csharp
222
222
private Uri GrammarUrlForRoute(string route)
223
223
{
224
224
return new Uri("http://localhost/MyBus/MyBusLocations.grxml#LocationsForRoute" + route);
The following example creates a grammar for choosing the cities for a flight. The example constructs two <xref:System.Speech.Recognition.SrgsGrammar.SrgsRuleRef> instances, each of which specifies a semantic key. Both rule references target the same <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> object, named `cities`, but tag the recognition result from the rule reference with a different semantic key. The semantic key identifies a recognized city as the departure city or the arrival city for the flight. The handler for the <xref:System.Speech.Recognition.SpeechRecognitionEngine.SpeechRecognized> event uses the keys to retrieve the semantics values created using <xref:System.Speech.Recognition.SrgsGrammar.SrgsNameValueTag.%23ctor%2A> from the recognition result.
Copy file name to clipboardExpand all lines: xml/System.Speech.Recognition.SrgsGrammar/SrgsSemanticInterpretationTag.xml
+4-9Lines changed: 4 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -38,24 +38,20 @@
38
38
## Remarks
39
39
The default semantic format for System.Speech conforms to the W3C [Semantic Interpretation for Speech Recognition (SISR) Version 1.0](https://www.w3.org/TR/semantic-interpretation/), where the format for `tag` elements that contain script is `semantics/1.0`. You must specify the script for <xref:System.Speech.Recognition.SrgsGrammar.SrgsSemanticInterpretationTag> objects using this format. In the syntax of `semantics/1.0`:
40
40
41
-
- The Rule Variable of the containing rule element is identified by "out".
42
-
43
-
- The name of the object that has access to the Rule Variable of rule elements outside the containing rule element is identified by "rules".
44
-
45
-
- The result from the latest referenced rule that matches the utterance can be represented by "rules.latest()".
41
+
- The Rule Variable of the containing rule element is identified by "out".
42
+
- The name of the object that has access to the Rule Variable of rule elements outside the containing rule element is identified by "rules".
43
+
- The result from the latest referenced rule that matches the utterance can be represented by "rules.latest()".
46
44
47
45
You can also associate a semantic value with a phrase in a grammar without using script, using the <xref:System.Speech.Recognition.SrgsGrammar.SrgsNameValueTag> object.
48
46
49
-
50
-
51
47
## Examples
52
48
The following example creates a grammar for choosing the cities for a flight. The example uses <xref:System.Speech.Recognition.SrgsGrammar.SrgsSemanticInterpretationTag> to assign a semantic value to each city, which is the code for the city's airport. The example also uses <xref:System.Speech.Recognition.SrgsGrammar.SrgsSemanticInterpretationTag> to assign a separate semantic key for each of the two references made by the <xref:System.Speech.Recognition.SrgsGrammar.SrgsRuleRef> object named `cityRef` to the <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule> object named `cities`. The semantic keys identify a recognized city as the departure city or the arrival city for the flight. The handler for the <xref:System.Speech.Recognition.SpeechRecognitionEngine.SpeechRecognized> event uses the keys to retrieve the semantics from the recognition result.
53
49
54
50
In the code example, "out" refers to the Rule Variable of the containing <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule>. The expression "out.LeavingFrom" refers to the property named `LeavingFrom` of the Rule Variable on the rule named `bookFlight`.
55
51
56
52
The expression "rules.flightCities" refers to the Rule Variable on the rule whose <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.Id%2A> is `flightCities`, and which is the target of a rule reference. In the example, the expression "out.LeavingFrom=rules.flightCities;" assigns the value from the rule whose <xref:System.Speech.Recognition.SrgsGrammar.SrgsRule.Id%2A> is `flightCities` to the property named `LeavingFrom` of the Rule Variable on the rule named `bookFlight`. See [Semantic Results Content](https://msdn.microsoft.com/library/622291af-615c-4a15-9014-2933aa3f89fe), [Grammar Rule Name Referencing](https://msdn.microsoft.com/library/0777e975-8665-4cc3-957b-752743cb1bb9), and [Grammar Rule Reference Referencing](https://msdn.microsoft.com/library/dec3a809-9aa2-4139-893f-3a549ca1e03e) for more information.
57
53
58
-
```
54
+
```csharp
59
55
using System;
60
56
using System.Speech.Recognition;
61
57
using System.Speech.Recognition.SrgsGrammar;
@@ -136,7 +132,6 @@ namespace SampleRecognition
136
132
}
137
133
}
138
134
}
139
-
140
135
```
141
136
142
137
The following is the XML form of the grammar generated by the code in the example above.
Copy file name to clipboardExpand all lines: xml/System.Speech.Recognition.SrgsGrammar/SrgsToken.xml
+1-2Lines changed: 1 addition & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -161,7 +161,7 @@
161
161
## Examples
162
162
The grammar in the following example contains slang words and also has an uncommon word: "whatchamacallit". Adding a custom, inline pronunciation using the <xref:System.Speech.Recognition.SrgsGrammar.SrgsToken.Pronunciation%2A> property of the <xref:System.Speech.Recognition.SrgsGrammar.SrgsToken> class can improve the accuracy of recognition for the word "whatchamacallit" as well as for the entire phrase that contains it. The example uses phones from the Microsoft Universal Phone Set (UPS) to define the custom pronunciations.
The following example creates a speech recognition grammar from a local SRGS file (cities.xml) using a file stream. The content of the cities.xml file appears following C# example.
The following example loads a local SRGS file (cities.xml) from a file stream and specifies a rule to use as the root of the grammar. The content of the cities.xml file appears in the XML example that follows the C# example.
565
558
566
559
```csharp
567
-
568
560
// Load a cities grammar from an I/O stream, use a specific
569
561
// rule as the root of the grammar, and return the new grammar.
The following example loads a local SRGS file (cities.xml) from a file and specifies a rule to use as the root of the grammar. The content of the cities.xml file appears in the XML example that follows the C# example.
802
792
803
793
```csharp
804
-
805
794
// Load a cities grammar from a local file, use a specific
806
795
// rule as the root of the grammar, and return the new grammar.
The following example loads a local SRGS file (shuttle.xml) from a file stream. The file contains a relative rule reference to a rule in the cities.xml file, and specifies a base URI to use to resolve the rule reference. The content of the shuttle.xml and cities.xml files appears in the XML examples that follow the C# example.
The following example creates a speech recognition grammar in an <xref:System.Speech.Recognition.SrgsGrammar.SrgsDocument> that contains a relative rule reference to the cities.xml file, and specifies a URI to use to resolve the rule reference. The content of the cities.xml file appears in the XML example that follows the C# example.
The following example writes information about a <xref:System.Speech.Recognition.Grammar> object to the [console](https://go.microsoft.com/fwlink/?LinkId=159613).
The following example writes information about a <xref:System.Speech.Recognition.Grammar> object to the [console](https://go.microsoft.com/fwlink/?LinkId=159613).
The following example creates two <xref:System.Speech.Recognition.Grammar> objects, one for digits and one for fractions. The Grammar objects are assigned names and relative weights and priorities, and loaded by an in-process speech recognizer. The `CreateDigitsGrammar`, `CreateFractionsGrammar`, and `recognizer_SpeechRecognized` methods are not shown here.
1601
1581
1602
1582
```csharp
1603
-
1604
1583
// Create a Grammar for recognizing numeric digits.
The following example creates two <xref:System.Speech.Recognition.Grammar> objects, one for digits and one for fractions. The <xref:System.Speech.Recognition.Grammar> objects are assigned names and relative weights and priorities, and loaded by an in-process speech recognizer. The `CreateDigitsGrammar`, `CreateFractionsGrammar`, and `recognizer_SpeechRecognized` methods are not shown here.
1674
1653
1675
1654
```csharp
1676
-
1677
1655
// Create a Grammar for recognizing numeric digits.
The following example writes information about a <xref:System.Speech.Recognition.Grammar> object to the [console](https://go.microsoft.com/fwlink/?LinkId=159613).
Console.WriteLine("Grammar name is {0}:", item.Name);
@@ -1963,7 +1940,6 @@ public partial class Form1 : Form
1963
1940
The following example creates two <xref:System.Speech.Recognition.Grammar> objects, one for digits and one for fractions. The <xref:System.Speech.Recognition.Grammar> objects are assigned names and relative weights and priorities, and loaded by an in-process speech recognizer. The `CreateDigitsGrammar`, `CreateFractionsGrammar`, and `recognizer_SpeechRecognized` methods are not shown here.
1964
1941
1965
1942
```csharp
1966
-
1967
1943
// Create a Grammar for recognizing numeric digits.
0 commit comments