Last active
December 12, 2015 01:48
-
-
Save Cmaury/4693667 to your computer and use it in GitHub Desktop.
It looks like the node-module speak.js breaks when you submit any options along with the string to be read. See below for an illustration using the included example. Any ideas as to what's going on?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var speak = require("./node-speak.js"), | |
http = require("http"); | |
var audio = ""; | |
//I tried multiple variations of including the options: speed, 'speed', '175', and 175. All produce the same error message. | |
speak("Hello, i was made using node dot J. S.", {'speed': '175'}, { | |
callback: function(src) { | |
audio = src; | |
} | |
}); | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/html'}); | |
res.end("<!DOCTYPE html><html><head><title>Speak.js node module</title></head><body><audio id='generatedAudio' src='" + audio + "' /></body><script type='text/javascript'>document.getElementById('generatedAudio').play();</script></html>"); | |
}).listen(1337, "127.0.0.1"); | |
console.log(audio); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ReferenceError: document is not defined | |
at callback (/Users/cmaury/Dropbox/dev/Accessibilityfirst/AsYouWish/node_modules/node-speak/node-speak.js:100454:9) | |
at speak (/Users/cmaury/Dropbox/dev/Accessibilityfirst/AsYouWish/node_modules/node-speak/node-speak.js:100504:5) | |
at /Users/cmaury/Dropbox/dev/Accessibilityfirst/AsYouWish/app.js:49:2 | |
at callbacks (/Users/cmaury/Dropbox/dev/Accessibilityfirst/AsYouWish/node_modules/express/lib/router/index.js:161:37) | |
at param (/Users/cmaury/Dropbox/dev/Accessibilityfirst/AsYouWish/node_modules/express/lib/router/index.js:135:11) | |
at pass (/Users/cmaury/Dropbox/dev/Accessibilityfirst/AsYouWish/node_modules/express/lib/router/index.js:142:5) | |
at Router._dispatch (/Users/cmaury/Dropbox/dev/Accessibilityfirst/AsYouWish/node_modules/express/lib/router/index.js:170:5) | |
at Object.router (/Users/cmaury/Dropbox/dev/Accessibilityfirst/AsYouWish/node_modules/express/lib/router/index.js:33:10) | |
at next (/Users/cmaury/Dropbox/dev/Accessibilityfirst/AsYouWish/node_modules/express/node_modules/connect/lib/proto.js:199:15) | |
at resume (/Users/cmaury/Dropbox/dev/Accessibilityfirst/AsYouWish/node_modules/express/node_modules/connect/lib/middleware/static.js:60:7) |
Awesome. Thanks for taking a look. I tried moving the /body tag to include the script, and the error still occurs.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a first cursory look; and first thing I notice, is that the
<script>
tag you calldocument.getElementById('...).play();
in is declared outside of the<body>
tag (at the end). I doubt thats the issue, but I guess its a good place to start.I'll have a good look at the options parsing code just to be sure though. I may have left a document reference lying around.