Nice work with speak.js!
I wrapped speakClient file with a function for better global scope control, which allows it to be used in any environment (like the way js library like jQuery does).
Probably, we should define name space like SpeakJS in the future (I will do that if you agree with the name) to avoid name conflict.
In addition, I added support for onended callback for the speak() function. The speak() function still works as it is but also it accepts optional callback parameter, which is called when speech finishes.
Further more, I add pause() and resume() functions for convenience.
Wrap with function for flexible usage
Add support for onended callback, pause and resume function
Ah, this is very nice!
I am concerned though with adding functions to the window object, which I think the code here does? Do other projects do such things? For example, I worry that if the browser window object gets a play method in the future, it will collide here with yours. Or maybe I misunderstood the code?
You are right. I made it this way to be consistent with your speak() API. Ultimately, we should provide these API under some namespace. e.g. TTS so TTS.speak(), TTS.pause(), etc.
Do you think TTS is good name or do you have something else in your mind?
I was using Speak.js on a project this weekend and can't wait to see the onended, pause(), and resume() features getting added. This is an awesome tool with a lot of potential and the features in this pull request will help out a ton! Looking forward to updates!
Sorry for the lack of updates on my part, I am super-busy with other projects and can't seem to find time for this. But I hope someone makes a fork and does cool stuff there. I am happy to call such a fork the "official version" if there is one, in the project page.
In that case, I can participate on that since I have that branch already. I will finish up with wrapping the API asap on my fork.
Thanks and good luck with your other projects!
Now I merged the latest branch with my change in https://github.com/kn/speak.js
Basically, I made 'speak' as a global variable rather than function with APIs:
You can read the detail in its README if you are interested.
Looks like nice work :) Do you want me to link to your fork in the main page?
That will be great :)
https://github.com/katsuyan/speak.js 404 :(
It's https://github.com/kn/speak.js now.