chore: commit local changes (voice cleanup, audio notifications)

This commit is contained in:
Sojan Jose
2025-08-18 13:00:08 +02:00
parent 6c6a2ec58f
commit a16e3e0352
11 changed files with 98 additions and 304 deletions

View File

@@ -13,16 +13,35 @@ export const getAudioContext = () => {
// eslint-disable-next-line default-param-last
export const getAlertAudio = async (baseUrl = '', requestContext) => {
const audioCtx = getAudioContext();
let lastSource;
const stopLast = () => {
try {
if (lastSource) {
lastSource.stop();
}
} catch (_) {
// ignore stop errors
} finally {
lastSource = null;
}
};
const playSound = audioBuffer => {
window.playAudioAlert = () => {
if (audioCtx) {
stopLast();
const source = audioCtx.createBufferSource();
source.buffer = audioBuffer;
source.connect(audioCtx.destination);
source.loop = false;
source.start();
lastSource = source;
source.onended = () => {
if (lastSource === source) lastSource = null;
};
}
};
window.stopAudioAlert = stopLast;
};
if (audioCtx) {