1 line
922 B
JavaScript
1 line
922 B
JavaScript
"use strict";var t=function(t){return t&&t.__esModule?t["default"]:t},s=require("../bt/main"),e=s.Status,o=s.createBehavior,r=s.factory,n=t(require("../tts-service.js"));module.exports=o({constructor:function(t,s){var o=this;this.status=e.INVALID,this.getWords=t,this.onWordWrapper=function(t){s(t),"STOP"===t.status&&(o.status=e.SUCCEEDED)},this.onSpeakingStopped=function(){o.status=e.SUCCEEDED}},start:function(){var t=this;return this.status=e.IN_PROGRESS,this.getWords(function(s){n.speak(s,function(s){return s?(console.log("tts.speak() error: "+s),void(t.status=e.SUCCEEDED)):void 0})}),n.on("word",this.onWordWrapper),n.on("stopped",this.onSpeakingStopped),!0},cleanup:function(){n.removeListener("stopped",this.onSpeakingStopped),n.removeListener("word",this.onWordWrapper)},stop:function(){this.cleanup()},update:function(){return this.status!==e.IN_PROGRESS&&this.cleanup(),this.status}}),r.addBehavior(module); |