Note
Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.
Check Phrase Input and Output File Format
Check Phrase takes as input an XML-based grammar file, a phrase to analyze, and a configuration file for the recognition engine. You specify the phrase to check on the command line when you run the tool. The tool writes a summary to the console that includes the input phrase and its semantics, and optionally writes detailed results of emulated recognition for the input phrase to an XML file.
Input File Format
Check Phrase accepts the following file formats for input grammar files:
Grammar documents in XML format that conform to the Speech Recognition Grammar Specification (SRGS) Version 1.0, for example "MyGrammar.grxml". It is an accepted convention to use the ".grxml" file extension for XML-based grammar documents that conform to the SRGS specification.
Compiled grammar files in CFG format, for example "MyCompiledGrammar.cfg". See the Compile Grammar Reference Manual for information about compiling grammar files.
Note
Input files in other formats will generate an error.
Example
The following is an example of a valid input grammar document in XML format that contains only the minimum required elements and attributes in the document’s header, and a simple rule in the body of the document.
<?xml version="1.0"?>
<grammar version="1.0"
xmlns="http://www.w3.org/2001/06/grammar"
xml:lang="en-US" root="main">
<rule id="main">
<one-of>
<item> hello </item>
<item> world </item>
</one-of>
</rule>
</grammar>
A valid XML-format grammar document consists of a legal header followed by a body consisting of a set of legal rule definitions. The document header ends and the body of the grammar document begins with the first rule element. Grammar files used as input for Check Phrase can contain optional elements and attributes in the document header, see SRGS Grammar XML Reference (Microsoft.Speech). For more information about elements and attributes in SRGS grammars, see Speech Recognition Grammar Specification Version 1.0.
Output File Format
The tool writes a summary of the analysis to the console and generates complete results of the analysis to an XML file.
Summary Output to the Console
When the analysis is complete, a summary containing the following information displays in the console:
Whether the phrase is in the grammar.
The semantics for the phrase (if the phrase is in the grammar and the result interpretation is a literal). If the semantics for the phrase are complex, the name of the output file.
Using the grammar example above and the phrase "hello" as inputs, the following is an example of the summary output to the console:
Info: Successfully parsed "hello"
Info: Successfully output details to "HelloWorldGrammarOutput.utt"
Processing Complete: 0 Error(s). 0 Warning(s).
Check Phrase Output File
Check Phrase generates detailed results of the analysis to an output file in XML format. The output file includes the following information:
The phrase input for emulation.
Whether the phrase was successfully parsed (that is, emulated) by the engine and the grammar (that is, matched).
The semantics for the phrase: either a string for a literal result, or XML markup that describes complex semantics.
The pronunciation of an emulated match.
The identifier of the rule used to match the phrase, and the location of the grammar file that contains it.
Example
The following example illustrates the output format of the Check Phrase tool when the input is the phrase “hello” and it matches the example grammar above.
<?xml version="1.0" encoding="utf-8"?>
<Scenario xml:space="preserve">
<Utterance>
<TranscriptText>hello</TranscriptText>
<InGrammar>True</InGrammar>
<TranscriptSemantics>hello</TranscriptSemantics>
<TranscriptPronunciation>H EH L O</TranscriptPronunciation>
<TranscriptRuleTree>
<Rule id=”main” uri=”HelloWorldGrammar.grxml”>hello</Rule>
</TranscriptRuleTree>
</Utterance>
</Scenario>
Remarks
For this release, Check Phrase returns only the top result if there are multiple matches for an input phrase.