Cognitive-services-speech-sdk: How to remove punctuation ?

Created on 26 May 2020  路  9Comments  路  Source: Azure-Samples/cognitive-services-speech-sdk

Hello,

How can i receive recognized result without punctuation ?

E.g. Instead of "What is the weather today ?", i'm expecting "What is the weather today" without question mark.

Thank you.

question

Most helpful comment

Add this:

speechConfig.setServiceProperty('punctuation', 'explicit', SpeechSDK.ServicePropertyChannel.UriQueryParameter);

To where you initialize your config object.

All 9 comments

The "Lexical" field in the detailed recognized text does not contain punctuation.
For speech to text, you can turn on detailed format by speechConfig->SetProperty(PropertyId::SpeechServiceResponse_OutputFormatOption, "detailed") before creating the recognizer.

The Lexical field can be retrieved as follows:

auto result = recognizer->RecognizeOnceAsync().get();
string jsonResult = result->Properties.GetProperty(PropertyId::SpeechServiceResponse_JsonResult);

Here is an example of the jsonResult:

image

Closing the issue as the question was answered.

I am having same issue in javascript sdk and I am using startContinuousRecognitionAsync function. I have added speechConfig.setProperty("SpeechServiceResponse_OutputFormatOption", "detailed") before creating the recognizer object but it's not returning Lexical field in :

recognizer.recognized = function (s, e) {
 console.log('recognized text', e.result.properties.getProperty("SpeechServiceResponse_JsonResult"));
};

Am I missing something ? Thank You.

To set the output format use:
speechConfig.outputFormat = sdk.OutputFormat.Detailed;

The property you found about it is an internal one that isn't used by all recognizer types, the config option should work for all types.

@rhurey Thanks it helped. But we need to enablespeechConfig.enableDictation(); so, this Lexical field is not useful. Is there any way to stop auto punctuation please ? Thank You.

Just to make sure I get the right information...

Do you want automatic punctuation turned off, and explicit punctuation to still be on and rendered?

i.e. if the user spoke the words: "Call my wife period" you'd get "Call my wife."
but if the user spoke "Call my wife" you'd get "Call my wife"
?

@rhurey yes. That's exactly we want. Thanks

@rhurey Is there any way to fix my issue please ?

Add this:

speechConfig.setServiceProperty('punctuation', 'explicit', SpeechSDK.ServicePropertyChannel.UriQueryParameter);

To where you initialize your config object.

Was this page helpful?
0 / 5 - 0 ratings