Skip to content

fix: prevent unnecessary /api/speech calls causing 500 errors#2201

Open
Priyanka-Microsoft wants to merge 1 commit intoAzure-Samples:devfrom
Priyanka-Microsoft:psl-bug-42243
Open

fix: prevent unnecessary /api/speech calls causing 500 errors#2201
Priyanka-Microsoft wants to merge 1 commit intoAzure-Samples:devfrom
Priyanka-Microsoft:psl-bug-42243

Conversation

@Priyanka-Microsoft
Copy link
Copy Markdown
Contributor

@Priyanka-Microsoft Priyanka-Microsoft commented May 4, 2026

Purpose

  • ...
    This pull request improves the speech synthesis feature in the Answer component by making the initialization and error handling of the speech synthesizer more robust and testable. The main changes include refactoring synthesizer initialization, enhancing error handling, and updating related tests.

Speech Synthesis Improvements:

  • Refactored the initializeSynthesizer function to accept optional token and region parameters, and to return null if these are missing, making initialization more flexible and robust.
  • Updated the speech playback logic to fetch synthesizer credentials if missing, initialize the synthesizer with those credentials, and handle errors gracefully by logging them to the console.
  • Modified the startSpeech function to accept an optional synthesizer instance, improving flexibility in how speech playback is triggered.

Testing and Error Handling:

  • Updated the test for API error handling to mock console.error instead of console.log, and added a test for clicking the speak button, ensuring error handling is properly tested. [1] [2]
  • Improved the fetchSythesizerData function to return a promise and handle errors more cleanly, removing unnecessary try/catch and logging.

These changes make the speech synthesis feature more reliable and maintainable, and ensure that error scenarios are properly handled and tested.

BUG ID :
https://dev.azure.com/CSACTOSOL/CSA%20Solutioning/_workitems/edit/42243/

Does this introduce a breaking change?

  • Yes
  • No

How to Test

  • Get the code
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
  • Test the code

What to Check

Verify that the following are valid

  • ...

Other Information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant