mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Use sprite’s soundbank to play text2speech sound (#1388)
* Use sprite’s soundbank to play sound * Add todo comment
This commit is contained in:
parent
db0597ada5
commit
f5066626e5
1 changed files with 8 additions and 3 deletions
|
@ -116,9 +116,10 @@ class Scratch3SpeakBlocks {
|
|||
/**
|
||||
* Convert the provided text into a sound file and then play the file.
|
||||
* @param {object} args Block arguments
|
||||
* @param {object} util - utility object provided by the runtime.
|
||||
* @return {Promise} A promise that resolves after playing the sound
|
||||
*/
|
||||
speakAndWait (args) {
|
||||
speakAndWait (args, util) {
|
||||
// Cast input to string
|
||||
args.WORDS = Cast.toString(args.WORDS);
|
||||
|
||||
|
@ -154,8 +155,12 @@ class Scratch3SpeakBlocks {
|
|||
}
|
||||
};
|
||||
this.runtime.audioEngine.decodeSoundPlayer(sound).then(soundPlayer => {
|
||||
soundPlayer.connect(this.runtime.audioEngine);
|
||||
soundPlayer.play();
|
||||
// @todo this code should not go to production as is because it leaks
|
||||
// soundplayers. We may not want to use the soundbank for this purpose
|
||||
// at all.
|
||||
const soundBank = util.target.sprite.soundBank;
|
||||
soundBank.addSoundPlayer(soundPlayer);
|
||||
soundBank.playSound(util.target, soundPlayer.id);
|
||||
soundPlayer.on('stop', resolve);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue