Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Job Engine, espeak talks on top of itself. #57

Open
JamesNewton opened this issue Sep 23, 2020 · 0 comments
Open

In Job Engine, espeak talks on top of itself. #57

JamesNewton opened this issue Sep 23, 2020 · 0 comments
Labels
bug job engine Related to onboard DDE jobs. .dde jobs which run in the job engine on the robot.

Comments

@JamesNewton
Copy link
Collaborator

the exec function returns instantly and continues to run espeak in the background, so that it's possible to call speak again. If speak is called multiple times, all the message appear on top of each other.

We fixed this once,
HaddingtonDynamics/Dexter#72 (comment)
but the fix wasn't incorporated and the code in DDE has changed enough that it needed to be re-implemented. I know the code below is working on my robot using job engine version 3.5.2, and I /think/ this will not cause problems going forward.

var to_speak = []
function speak({speak_data = "hello", volume = 1.0, rate = 1.0, pitch = 1.0, lang = "en_US", voice = 0, callback = null} = {}$
    if (arguments.length > 0 && speak_data != null) {
      var speak_data = arguments[0] //, volume = 1.0, rate = 1.0, pitch = 1.0, lang = "en_US", voice = 0, callback = null
      //out("speak_data:"+speak_data);
      }
    var text = stringify_for_speak(speak_data)
    if(window.platform == "node"){
      if (speak_data != null) { //new speech text
        let speak_cmd = "espeak \"" + text + "\" -a "+ (volume*200) + " -p " + (pitch * 50) + " -s " + (rate * 37 + 130)
        to_speak.push(speak_cmd)
        //out("saylater:"+speak_cmd)
        }
      else { //finished speaking prior text
        if (to_speak.length > 0) { //say what's on the stack, dump, and call again with null
          //out("saying: "+to_speak[0])
          exec(to_speak[0], function(){ to_speak.shift(); speak({speak_data:null}); })
          }
        else {
          //out("done saying");
          if (callback) callback();
          }
        }
      if (to_speak.length == 1) { //last one
        //out("lastword:"+to_speak[0])
        exec(to_speak[0], function(){ to_speak.shift(); speak({speak_data:null}); })
        }
      }
    else {
        var msg = new SpeechSynthesisUtterance();
//.... same from here down.
@JamesNewton JamesNewton added bug job engine Related to onboard DDE jobs. .dde jobs which run in the job engine on the robot. labels Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug job engine Related to onboard DDE jobs. .dde jobs which run in the job engine on the robot.
Projects
None yet
Development

No branches or pull requests

1 participant