how to disable the automatic fading of webaudio during speech synthesis

70 Views Asked by At

When using webaudio to play music and speechsynthesis to speak, some browsers ( Chrome and Safari ) do an automatic fading of the music. In my games I have my own functions to manage the fading of the music the way I want. And I don't like their automatic fading, the volume of the music is too low during the speech and the volume comes back way too long after the speech has ended. So I want to disable this.

Is it possible ? (with javascript and html, not in the browser settings)

Here is the most simple example I can create to show you the fading I am talking about :

audiocontext = new AudioContext();
oscillator = audiocontext.createOscillator();
oscillator.connect(audiocontext.destination);
oscillator.start();

setTimeout( function(){ 
    let msg = new SpeechSynthesisUtterance();
    msg.lang = "en-GB" ;
    msg.text = "This is a test of speech synthesis." ;
    window.speechSynthesis.speak(msg);
 } , 2000 )

0

There are 0 best solutions below