Speechsynthesizer causes JVM crash during finalization (Speech client-sdk for Java)

Lucas Mikulla 0 Reputation points
2024-12-17T12:41:19.6966667+00:00

https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues/2701

As I detailed in the above github issue, there is a reproducible bug in the Java client-sdk for Azure Speech. During Finalization of Speechsynthesizer Instance it can cause a Memory Access Violation, resulting in a full crash of the JVM.

Version of Speech SDK 1.40.0

Platform, Operating System, and Programming Language

OS: Windows Server 2022 und Windows 11 Pro Programming language: Java OpenJDK 11

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

1 answer

Sort by: Most helpful
  1. navba-MSFT 26,885 Reputation points Microsoft Employee
    2024-12-24T02:48:39.3466667+00:00

    @Lucas Mikulla I was able to repro this issue at my end and find the cause of this issue.Cause:

    The problem with the provided code is that it doesn't wait for the speech synthesis to complete before the synthesizer object is closed. When I tried it, I got this error - java.lang.IllegalStateException: Cannot dispose a synthesizer while async synthesis is running. Await async synthesis to avoid unexpected disposals.

    .

    Fix:

    I replaced test.speak("Hello"); with test.speak("Hello").get(); and Speech SDK did not crash anymore.

    .

    Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.

    **

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.