SpeechRecognizer.Grammars Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a collection of the Grammar objects that are loaded in this SpeechRecognizer instance.
public:
property System::Collections::ObjectModel::ReadOnlyCollection<System::Speech::Recognition::Grammar ^> ^ Grammars { System::Collections::ObjectModel::ReadOnlyCollection<System::Speech::Recognition::Grammar ^> ^ get(); };
public System.Collections.ObjectModel.ReadOnlyCollection<System.Speech.Recognition.Grammar> Grammars { get; }
member this.Grammars : System.Collections.ObjectModel.ReadOnlyCollection<System.Speech.Recognition.Grammar>
Public ReadOnly Property Grammars As ReadOnlyCollection(Of Grammar)
Property Value
A collection of the Grammar objects that the application loaded into the current instance of the shared recognizer.
Examples
The following example outputs information to the console for each speech recognition grammar loaded into the shared speech recognizer.
using System;
using System.Collections.Generic;
using System.Speech.Recognition;
using System.Threading;
namespace SharedRecognizer
{
class Program
{
static void Main(string[] args)
{
using (SpeechRecognizer recognizer = new SpeechRecognizer())
{
Grammar sampleGrammar = new Grammar(new GrammarBuilder("sample phrase"));
sampleGrammar.Name = "Sample Grammar";
recognizer.LoadGrammar(sampleGrammar);
OutputGrammarList(recognizer);
}
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
private static void OutputGrammarList(SpeechRecognizer recognizer)
{
List<Grammar> grammars = new List<Grammar>(recognizer.Grammars);
if (grammars.Count > 0)
{
Console.WriteLine("Loaded grammars:");
foreach (Grammar g in grammars)
{
Console.WriteLine(" Grammar: {0}",
(g.Name != null) ? g.Name : "<no name>");
}
}
else
{
Console.WriteLine("No grammars loaded.");
}
}
}
Remarks
This property does not return any speech recognition grammars loaded by another application.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기