Azure-Samples / cognitive-services-speech-sdk

Sample code for the Microsoft Cognitive Services Speech SDK
MIT License
2.88k stars 1.85k forks source link

the response result is Canceled when I execute the program on CentOs7 #2030

Closed youtianhong closed 1 year ago

youtianhong commented 1 year ago

Expected behavior Hope will transform text to speech normally on CentOs7 (It's work fine on Windows OS)

Version of the Cognitive Services Speech SDK 1.30.0 of client-sdk

Platform, Operating System, and Programming Language OS: Linux Hardware - x64 Programming language: Java Browser: Chrome

Describe the bug My application is a spring boot java project connecting to the azure services for converting text to speech. the problem is happened, when I executed the tts program, the response result is Canceled, What's the problem? (It works fine on Windows OS)

2023-07-28 12:23:16.163 [http-nio-6666-exec-8] INFO c.s.aioral.web.controller.SpeechController - ---------loadLibrary success------ 2023-07-28 12:23:16.163 [http-nio-6666-exec-8] INFO c.s.aioral.integration.azure.AzureTtsServiceImpl - start to textToSpeech,voiceName=en-US-JaneNeural,text length=12 2023-07-28 12:23:16.545 [http-nio-6666-exec-8] INFO c.s.aioral.integration.azure.AzureTtsServiceImpl - textToSpeech resultId=185c66bd97fe4b9c97b124311a3c1be8 reason=Canceled

You known the normal response result is "textToSpeech resultId=8cb690dde3304cfa9fe74c97e2a9b61a,reason=SynthesizingAudioCompleted" which was executed on Windows OS

My text to speech code like below: `public byte[] textToSpeech(String voiceName,String text) { log.info("start to textToSpeech,voiceName={},text length={}",voiceName,text.length());

    try{

        SpeechConfig speechConfig = SpeechConfig.fromSubscription("4408b323ce244ce7b7b8bxxxxx", "southeastasia");
        speechConfig.setSpeechSynthesisLanguage("en-US");
        //en-US-JennyNeural
        speechConfig.setSpeechSynthesisVoiceName(voiceName);
        speechConfig.setSpeechSynthesisOutputFormat(SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3);
        SpeechSynthesizer synthesizer = new SpeechSynthesizer(speechConfig, null);
        SpeechSynthesisResult result = synthesizer.SpeakText(text);
        log.info("textToSpeech resultId={},reason={}",result.getResultId(),result.getReason().toString());
        return result.getAudioData();
    } 

}`

youtianhong commented 1 year ago

I try to print the detail of the result, Why it reported Connection failed ? and show web socket connection? Actually I use http way to convert it

2023-07-28 23:26:31.245 [http-nio-5555-exec-6] INFO com.example.demo.service.AzureTtsServiceImpl - start to textToSpeech,voiceName=en-US-JaneNeural,text length=11 2023-07-28 23:26:34.054 [http-nio-5555-exec-6] INFO com.example.demo.service.AzureTtsServiceImpl - textToSpeech resultId=56a45c32865e4cb68b822b1d3ec9a841reason=Canceled 2023-07-28 23:26:34.055 [http-nio-5555-exec-6] INFO com.example.demo.service.AzureTtsServiceImpl - CANCELED: Reason=Error 2023-07-28 23:26:34.055 [http-nio-5555-exec-6] ERROR com.example.demo.service.AzureTtsServiceImpl - CANCELED: ErrorCode=ConnectionFailure 2023-07-28 23:26:34.056 [http-nio-5555-exec-6] ERROR com.example.demo.service.AzureTtsServiceImpl - CANCELED: ErrorDetails="Connection failed (no connection to the remote host). Internal error: 1. Error details: Failed with error: WS_OPEN_ERROR_UNDERLYING_IO_OPEN_FAILED wss://southeastasia.tts.speech.microsoft.com/cognitiveservices/websocket/v1 X-ConnectionId: da6c705e38c44fb6a34518f81f48fca1 USP state: Sending. Received audio size: 0 bytes."

youtianhong commented 1 year ago

I'm not sure if the problem is caused by OpenSSL configration, but the problem still exists when i config the SSL_CERT_FILE for this: export SSL_CERT_FILE=/etc/pki/tls/certs/ca-bundle.crt

I saw the azure guide mentioned that need download and install the CA certification like below: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/how-to-configure-openssl-linux?pivots=programming-language-java#certificate-revocation-checks If a destination posing as the Speech service reports a certificate that's been revoked in a retrieved CRL, the SDK will terminate the connection and report an error via a Canceled event

if the problem is not config CA certification, Which one should i need to download and config? There are too many certifications in this list of the link https://learn.microsoft.com/zh-cn/azure/security/fundamentals/azure-ca-details?tabs=root-and-subordinate-cas-list#certificate-downloads-and-revocation-lists

ralph-msft commented 1 year ago

To better assist you, could you please share the SDK logs? You can find instructions on how to do this here: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/how-to-use-logging

youtianhong commented 1 year ago

The problem is fixed after setting configuration for printing SDK log (speechConfig.setProperty(PropertyId.Speech_LogFilename, "LogfilePathAndName");) Not sure if this is a coincidence, it's curious (May be it's not effective for previous setting export SSL_CERT_FILE, but it's fine now)

I found this openssl error log like below when i invoke the api at the first time,in the meantime it cost 8 seconds for 1st invoking It's fine now after the first time invoking, the error log disappeared, and it cost time normally (one or two seconds per time cost) Could you tell me what is the problem?

[191645]: 212ms SPX_TRACE_ERROR: AZ_LOG_ERROR: tlsio_openssl.c:1257 could not read file /tmp/309b4d70.crl.0 [191645]: 212ms SPX_TRACE_ERROR: AZ_LOG_ERROR: tlsio_openssl.c:1257 could not read file /tmp/309b4d70.crl.1

github-actions[bot] commented 1 year ago

This item has been open without activity for 19 days. Provide a comment on status and remove "update needed" label.

trrwilson commented 1 year ago

Hello! Apologies for the delayed response on the followup question.

That transient message and delay you see is expected behavior with downloading and caching certificate revocation list (CRL) data to improve connection security. You can read more about how the Speech SDK uses CRLs and how it can be configured on this page: https://learn.microsoft.com/azure/ai-services/speech-service/how-to-configure-openssl-linux

Given the bit of the topic shift and age, I'll close this issue. Please file a new issue referencing this one if there's more we can help with. Thank you!