Last active
December 2, 2015 11:57
-
-
Save timkock/c9b358e23b954b22d5ac to your computer and use it in GitHub Desktop.
sing.js
This file contains 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
'use strict'; | |
// instructions | |
// 0. save this code to sing.js | |
// 1. npm install request cheerio commander | |
// 2. node sing.js -l http://tinyurl.com/qxmreql -s 50 | |
// dependencies | |
var request = require('request') | |
, cheerio = require('cheerio') | |
, program = require('commander') | |
, exec = require('child_process').exec; | |
// argument interpreter | |
program | |
.version('0.0.1') | |
.option('-l, --lyrics <lyrics>', 'lyrics url') | |
.option('-v, --voice <voice>', 'lyrics url', 'Karen') | |
.option('-s, --speed <speed>', 'speed', '200') | |
.parse(process.argv); | |
// get page, parse and say | |
request(program.lyrics, function (error, response, body) { | |
var $ = cheerio.load(body); | |
exec('say -v '+program.voice+' -r '+program.speed+' "'+$('div#lyrics').html().split('<br>').join('... ')+'"', process.exit); | |
}); |
sudo apt-get install gnustep-gui-runtime
For Ubuntu!
AMAGAD 👍
node sing.js -l http://www.songtexte.com/songtext/ylvis/the-fox-what-does-the-fox-say-6b5e26fe.html -v Karen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
just 4 mac 4 now