@acpfx/play-file 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +31 -0
- package/dist/index.js +233 -0
- package/dist/manifest.json +1 -0
- package/package.json +6 -2
- package/CHANGELOG.md +0 -38
- package/src/index.ts +0 -125
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 acpfx contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @acpfx/play-file
|
|
2
|
+
|
|
3
|
+
Writes received audio chunks to a WAV file. Useful for recording pipeline output during testing.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
This package is a pipeline node for [@acpfx/cli](../orchestrator/README.md). See the CLI package for installation and usage.
|
|
8
|
+
|
|
9
|
+
## Manifest
|
|
10
|
+
|
|
11
|
+
- **Consumes:** `audio.chunk`, `control.interrupt`, `lifecycle.done`
|
|
12
|
+
- **Emits:** `lifecycle.ready`, `lifecycle.done`
|
|
13
|
+
|
|
14
|
+
## Settings
|
|
15
|
+
|
|
16
|
+
| Name | Type | Default | Description |
|
|
17
|
+
|------|------|---------|-------------|
|
|
18
|
+
| `path` | string | **(required)** | Output WAV file path |
|
|
19
|
+
|
|
20
|
+
## Pipeline Example
|
|
21
|
+
|
|
22
|
+
```yaml
|
|
23
|
+
nodes:
|
|
24
|
+
output:
|
|
25
|
+
use: "@acpfx/play-file"
|
|
26
|
+
settings: { path: ./output.wav }
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## License
|
|
30
|
+
|
|
31
|
+
ISC
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { createWriteStream } from "node:fs";
|
|
5
|
+
import { open } from "node:fs/promises";
|
|
6
|
+
import { resolve } from "node:path";
|
|
7
|
+
|
|
8
|
+
// ../node-sdk/src/index.ts
|
|
9
|
+
import { createInterface } from "node:readline";
|
|
10
|
+
|
|
11
|
+
// ../core/src/config.ts
|
|
12
|
+
import { parse as parseYaml } from "yaml";
|
|
13
|
+
|
|
14
|
+
// ../core/src/manifest.ts
|
|
15
|
+
import { readFileSync } from "node:fs";
|
|
16
|
+
import { join, dirname } from "node:path";
|
|
17
|
+
import { z as z2 } from "zod";
|
|
18
|
+
|
|
19
|
+
// ../core/src/acpfx-flags.ts
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
var SetupCheckResponseSchema = z.object({
|
|
22
|
+
needed: z.boolean(),
|
|
23
|
+
description: z.string().optional()
|
|
24
|
+
});
|
|
25
|
+
var SetupProgressSchema = z.discriminatedUnion("type", [
|
|
26
|
+
z.object({
|
|
27
|
+
type: z.literal("progress"),
|
|
28
|
+
message: z.string(),
|
|
29
|
+
pct: z.number().optional()
|
|
30
|
+
}),
|
|
31
|
+
z.object({ type: z.literal("complete"), message: z.string() }),
|
|
32
|
+
z.object({ type: z.literal("error"), message: z.string() })
|
|
33
|
+
]);
|
|
34
|
+
var UnsupportedFlagResponseSchema = z.object({
|
|
35
|
+
unsupported: z.boolean(),
|
|
36
|
+
flag: z.string()
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// ../core/src/manifest.ts
|
|
40
|
+
var ArgumentTypeSchema = z2.enum(["string", "number", "boolean"]);
|
|
41
|
+
var ManifestArgumentSchema = z2.object({
|
|
42
|
+
type: ArgumentTypeSchema,
|
|
43
|
+
default: z2.unknown().optional(),
|
|
44
|
+
description: z2.string().optional(),
|
|
45
|
+
required: z2.boolean().optional(),
|
|
46
|
+
enum: z2.array(z2.unknown()).optional()
|
|
47
|
+
});
|
|
48
|
+
var ManifestEnvFieldSchema = z2.object({
|
|
49
|
+
required: z2.boolean().optional(),
|
|
50
|
+
description: z2.string().optional()
|
|
51
|
+
});
|
|
52
|
+
var NodeManifestSchema = z2.object({
|
|
53
|
+
name: z2.string(),
|
|
54
|
+
description: z2.string().optional(),
|
|
55
|
+
consumes: z2.array(z2.string()),
|
|
56
|
+
emits: z2.array(z2.string()),
|
|
57
|
+
arguments: z2.record(z2.string(), ManifestArgumentSchema).optional(),
|
|
58
|
+
additional_arguments: z2.boolean().optional(),
|
|
59
|
+
env: z2.record(z2.string(), ManifestEnvFieldSchema).optional()
|
|
60
|
+
});
|
|
61
|
+
function handleAcpfxFlags(manifestPath) {
|
|
62
|
+
const acpfxFlag = process.argv.find((a) => a.startsWith("--acpfx-"));
|
|
63
|
+
const legacyManifest = process.argv.includes("--manifest");
|
|
64
|
+
if (!acpfxFlag && !legacyManifest) return;
|
|
65
|
+
const flag = acpfxFlag ?? "--acpfx-manifest";
|
|
66
|
+
switch (flag) {
|
|
67
|
+
case "--acpfx-manifest":
|
|
68
|
+
printManifest(manifestPath);
|
|
69
|
+
break;
|
|
70
|
+
case "--acpfx-setup-check":
|
|
71
|
+
process.stdout.write(JSON.stringify({ needed: false }) + "\n");
|
|
72
|
+
process.exit(0);
|
|
73
|
+
break;
|
|
74
|
+
default:
|
|
75
|
+
process.stdout.write(
|
|
76
|
+
JSON.stringify({ unsupported: true, flag }) + "\n"
|
|
77
|
+
);
|
|
78
|
+
process.exit(0);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function handleManifestFlag(manifestPath) {
|
|
82
|
+
handleAcpfxFlags(manifestPath);
|
|
83
|
+
}
|
|
84
|
+
function printManifest(manifestPath) {
|
|
85
|
+
if (!manifestPath) {
|
|
86
|
+
const script = process.argv[1];
|
|
87
|
+
const scriptDir = dirname(script);
|
|
88
|
+
const scriptBase = script.replace(/\.[^.]+$/, "");
|
|
89
|
+
const colocated = `${scriptBase}.manifest.json`;
|
|
90
|
+
try {
|
|
91
|
+
readFileSync(colocated);
|
|
92
|
+
manifestPath = colocated;
|
|
93
|
+
} catch {
|
|
94
|
+
manifestPath = join(scriptDir, "manifest.json");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const content = readFileSync(manifestPath, "utf8");
|
|
99
|
+
process.stdout.write(content.trim() + "\n");
|
|
100
|
+
process.exit(0);
|
|
101
|
+
} catch (err) {
|
|
102
|
+
process.stderr.write(`Failed to read manifest: ${err}
|
|
103
|
+
`);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ../node-sdk/src/index.ts
|
|
109
|
+
var NODE_NAME = process.env.ACPFX_NODE_NAME ?? "unknown";
|
|
110
|
+
function emit(event) {
|
|
111
|
+
process.stdout.write(JSON.stringify(event) + "\n");
|
|
112
|
+
}
|
|
113
|
+
function log(level, message) {
|
|
114
|
+
emit({ type: "log", level, component: NODE_NAME, message });
|
|
115
|
+
}
|
|
116
|
+
log.info = (message) => log("info", message);
|
|
117
|
+
log.warn = (message) => log("warn", message);
|
|
118
|
+
log.error = (message) => log("error", message);
|
|
119
|
+
log.debug = (message) => log("debug", message);
|
|
120
|
+
function onEvent(handler) {
|
|
121
|
+
const rl2 = createInterface({ input: process.stdin });
|
|
122
|
+
rl2.on("line", (line) => {
|
|
123
|
+
if (!line.trim()) return;
|
|
124
|
+
try {
|
|
125
|
+
const event = JSON.parse(line);
|
|
126
|
+
handler(event);
|
|
127
|
+
} catch {
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
return rl2;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// src/index.ts
|
|
134
|
+
handleManifestFlag();
|
|
135
|
+
var settings = JSON.parse(
|
|
136
|
+
process.env.ACPFX_SETTINGS || "{}"
|
|
137
|
+
);
|
|
138
|
+
if (!settings.path) {
|
|
139
|
+
log.error("settings.path is required");
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
var filePath = resolve(settings.path);
|
|
143
|
+
var stream = null;
|
|
144
|
+
var bytesWritten = 0;
|
|
145
|
+
var sampleRate = 16e3;
|
|
146
|
+
var channels = 1;
|
|
147
|
+
var started = false;
|
|
148
|
+
function createWavHeader(dataSize, sr, ch) {
|
|
149
|
+
const bitsPerSample = 16;
|
|
150
|
+
const byteRate = sr * ch * bitsPerSample / 8;
|
|
151
|
+
const blockAlign = ch * bitsPerSample / 8;
|
|
152
|
+
const header = Buffer.alloc(44);
|
|
153
|
+
let off = 0;
|
|
154
|
+
header.write("RIFF", off);
|
|
155
|
+
off += 4;
|
|
156
|
+
header.writeUInt32LE(dataSize + 36, off);
|
|
157
|
+
off += 4;
|
|
158
|
+
header.write("WAVE", off);
|
|
159
|
+
off += 4;
|
|
160
|
+
header.write("fmt ", off);
|
|
161
|
+
off += 4;
|
|
162
|
+
header.writeUInt32LE(16, off);
|
|
163
|
+
off += 4;
|
|
164
|
+
header.writeUInt16LE(1, off);
|
|
165
|
+
off += 2;
|
|
166
|
+
header.writeUInt16LE(ch, off);
|
|
167
|
+
off += 2;
|
|
168
|
+
header.writeUInt32LE(sr, off);
|
|
169
|
+
off += 4;
|
|
170
|
+
header.writeUInt32LE(byteRate, off);
|
|
171
|
+
off += 4;
|
|
172
|
+
header.writeUInt16LE(blockAlign, off);
|
|
173
|
+
off += 2;
|
|
174
|
+
header.writeUInt16LE(bitsPerSample, off);
|
|
175
|
+
off += 2;
|
|
176
|
+
header.write("data", off);
|
|
177
|
+
off += 4;
|
|
178
|
+
header.writeUInt32LE(dataSize, off);
|
|
179
|
+
return header;
|
|
180
|
+
}
|
|
181
|
+
function startWriting() {
|
|
182
|
+
if (started) return;
|
|
183
|
+
started = true;
|
|
184
|
+
stream = createWriteStream(filePath);
|
|
185
|
+
bytesWritten = 0;
|
|
186
|
+
stream.write(Buffer.alloc(44));
|
|
187
|
+
}
|
|
188
|
+
async function finalize() {
|
|
189
|
+
if (!stream) return;
|
|
190
|
+
await new Promise((resolve2, reject) => {
|
|
191
|
+
stream.end(() => resolve2());
|
|
192
|
+
stream.on("error", reject);
|
|
193
|
+
});
|
|
194
|
+
const header = createWavHeader(bytesWritten, sampleRate, channels);
|
|
195
|
+
const fd = await open(filePath, "r+");
|
|
196
|
+
await fd.write(header, 0, header.length, 0);
|
|
197
|
+
await fd.close();
|
|
198
|
+
stream = null;
|
|
199
|
+
}
|
|
200
|
+
emit({ type: "lifecycle.ready", component: "play-file" });
|
|
201
|
+
var rl = onEvent((event) => {
|
|
202
|
+
if (event.type === "audio.chunk") {
|
|
203
|
+
startWriting();
|
|
204
|
+
if (bytesWritten === 0) {
|
|
205
|
+
sampleRate = event.sampleRate ?? 16e3;
|
|
206
|
+
channels = event.channels ?? 1;
|
|
207
|
+
}
|
|
208
|
+
const pcm = Buffer.from(event.data, "base64");
|
|
209
|
+
if (stream?.writable) {
|
|
210
|
+
stream.write(pcm);
|
|
211
|
+
bytesWritten += pcm.length;
|
|
212
|
+
}
|
|
213
|
+
} else if (event.type === "control.interrupt") {
|
|
214
|
+
finalize().then(() => {
|
|
215
|
+
emit({ type: "lifecycle.done", component: "play-file" });
|
|
216
|
+
process.exit(0);
|
|
217
|
+
});
|
|
218
|
+
} else if (event.type === "lifecycle.done") {
|
|
219
|
+
finalize().then(() => {
|
|
220
|
+
emit({ type: "lifecycle.done", component: "play-file" });
|
|
221
|
+
process.exit(0);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
rl.on("close", () => {
|
|
226
|
+
finalize().then(() => {
|
|
227
|
+
emit({ type: "lifecycle.done", component: "play-file" });
|
|
228
|
+
process.exit(0);
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
process.on("SIGTERM", () => {
|
|
232
|
+
finalize().then(() => process.exit(0));
|
|
233
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"play-file","description":"Writes audio chunks to a WAV file","consumes":["audio.chunk","control.interrupt","lifecycle.done"],"emits":["lifecycle.ready","lifecycle.done"],"arguments":{"path":{"type":"string","required":true,"description":"Output WAV file path"}}}
|
package/package.json
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acpfx/play-file",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"acpfx-play-file": "./dist/index.js"
|
|
7
7
|
},
|
|
8
8
|
"main": "./dist/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"manifest.yaml"
|
|
12
|
+
],
|
|
9
13
|
"dependencies": {
|
|
10
14
|
"@acpfx/core": "0.4.0",
|
|
11
15
|
"@acpfx/node-sdk": "0.3.0"
|
|
12
16
|
},
|
|
13
17
|
"scripts": {
|
|
14
|
-
"build": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.js --packages=external"
|
|
18
|
+
"build": "esbuild src/index.ts --bundle --banner:js=\"#!/usr/bin/env node\" --platform=node --format=esm --outfile=dist/index.js --packages=external && node ../../scripts/copy-manifest.js"
|
|
15
19
|
}
|
|
16
20
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# @acpfx/play-file
|
|
2
|
-
|
|
3
|
-
## 0.2.2
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies [0e6838e]
|
|
8
|
-
- @acpfx/core@0.4.0
|
|
9
|
-
- @acpfx/node-sdk@0.3.0
|
|
10
|
-
|
|
11
|
-
## 0.2.1
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
- Updated dependencies [79c6694]
|
|
16
|
-
- Updated dependencies [a0320a1]
|
|
17
|
-
- @acpfx/core@0.3.0
|
|
18
|
-
- @acpfx/node-sdk@0.2.1
|
|
19
|
-
|
|
20
|
-
## 0.2.0
|
|
21
|
-
|
|
22
|
-
### Minor Changes
|
|
23
|
-
|
|
24
|
-
- d757640: Initial release: type-safe contracts, Rust orchestrator, manifest-driven event filtering
|
|
25
|
-
|
|
26
|
-
- Rust schema crate as canonical event type source of truth with codegen to TypeScript + Zod
|
|
27
|
-
- Node manifests (manifest.yaml) declaring consumes/emits contracts
|
|
28
|
-
- Orchestrator event filtering: nodes only receive declared events
|
|
29
|
-
- Rust orchestrator with ratatui TUI (--ui flag)
|
|
30
|
-
- node-sdk with structured logging helpers
|
|
31
|
-
- CI/CD with GitHub Actions and changesets
|
|
32
|
-
- Platform-specific npm packages for Rust binaries (esbuild-style distribution)
|
|
33
|
-
|
|
34
|
-
### Patch Changes
|
|
35
|
-
|
|
36
|
-
- Updated dependencies [d757640]
|
|
37
|
-
- @acpfx/core@0.2.0
|
|
38
|
-
- @acpfx/node-sdk@0.2.0
|
package/src/index.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* play-file node — reads audio.chunk events from stdin and writes a WAV file.
|
|
3
|
-
* Handles control.interrupt by stopping and finalizing the WAV header.
|
|
4
|
-
*
|
|
5
|
-
* Settings (via ACPFX_SETTINGS):
|
|
6
|
-
* path: string — output WAV file path
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { createWriteStream, type WriteStream } from "node:fs";
|
|
10
|
-
import { open } from "node:fs/promises";
|
|
11
|
-
import { resolve } from "node:path";
|
|
12
|
-
import { emit, log, onEvent, handleManifestFlag } from "@acpfx/node-sdk";
|
|
13
|
-
|
|
14
|
-
handleManifestFlag();
|
|
15
|
-
|
|
16
|
-
type Settings = {
|
|
17
|
-
path: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const settings: Settings = JSON.parse(
|
|
21
|
-
process.env.ACPFX_SETTINGS || "{}",
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
if (!settings.path) {
|
|
25
|
-
log.error("settings.path is required");
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const filePath = resolve(settings.path);
|
|
30
|
-
let stream: WriteStream | null = null;
|
|
31
|
-
let bytesWritten = 0;
|
|
32
|
-
let sampleRate = 16000;
|
|
33
|
-
let channels = 1;
|
|
34
|
-
let started = false;
|
|
35
|
-
|
|
36
|
-
function createWavHeader(dataSize: number, sr: number, ch: number): Buffer {
|
|
37
|
-
const bitsPerSample = 16;
|
|
38
|
-
const byteRate = (sr * ch * bitsPerSample) / 8;
|
|
39
|
-
const blockAlign = (ch * bitsPerSample) / 8;
|
|
40
|
-
const header = Buffer.alloc(44);
|
|
41
|
-
let off = 0;
|
|
42
|
-
|
|
43
|
-
header.write("RIFF", off); off += 4;
|
|
44
|
-
header.writeUInt32LE(dataSize + 36, off); off += 4;
|
|
45
|
-
header.write("WAVE", off); off += 4;
|
|
46
|
-
header.write("fmt ", off); off += 4;
|
|
47
|
-
header.writeUInt32LE(16, off); off += 4;
|
|
48
|
-
header.writeUInt16LE(1, off); off += 2;
|
|
49
|
-
header.writeUInt16LE(ch, off); off += 2;
|
|
50
|
-
header.writeUInt32LE(sr, off); off += 4;
|
|
51
|
-
header.writeUInt32LE(byteRate, off); off += 4;
|
|
52
|
-
header.writeUInt16LE(blockAlign, off); off += 2;
|
|
53
|
-
header.writeUInt16LE(bitsPerSample, off); off += 2;
|
|
54
|
-
header.write("data", off); off += 4;
|
|
55
|
-
header.writeUInt32LE(dataSize, off);
|
|
56
|
-
|
|
57
|
-
return header;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function startWriting(): void {
|
|
61
|
-
if (started) return;
|
|
62
|
-
started = true;
|
|
63
|
-
stream = createWriteStream(filePath);
|
|
64
|
-
bytesWritten = 0;
|
|
65
|
-
// Write placeholder WAV header
|
|
66
|
-
stream.write(Buffer.alloc(44));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async function finalize(): Promise<void> {
|
|
70
|
-
if (!stream) return;
|
|
71
|
-
|
|
72
|
-
await new Promise<void>((resolve, reject) => {
|
|
73
|
-
stream!.end(() => resolve());
|
|
74
|
-
stream!.on("error", reject);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Update WAV header with correct sizes
|
|
78
|
-
const header = createWavHeader(bytesWritten, sampleRate, channels);
|
|
79
|
-
const fd = await open(filePath, "r+");
|
|
80
|
-
await fd.write(header, 0, header.length, 0);
|
|
81
|
-
await fd.close();
|
|
82
|
-
|
|
83
|
-
stream = null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Emit lifecycle.ready
|
|
87
|
-
emit({ type: "lifecycle.ready", component: "play-file" });
|
|
88
|
-
|
|
89
|
-
const rl = onEvent((event) => {
|
|
90
|
-
if (event.type === "audio.chunk") {
|
|
91
|
-
startWriting();
|
|
92
|
-
// Capture format from first chunk
|
|
93
|
-
if (bytesWritten === 0) {
|
|
94
|
-
sampleRate = (event.sampleRate as number) ?? 16000;
|
|
95
|
-
channels = (event.channels as number) ?? 1;
|
|
96
|
-
}
|
|
97
|
-
const pcm = Buffer.from(event.data as string, "base64");
|
|
98
|
-
if (stream?.writable) {
|
|
99
|
-
stream.write(pcm);
|
|
100
|
-
bytesWritten += pcm.length;
|
|
101
|
-
}
|
|
102
|
-
} else if (event.type === "control.interrupt") {
|
|
103
|
-
finalize().then(() => {
|
|
104
|
-
emit({ type: "lifecycle.done", component: "play-file" });
|
|
105
|
-
process.exit(0);
|
|
106
|
-
});
|
|
107
|
-
} else if (event.type === "lifecycle.done") {
|
|
108
|
-
finalize().then(() => {
|
|
109
|
-
emit({ type: "lifecycle.done", component: "play-file" });
|
|
110
|
-
process.exit(0);
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
rl.on("close", () => {
|
|
116
|
-
// stdin EOF — finalize and exit
|
|
117
|
-
finalize().then(() => {
|
|
118
|
-
emit({ type: "lifecycle.done", component: "play-file" });
|
|
119
|
-
process.exit(0);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
process.on("SIGTERM", () => {
|
|
124
|
-
finalize().then(() => process.exit(0));
|
|
125
|
-
});
|