Skip to content

Instantly share code, notes, and snippets.

@emersion
Created December 10, 2014 14:24
Show Gist options
  • Save emersion/a28d2ae87ffb45b92784 to your computer and use it in GitHub Desktop.
Save emersion/a28d2ae87ffb45b92784 to your computer and use it in GitHub Desktop.
Youtube to speaker in Node.js
var ytdl = require('ytdl-core');
var fs = require('fs');
var ffmpeg = require('fluent-ffmpeg');
var lame = require('lame');
var Speaker = require('speaker');
var dl = ytdl('http://www.youtube.com/watch?v=A02s8omM_hI', {
filter: function(format) { return format.container === 'mp4'; }
});
var converter = ffmpeg(dl).format('mp3').pipe(new lame.Decoder())
.on('format', function (format) {
this.pipe(new Speaker(format));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment