Text2speech set gain to 2 (6db)

This commit is contained in:
Eric Rosenbaum 2018-08-31 10:47:36 -04:00
parent dbd3996fb6
commit 5dfa4cc691

View file

@ -337,9 +337,18 @@ class Scratch3SpeakBlocks {
}
};
this.runtime.audioEngine.decodeSoundPlayer(sound).then(soundPlayer => {
soundPlayer.connect(this.runtime.audioEngine);
const context = this.runtime.audioEngine.audioContext;
soundPlayer.setPlaybackRate(playbackRate);
soundPlayer.play();
// Increase the loudness of the speech sound
const gainNode = context.createGain();
gainNode.gain.setValueAtTime(2, context.currentTime);
// Note that this connect must be done after play is called,
// which initializes the soundPlayer's output node.
soundPlayer.outputNode.connect(gainNode);
gainNode.connect(this.runtime.audioEngine.inputNode);
soundPlayer.on('stop', resolve);
});
});