From 5dfa4cc6910eea375b3ce4a4321e7e720fcd382c Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Fri, 31 Aug 2018 10:47:36 -0400 Subject: [PATCH] Text2speech set gain to 2 (6db) --- src/extensions/scratch3_text2speech/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/extensions/scratch3_text2speech/index.js b/src/extensions/scratch3_text2speech/index.js index 393c3084..fd023d99 100644 --- a/src/extensions/scratch3_text2speech/index.js +++ b/src/extensions/scratch3_text2speech/index.js @@ -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); }); });