Skip to main content
100%

Gist 5765711

✓ Published0🌍 Public
Aalessioalex
Last edited Oct 24, 2012
Created on Jun 12, 2013

This example demonstrates a minimal Node.js command-line tool that plays an MP3 audio file through the system’s default audio output. It reads the file from the path given as the second command-line argument, decodes the MP3 stream, and pipes the decoded audio data directly to the speaker. The code uses the `fs.createReadStream` API to read the file, the `lame` decoder to convert MP3 frames into raw PCM audio, and the `Speaker` module to output that PCM data to the sound device. The `on('format')` event provides the audio format required to initialize the speaker correctly.

AI-generated description

Similar vizzes