Why does Connection.setMessageProperty return an error response?

Kun Wu 141 Reputation points Microsoft Employee
2024-03-27T03:20:17.47+00:00

Hello Speech-To-Text team,

By referring to Connection class API doc https://learn.microsoft.com/en-us/java/api/com.microsoft.cognitiveservices.speech.connection?view=azure-java-stable#com-microsoft-cognitiveservices-speech-connection-setmessageproperty(java-lang-string-java-lang-string-java-lang-string), with Speech Java SDK 1.34.0 i'm trying to config disfluency removal feature by using below code:

import com.microsoft.cognitiveservices.speech.*; 

SpeechConfig config = SpeechConfig.fromSubscription("<key>", "<region>");
SpeechRecognizer recognizer = new SpeechRecognizer(config, "zh-CN");   
Connection connect = Connection.fromRecognizer(recognizer); 
connect.setMessageProperty("speech.context", "phraseDetection",
"{\"enrichment\":{\"Interactive\":{\"PunctuationMode\":\"Implicit\",\"DisfluencyMode\":\"Removed\"},\"Dictation\":{\"PunctuationMode\":\"Explicit\",\"DisfluencyMode\":\"Removed\"},\"Conversation\":{\"PunctuationMode\":\"Implicit\",\"DisfluencyMode\":\"Removed\"}}}");


recognizer.recognized.addEventListener((s, e) -> {
if (e.getResult().getReason() == ResultReason.RecognizedSpeech) {                    System.out.println("RECOGNIZ-ED: Text=" + e.getResult().getProperties().getProperty(PropertyId.SpeechServiceResponse_JsonResult));          }});

recognizer.canceled.addEventListener((s, e) -> {                
if (e.getReason() == CancellationReason.Error) {                    System.out.println("CANCELED: ErrorCode=" + e.getErrorCode());                    System.out.println("CANCELED: ErrorDetails=" + e.getErrorDetails());                }});

recognizer.startContinuousRecognitionAsync().get();

However, i don't see the disfluency is removed by only get below error message from SDK:

CANCELED: ErrorCode=BadRequest CANCELED: ErrorDetails=Connection was closed by the remote host. Error code: 1007. Error details: Invalid 'language' query parameter or unknown custom deployment. SessionId: c8f90ba659104ca49cff9944cdccc01a

Would you please help to check this issue ?

Thank you.

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,555 questions
{count} votes

Accepted answer
  1. navba-MSFT 20,810 Reputation points Microsoft Employee
    2024-04-03T04:55:16.9666667+00:00

    @Kun Wu Apologies for the delay in getting back. Could you try running with the following?

     "{\"Language\": \"zh-CN\",\"Mode\": \"Conversation\",\"enrichment\":{\"Interactive\":{\"PunctuationMode\":\"Implicit\",\"DisfluencyMode\":\"Removed\"},\"Dictation\":{\"PunctuationMode\":\"Explicit\",\"DisfluencyMode\":\"Removed\"},\"Conversation\":{\"PunctuationMode\":\"Implicit\",\"DisfluencyMode\":\"Removed\"}}}");
    
    

    Awaiting your reply.


0 additional answers

Sort by: Most helpful