LoginSignup
0
0

More than 5 years have passed since last update.

Windows の Node.js で音声データを再生する

Posted at

Windows + Node.js なら node-wav-player が簡単。
Windows の場合、.Net のプレイヤー使うらしい。

const player = require('node-wav-player');

class Player {
    /**
     * @return {Promise<ReadableStream>}
     */
    static play(path) {
        return new Promise((resolve, reject) => {
            player.play({path: path}).then(() => {
                resolve();
            }).catch((error) => {
                console.error(error);
                reject(error);
            });
        });
    }
}

module.exports = Player;
const Player = require('./Player');
await Player.play(wavPath);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0