{"id":14745,"library":"node-red-contrib-play-audio","title":"Node-RED Browser Audio Player","description":"The node-red-contrib-play-audio package (current stable version 2.5.0) provides a Node-RED node designed for playing audio directly within the client-side browser context where the Node-RED dashboard or editor is viewed. It specifically leverages the Web Audio API to play raw audio buffers, making it suitable for integrations with other nodes that output audio data, such as Text-to-Speech (TTS) services (e.g., the Watson Text to Speech node). Additionally, it offers basic browser-native Text-to-Speech capabilities for simple string inputs, provided the browser supports this feature. This node is a key component for adding client-side audio feedback or announcements to Node-RED applications, operating exclusively in the browser environment rather than on the Node.js server. Its release cadence follows contributions and updates to Node-RED compatibility.","status":"active","version":"2.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/lorentzlasson/node-red-contrib-play-audio","tags":["javascript","node-red","audio","TTS","text-to-speech"],"install":[{"cmd":"npm install node-red-contrib-play-audio","lang":"bash","label":"npm"},{"cmd":"yarn add node-red-contrib-play-audio","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-red-contrib-play-audio","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Node-RED nodes are installed via npm into the Node-RED user directory, typically `~/.node-red`, not imported directly into application code. Once installed, the 'Play Audio' node appears in the Node-RED editor palette.","wrong":"import { PlayAudioNode } from 'node-red-contrib-play-audio'","symbol":"node-red-contrib-play-audio","correct":"npm install node-red-contrib-play-audio"}],"quickstart":{"code":"[\n    {\n        \"id\": \"a1b2c3d4e5f6g7h8\",\n        \"type\": \"inject\",\n        \"z\": \"z9y8x7w6v5u4t3s2\",\n        \"name\": \"Trigger TTS\",\n        \"props\": [\n            {\n                \"p\": \"payload\",\n                \"v\": \"Hello from Node-RED!\",\n                \"vt\": \"str\"\n            },\n            {\n                \"p\": \"topic\",\n                \"vt\": \"msg\"\n            }\n        ],\n        \"repeat\": \"\",\n        \"crontab\": \"\",\n        \"once\": true,\n        \"onceDelay\": 0.1,\n        \"topic\": \"\",\n        \"x\": 140,\n        \"y\": 100,\n        \"wires\": [\n            [\n                \"h1g2f3e4d5c6b7a8\"\n            ]\n        ]\n    },\n    {\n        \"id\": \"h1g2f3e4d5c6b7a8\",\n        \"type\": \"play-audio\",\n        \"z\": \"z9y8x7w6v5u4t3s2\",\n        \"name\": \"Play Audio\",\n        \"voice\": \"default\",\n        \"lang\": \"en-US\",\n        \"x\": 340,\n        \"y\": 100,\n        \"wires\": []\n    }\n]","lang":"json","description":"This flow demonstrates installing the node and a basic Text-to-Speech (TTS) example. Install the node via `npm install node-red-contrib-play-audio` in your Node-RED user directory (`~/.node-red`). Then, import this JSON flow, deploy it, and click the 'Trigger TTS' inject node to hear 'Hello from Node-RED!' spoken in your browser."},"warnings":[{"fix":"Ensure the browser tab running Node-RED is open and has focus for audio to play. For server-side audio, a different Node-RED node designed for server OS audio playback is required.","message":"This node performs audio playback exclusively in the client-side browser where the Node-RED editor or dashboard is accessed. It does not play audio on the Node.js server.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Users may need to interact with the browser page (e.g., click a button) before audio can autoplay due to browser policies. Check browser console for Web Audio API related errors or warnings.","message":"Playback relies on the Web Audio API, which may have browser compatibility differences or security restrictions, especially regarding autoplay.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Test TTS output across target browsers. For consistent high-quality speech, consider using an external TTS API service (like IBM Watson, Google Cloud TTS, etc.) that outputs raw audio, and then feed that buffer into this node.","message":"When using the Text-to-Speech (TTS) feature, voice quality and availability are dependent on the client browser's native speech synthesis capabilities, which vary significantly across browsers and operating systems.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Run `npm install node-red-contrib-play-audio` in your Node-RED user directory (typically `~/.node-red`). Restart Node-RED after installation.","cause":"The Node-RED node package was not installed correctly or in the correct directory for Node-RED to discover it.","error":"Error: Cannot find module 'node-red-contrib-play-audio'"},{"fix":"Interact with the browser page (e.g., click an inject button) to satisfy autoplay policies. Ensure your browser is up-to-date and supports the Web Audio API. Keep the Node-RED tab active.","cause":"Browser autoplay policies are blocking the audio, or the browser does not support the Web Audio API, or the browser tab is not active.","error":"Audio not playing in browser / 'Play Audio' node appears green but no sound"},{"fix":"Ensure Node-RED is restarted after `npm install`. Verify you installed the package in the directory where your Node-RED instance is configured to look for nodes (often `~/.node-red`).","cause":"Node-RED was not restarted, or the installation occurred in a different directory than Node-RED's active user directory.","error":"'Play Audio' node missing from palette after installation."}],"ecosystem":"npm"}