Error thrown and uncaught while speaking " " (empty space) on Safari using Cognitive Services
(Reported internally via Teams on behalf of customer)
Screenshots

Version
Possibly 4.12.0
Describe the bug
When using Cognitive Services to speak on an activity with speak field of an empty space " ", AudioContext.decodeAudioData will throw an exception, because the TTS-ed wavedata is empty (0 bytes in length, instead of MP3).
Thus, AudioContext.decodeAudioData(ArrayBuffer.from([])) would throw an exception.
This only happens in Safari because Safari is using an older signature of AudioContext.decodeAudioData, a.k.a. callback signature.

Due to a bug on how we handle the callback signature, we throw an exception of null. It propagate up through here:

Since error is null, accessing error.stack will trigger an exception, which is uncaught.
Steps to reproduce
- On Safari, speak to a bot that will result in an activity with
speakfield set to" "(empty space)
Expected behavior
It should not narrate anything.
Additional context
[Bug]
For customers experiencing this problem: Temporary work around: do not send a speak field with a single space
The is also related to #3782.