Azure-Samples / cognitive-services-speech-sdk

Sample code for the Microsoft Cognitive Services Speech SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can i set silence duration at end of speech ?

yeshunping opened this issue · comments

It seems that the default silence duration is 2s , it means that after 2 second silence, silence detected will be triggered. BUT on some cases, we need a shorter threshold for it, for example , 1s or 600ms for it.
I will C++ SDK ,but i failed to find a interface to set it. I only found that

InitialSilenceTimeout = 2

for NoMatchCode

Is there such a interface ? or if this feature will be supported in the coming release ? or existed already in SDK of other languages ?

or is there some config for EndSilenceTimeout ?

Currently it is not directly possible to specify silence timeout via SDK APIs. As a workaround, you can use FromEndpoint call to create a SpeechConfig and specifying the endping URL with query parameters:
wss://YourServiceRegion.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1? initialSilenceTimeoutMs=2000&endSilenceTimeoutMs=2000

Please note to replace YourServiceRegion with the name of service region associated with your subscription key, like westus. And the value for initialSilenceTimeoutMs and endSilenceTimeoutMs is in millisecond.

We will add methods in API to allow users to configure initial and end silence timeout in the future release.

ok ,I will try SpeechConfig. thanks very much.

@zhouwangzw Any update regarding the silence timeout via SDK APIs? Is that already available?

There is a 'SetProperty' method on the config which was added to the SDK to allow you to set parameters to the request
(in C#: https://docs.microsoft.com/en-us/dotnet/api/microsoft.cognitiveservices.speech.propertycollection.setproperty?view=azure-dotnet)

This way you can set the EndSilenceTimeout (PropertyIDs in C#:
https://docs.microsoft.com/en-us/dotnet/api/microsoft.cognitiveservices.speech.propertyid?view=azure-dotnet)

thx
Wolfgang