├── .gitignore ├── client.js ├── package-lock.json ├── package.json └── path └── to └── audio.raw /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | 15 | .env 16 | dist/ 17 | .dockerenv 18 | Dockerfile 19 | -------------------------------------------------------------------------------- /client.js: -------------------------------------------------------------------------------- 1 | const WebSocket = require('ws'); 2 | const fs = require('fs'); 3 | const ws = new WebSocket('wss://us.quantumaisys.com/ws/vonage?tag=VRwj0tYpoI&socket=abcdefg'); 4 | // const ws = new WebSocket('ws://localhost:8080'); 5 | 6 | ws.on('open', () => { 7 | console.log('WebSocket connection opened'); 8 | 9 | const readStream = fs.createReadStream('path/to/audio.raw'); 10 | 11 | readStream.on('data', (data) => { 12 | ws.send(data); 13 | }); 14 | 15 | readStream.on('end', () => { 16 | console.log('Finished streaming audio'); 17 | ws.close(); 18 | }); 19 | }); 20 | 21 | ws.on('close', () => { 22 | console.log('WebSocket connection closed'); 23 | }); -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "audio_stream", 3 | "lockfileVersion": 2, 4 | "requires": true, 5 | "packages": { 6 | "": { 7 | "dependencies": { 8 | "fs": "^0.0.1-security", 9 | "ws": "^8.12.0" 10 | } 11 | }, 12 | "node_modules/fs": { 13 | "version": "0.0.1-security", 14 | "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", 15 | "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" 16 | }, 17 | "node_modules/ws": { 18 | "version": "8.12.0", 19 | "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.0.tgz", 20 | "integrity": "sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig==", 21 | "engines": { 22 | "node": ">=10.0.0" 23 | }, 24 | "peerDependencies": { 25 | "bufferutil": "^4.0.1", 26 | "utf-8-validate": ">=5.0.2" 27 | }, 28 | "peerDependenciesMeta": { 29 | "bufferutil": { 30 | "optional": true 31 | }, 32 | "utf-8-validate": { 33 | "optional": true 34 | } 35 | } 36 | } 37 | }, 38 | "dependencies": { 39 | "fs": { 40 | "version": "0.0.1-security", 41 | "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", 42 | "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" 43 | }, 44 | "ws": { 45 | "version": "8.12.0", 46 | "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.0.tgz", 47 | "integrity": "sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig==", 48 | "requires": {} 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "node client.js" 4 | }, 5 | "dependencies": { 6 | "fs": "^0.0.1-security", 7 | "ws": "^8.12.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /path/to/audio.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtopcoder/audio-stream-websocket/d3bba4bc8175749971af58cbf33f37ebb54d3c3f/path/to/audio.raw --------------------------------------------------------------------------------