SpeechClient Class |
Namespace: Microsoft.Bing.Speech
The SpeechClient type exposes the following members.
Name | Description | |
---|---|---|
SpeechClient |
Initializes a new instance of the SpeechClient class used to perform speech recognition with audio data.
|
Name | Description | |
---|---|---|
Dispose |
Dispose and clean up resources.
| |
RecognizeAsync |
Streams audio asynchronously to the speech service for recognition.
| |
SubscribeToT |
Subscribes the specific event to perform given a action.
| |
SubscribeToPartialResult |
Subscribes to partial speech results.
| |
SubscribeToRecognitionResult |
Subscribes to speech recognition results.
|
var preferences = new Preferences("en-us", new Uri(@"wss://speech.platform.bing.com/api/service/recognition"), new AuthorizationProvider("******************")); using (var speechClient = new SpeechClient(preferences)) { speechClient.SubscribeToPartialResult( result => { Console.WriteLine(result.DisplayText); return Task.FromResult(true); }); speechClient.SubscribeToRecognitionResult( result => { Console.WriteLine(result.RecognitionStatus); return Task.FromResult(true); }); // create an audio content and pass it a stream. using (var audio = new FileStream("sample.wav", FileMode.Open, FileAccess.Read)) { var deviceMetadata = new DeviceMetadata(DeviceType.Near, DeviceFamily.Desktop, NetworkType.Ethernet, OsName.Windows, "1607", "Dell", "T3600"); var applicationMetadata = new ApplicationMetadata("SampleApp", "1.0.0"); var requestMetadata = new RequestMetadata(Guid.NewGuid(), deviceMetadata, applicationMetadata, "SampleService"); await speechClient.RecognizeAsync(new SpeechInput(audio, requestMetadata), CancellationToken.None).ConfigureAwait(false); } }