@scotteza/opencode-spoken-replies 0.0.0-stage → 1.0.0
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 +22 -0
- package/README.md +138 -2
- package/dist/commands/voice-commands.d.ts +41 -0
- package/dist/commands/voice-menu.d.ts +5 -0
- package/dist/commands/voice-picker.d.ts +2 -0
- package/dist/latest/latest-message-store.d.ts +56 -0
- package/dist/messages/message-store.d.ts +18 -0
- package/dist/playback/playback-pipeline.d.ts +52 -0
- package/dist/playback/player-service.d.ts +30 -0
- package/dist/playback/queue.d.ts +112 -0
- package/dist/server-plugin.d.ts +3 -0
- package/dist/server-plugin.js +264 -0
- package/dist/session/idle-controller.d.ts +19 -0
- package/dist/session/question-controller.d.ts +20 -0
- package/dist/session/session-store.d.ts +25 -0
- package/dist/shared/timer-registry.d.ts +12 -0
- package/dist/shared/voice-utils.d.ts +8 -0
- package/dist/state/voice-state-store.d.ts +32 -0
- package/dist/state/voice-status.d.ts +2 -0
- package/dist/streaming/stream-buffer.d.ts +59 -0
- package/dist/streaming/streaming-controller.d.ts +33 -0
- package/dist/system-prompt-injection.d.ts +1 -0
- package/dist/tui-plugin.d.ts +4 -0
- package/dist/tui-plugin.js +3342 -0
- package/dist/voice-audio.d.ts +2 -0
- package/dist/voice-config.d.ts +2 -0
- package/dist/voice-constants.d.ts +7 -0
- package/dist/voice-helper-process.d.ts +26 -0
- package/dist/voice-helper-process.js +615 -0
- package/dist/voice-helper-protocol.d.ts +38 -0
- package/dist/voice-helper-runtime.d.ts +34 -0
- package/dist/voice-kokoro.d.ts +24 -0
- package/dist/voice-log.d.ts +12 -0
- package/dist/voice-rpc.d.ts +57 -0
- package/dist/voice-sanitize.d.ts +23 -0
- package/dist/voice-selection.d.ts +26 -0
- package/dist/voice-speed.d.ts +27 -0
- package/dist/voice-text.d.ts +9 -0
- package/dist/voice-types.d.ts +79 -0
- package/package.json +72 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 semirhuduti
|
|
4
|
+
Copyright (c) 2026 Scott Edwards
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,139 @@
|
|
|
1
|
-
#
|
|
1
|
+
# OpenCode Spoken Replies
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
OpenCode Spoken Replies lets OpenCode read assistant replies aloud as they arrive. Choose a voice, adjust the speed, and pause or replay speech from the terminal interface.
|
|
4
|
+
|
|
5
|
+
This independently maintained fork builds on [opencode-tts-voice](https://github.com/semirhuduti/opencode-tts-voice). It is not maintained, endorsed, or supported by the original author.
|
|
6
|
+
|
|
7
|
+
If you appreciate the original author's work, please [buy Semir Huduti a coffee](https://www.buymeacoffee.com/semirhuduti).
|
|
8
|
+
|
|
9
|
+
[](https://www.buymeacoffee.com/semirhuduti)
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- Listen to assistant replies as they arrive instead of reading the terminal output.
|
|
14
|
+
- Choose and preview a voice, then adjust speaking speed to suit your preference.
|
|
15
|
+
- Pause, resume, replay the latest reply, or revisit earlier replies.
|
|
16
|
+
- Hear OpenCode question prompts aloud; optionally hear completion announcements and direct subagent replies.
|
|
17
|
+
- Turn speech on or off quickly, with the current voice status and speed visible in OpenCode.
|
|
18
|
+
- Speech is generated locally; no cloud speech service or API key is required. The Kokoro model is downloaded on first use.
|
|
19
|
+
|
|
20
|
+
## Install in OpenCode
|
|
21
|
+
|
|
22
|
+
Requirements: OpenCode 2.3.2 or later in the 2.x line, an audio player on your `PATH` (`ffplay`, `mpv`, `paplay`, or `aplay`), and internet access for the initial model download. `mpv` is recommended.
|
|
23
|
+
|
|
24
|
+
**The npm package is not published yet.** After publication, install it globally with:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
opencode plugin add @scotteza/opencode-spoken-replies
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or add it to the `plugins` array in your OpenCode `opencode.json` or `opencode.jsonc`:
|
|
31
|
+
|
|
32
|
+
```jsonc
|
|
33
|
+
{
|
|
34
|
+
"$schema": "https://opencode.ai/config.json",
|
|
35
|
+
"plugins": ["@scotteza/opencode-spoken-replies"]
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Build and use a local checkout
|
|
40
|
+
|
|
41
|
+
To modify the plugin, install Node.js 20.9 or later and Bun 1.3.14 or later, then run these commands from the repository root.
|
|
42
|
+
|
|
43
|
+
On WSL with Ubuntu, install Bun from your WSL terminal (not PowerShell):
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
sudo apt update
|
|
47
|
+
sudo apt install -y curl unzip
|
|
48
|
+
curl -fsSL https://bun.sh/install | bash
|
|
49
|
+
source ~/.bashrc # use ~/.zshrc if your WSL shell is zsh
|
|
50
|
+
bun --version
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
This is Bun's official installer. In WSL, it installs Bun in the Linux environment under `~/.bun` and adds it to your shell path; it does not install Bun for Windows. The version command should report Bun 1.3.14 or later. See the [official Bun installation guide](https://bun.sh/docs/installation) if `bun` is not found or you use a different shell.
|
|
54
|
+
|
|
55
|
+
Use Linux Node.js and npm in WSL too. If `command -v npm` points into `/mnt/c/` (for example, to a Windows Node installation), install Node with Linux `nvm` so npm scripts can find WSL's Bun:
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
|
|
59
|
+
source ~/.bashrc # use ~/.zshrc if your WSL shell is zsh
|
|
60
|
+
nvm install --lts
|
|
61
|
+
nvm alias default 'lts/*'
|
|
62
|
+
nvm use default
|
|
63
|
+
command -v node
|
|
64
|
+
command -v npm
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The `node` and `npm` paths should be inside your WSL home directory, not under `/mnt/c/`. Then install the project dependencies and run the build and tests as shown below.
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
npm install
|
|
71
|
+
npm run build
|
|
72
|
+
npm test
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
To generate and validate a short audio sample, run `npm run test:audio`. The first run may download the Kokoro model. To also play the sample, set `OPENCODE_TTS_TEST_PLAY=1` and have a supported audio player installed.
|
|
76
|
+
|
|
77
|
+
Load the local build by adding its checkout directory (not `dist/`) to an OpenCode config:
|
|
78
|
+
|
|
79
|
+
```jsonc
|
|
80
|
+
{
|
|
81
|
+
"$schema": "https://opencode.ai/config.json",
|
|
82
|
+
"plugins": [
|
|
83
|
+
{
|
|
84
|
+
"package": "/absolute/path/to/opencode-spoken-replies",
|
|
85
|
+
"options": {}
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Restart or reload OpenCode, open a session, and look for the voice status in the footer. Speech is enabled by default. Question prompts in the active session are spoken by default; idle announcements and direct subagent replies are optional and off by default.
|
|
92
|
+
|
|
93
|
+
## Keyboard shortcuts
|
|
94
|
+
|
|
95
|
+
| Shortcut | Action |
|
|
96
|
+
| --- | --- |
|
|
97
|
+
| `F5` | Open assistant-message history. |
|
|
98
|
+
| `F6` | Pause or resume speech; replay the latest reply when idle. |
|
|
99
|
+
| `F7` | Replay the latest reply from the beginning. |
|
|
100
|
+
| `F8` | Turn automatic speech on or off. |
|
|
101
|
+
| `Ctrl+F6` | Slow speech by 0.25x. |
|
|
102
|
+
| `Ctrl+F7` | Speed speech up by 0.25x. |
|
|
103
|
+
| `Ctrl+F9` | Open the voice shortcuts menu. |
|
|
104
|
+
| `Ctrl+O` | Preview the selected voice in the voice picker. |
|
|
105
|
+
| `Enter` | Select a voice or play the selected history entry. |
|
|
106
|
+
| `Shift+Enter` | In history, play the selected entry and later entries. |
|
|
107
|
+
| `Escape` | Close the active picker. |
|
|
108
|
+
|
|
109
|
+
In the history picker, selecting an entry enables speech if it was off. On some keyboards, function keys require holding `Fn`.
|
|
110
|
+
|
|
111
|
+
## Settings
|
|
112
|
+
|
|
113
|
+
Settings go in the plugin entry's `options` object. The defaults are voice `af_heart`, speed `1x`, automatic device selection, question prompts on, idle announcements off, and subagent replies off. Speed ranges from `0.25x` to `5x`; without an explicit speed or voice setting, changes are remembered between launches.
|
|
114
|
+
|
|
115
|
+
For example, to choose a voice and enable completion announcements:
|
|
116
|
+
|
|
117
|
+
```jsonc
|
|
118
|
+
{
|
|
119
|
+
"plugins": [
|
|
120
|
+
{
|
|
121
|
+
"package": "@scotteza/opencode-spoken-replies",
|
|
122
|
+
"options": {
|
|
123
|
+
"voice": "af_heart",
|
|
124
|
+
"speed": 1.25,
|
|
125
|
+
"speakOnIdle": true,
|
|
126
|
+
"idleAnnouncement": "Task completed."
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Feature requests and issues
|
|
134
|
+
|
|
135
|
+
Have an idea or found a problem? [Open an issue](https://github.com/scotteza/opencode-spoken-replies/issues/new) in this repository and describe the request or problem.
|
|
136
|
+
|
|
137
|
+
## Credits and licence
|
|
138
|
+
|
|
139
|
+
This project builds on [opencode-tts-voice](https://github.com/semirhuduti/opencode-tts-voice), created by [Semir Huduti](https://github.com/semirhuduti) and released under the MIT licence. This fork adds substantial changes and is independently maintained by [Scott Edwards](https://github.com/scotteza). The original author does not maintain, endorse, or support this project. See [LICENSE](LICENSE) for the licence text and copyright notices.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { VoiceConfig } from "../voice-types.js";
|
|
2
|
+
import type { LatestMessageStore } from "../latest/latest-message-store.js";
|
|
3
|
+
import type { PlaybackPipeline } from "../playback/playback-pipeline.js";
|
|
4
|
+
import type { SessionStore } from "../session/session-store.js";
|
|
5
|
+
import type { VoiceStateStore } from "../state/voice-state-store.js";
|
|
6
|
+
type Toast = (input: {
|
|
7
|
+
variant: "info" | "success" | "warning" | "error";
|
|
8
|
+
message: string;
|
|
9
|
+
}) => void;
|
|
10
|
+
type HistoryPlaybackMode = "single" | "continue";
|
|
11
|
+
export declare class VoiceCommands {
|
|
12
|
+
private readonly route;
|
|
13
|
+
private readonly config;
|
|
14
|
+
private readonly state;
|
|
15
|
+
private readonly playback;
|
|
16
|
+
private readonly sessionStore;
|
|
17
|
+
private readonly latestStore;
|
|
18
|
+
private readonly toast;
|
|
19
|
+
private readonly log;
|
|
20
|
+
constructor(route: {
|
|
21
|
+
current: {
|
|
22
|
+
name: string;
|
|
23
|
+
params?: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
}, config: VoiceConfig, state: VoiceStateStore, playback: PlaybackPipeline, sessionStore: SessionStore, latestStore: LatestMessageStore, toast: Toast);
|
|
26
|
+
toggleEnabled(): Promise<void>;
|
|
27
|
+
togglePlayback(sessionID?: string): Promise<void>;
|
|
28
|
+
replayLatest(sessionID?: string): Promise<boolean>;
|
|
29
|
+
historyEntries(sessionID?: string): Promise<{
|
|
30
|
+
sessionID: string;
|
|
31
|
+
messageID: string;
|
|
32
|
+
created: number;
|
|
33
|
+
text: string;
|
|
34
|
+
preview: string;
|
|
35
|
+
chronologicalIndex: number;
|
|
36
|
+
}[]>;
|
|
37
|
+
hasHistory(sessionID?: string): Promise<boolean>;
|
|
38
|
+
playHistory(messageID: string, mode: HistoryPlaybackMode, sessionID?: string): Promise<boolean>;
|
|
39
|
+
private activeSessionID;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Context } from "@opencode/plugin/tui/context";
|
|
2
|
+
type VoiceAction = "history" | "pause" | "latest" | "toggle" | "slower" | "faster" | "choose";
|
|
3
|
+
type VoiceActionHandlers = Record<VoiceAction, () => Promise<void>>;
|
|
4
|
+
export declare function openVoiceMenu(api: Pick<Context, "keymap" | "ui">, actions: VoiceActionHandlers, isDisposed: () => boolean): Promise<void>;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Context } from "@opencode/plugin/tui/context";
|
|
2
|
+
import type { VoiceConfig } from "../voice-types.js";
|
|
3
|
+
import type { SessionStore } from "../session/session-store.js";
|
|
4
|
+
export type AssistantHistoryEntry = {
|
|
5
|
+
sessionID: string;
|
|
6
|
+
messageID: string;
|
|
7
|
+
created: number;
|
|
8
|
+
text: string;
|
|
9
|
+
preview: string;
|
|
10
|
+
chronologicalIndex: number;
|
|
11
|
+
};
|
|
12
|
+
export declare class LatestMessageStore {
|
|
13
|
+
private readonly api;
|
|
14
|
+
private readonly config;
|
|
15
|
+
private readonly sessionStore;
|
|
16
|
+
private readonly log;
|
|
17
|
+
private readonly callbacks;
|
|
18
|
+
private readonly cleanup;
|
|
19
|
+
private readonly pending;
|
|
20
|
+
constructor(api: Context, config: VoiceConfig, sessionStore: SessionStore);
|
|
21
|
+
dispose(): void;
|
|
22
|
+
onHistoryChanged(callback: (sessionID: string) => void): () => void;
|
|
23
|
+
refresh(sessionID: string): void;
|
|
24
|
+
private sync;
|
|
25
|
+
replayText(sessionID: string): Promise<{
|
|
26
|
+
text: string | undefined;
|
|
27
|
+
source: "state";
|
|
28
|
+
}>;
|
|
29
|
+
collectDisplayHistory(sessionID: string, limit?: number): Promise<{
|
|
30
|
+
sessionID: string;
|
|
31
|
+
messageID: string;
|
|
32
|
+
created: number;
|
|
33
|
+
text: string;
|
|
34
|
+
preview: string;
|
|
35
|
+
chronologicalIndex: number;
|
|
36
|
+
}[]>;
|
|
37
|
+
collectContinuationHistory(sessionID: string, selectedMessageID: string): Promise<{
|
|
38
|
+
sessionID: string;
|
|
39
|
+
messageID: string;
|
|
40
|
+
created: number;
|
|
41
|
+
text: string;
|
|
42
|
+
preview: string;
|
|
43
|
+
chronologicalIndex: number;
|
|
44
|
+
}[]>;
|
|
45
|
+
hasPlayableHistory(sessionID: string): Promise<boolean>;
|
|
46
|
+
collectPlayableHistory(sessionID: string): Promise<{
|
|
47
|
+
sessionID: string;
|
|
48
|
+
messageID: string;
|
|
49
|
+
created: number;
|
|
50
|
+
text: string;
|
|
51
|
+
preview: string;
|
|
52
|
+
chronologicalIndex: number;
|
|
53
|
+
}[]>;
|
|
54
|
+
private assistantText;
|
|
55
|
+
private notify;
|
|
56
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Context as TuiPluginApi } from "@opencode/plugin/tui/context";
|
|
2
|
+
import type { SessionMessageInfo as Message } from "@opencode/client";
|
|
3
|
+
type MessageUpdatedCallback = (message: Message) => Promise<void> | void;
|
|
4
|
+
export declare class MessageStore {
|
|
5
|
+
private readonly api;
|
|
6
|
+
private readonly log;
|
|
7
|
+
private readonly messages;
|
|
8
|
+
private readonly callbacks;
|
|
9
|
+
private readonly cleanup;
|
|
10
|
+
private disposed;
|
|
11
|
+
constructor(api: TuiPluginApi);
|
|
12
|
+
onUpdated(callback: MessageUpdatedCallback): () => void;
|
|
13
|
+
lookupMessage(sessionID: string, messageID: string): Message | undefined;
|
|
14
|
+
dispose(): void;
|
|
15
|
+
private onMessageUpdated;
|
|
16
|
+
private runEventTask;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { SpeechSource, VoiceConfig } from "../voice-types.js";
|
|
2
|
+
import type { TimerRegistry } from "../shared/timer-registry.js";
|
|
3
|
+
import type { VoiceStateStore } from "../state/voice-state-store.js";
|
|
4
|
+
import { type QueueTrace } from "./queue.js";
|
|
5
|
+
type Toast = (input: {
|
|
6
|
+
variant: "info" | "success" | "warning" | "error";
|
|
7
|
+
message: string;
|
|
8
|
+
}) => void;
|
|
9
|
+
export declare class PlaybackPipeline {
|
|
10
|
+
private readonly config;
|
|
11
|
+
private readonly state;
|
|
12
|
+
private readonly timers;
|
|
13
|
+
private readonly toast;
|
|
14
|
+
private readonly log;
|
|
15
|
+
private readonly runtime;
|
|
16
|
+
private readonly player;
|
|
17
|
+
private readonly queue;
|
|
18
|
+
private currentGenerate?;
|
|
19
|
+
private currentPlay?;
|
|
20
|
+
private queueWake?;
|
|
21
|
+
private playbackWake?;
|
|
22
|
+
private loopStarted;
|
|
23
|
+
private disposed;
|
|
24
|
+
private epoch;
|
|
25
|
+
private lastToastAt;
|
|
26
|
+
constructor(config: VoiceConfig, state: VoiceStateStore, timers: TimerRegistry, toast: Toast);
|
|
27
|
+
start(): void;
|
|
28
|
+
enqueuePreparedChunk(text: string, pauseMs: number, source: SpeechSource, trace?: QueueTrace): number;
|
|
29
|
+
previewVoice(voice: string): void;
|
|
30
|
+
isBusy(): boolean;
|
|
31
|
+
pause(): void;
|
|
32
|
+
resume(): void;
|
|
33
|
+
reset(requeueCurrent: boolean): Promise<void>;
|
|
34
|
+
dispose(): Promise<void>;
|
|
35
|
+
private runGenerationLoop;
|
|
36
|
+
private runPlaybackLoop;
|
|
37
|
+
private takeNextQueueItem;
|
|
38
|
+
private waitForReadyAudioCapacity;
|
|
39
|
+
private takeNextReadyAudio;
|
|
40
|
+
private waitForQueueSignal;
|
|
41
|
+
private waitForPlaybackSignal;
|
|
42
|
+
private notify;
|
|
43
|
+
private syncActivity;
|
|
44
|
+
private collectBufferedSourceItems;
|
|
45
|
+
private isStale;
|
|
46
|
+
private enqueueReadyAudio;
|
|
47
|
+
private createAudioReadyItem;
|
|
48
|
+
private discardReadyAudio;
|
|
49
|
+
private handleRuntimeError;
|
|
50
|
+
private toastError;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
import type { VoiceConfig } from "../voice-types.js";
|
|
3
|
+
import type { TimerRegistry } from "../shared/timer-registry.js";
|
|
4
|
+
import type { VoiceLogger } from "../voice-log.js";
|
|
5
|
+
export type PlayFileTask = {
|
|
6
|
+
id: number;
|
|
7
|
+
interrupted: boolean;
|
|
8
|
+
child?: ChildProcess;
|
|
9
|
+
};
|
|
10
|
+
export declare function toBasePlayer(playerBin: string): string;
|
|
11
|
+
export declare function isMissingBinary(error: unknown): error is NodeJS.ErrnoException;
|
|
12
|
+
export declare function resolveExecutable(playerBin: string): string | undefined;
|
|
13
|
+
export declare function buildPlayerArgs(playerBin: string, args: string[], file: string): string[];
|
|
14
|
+
export declare function describePlayer(playerBin: string): {
|
|
15
|
+
audioPlayer: string;
|
|
16
|
+
backend: string;
|
|
17
|
+
player: string;
|
|
18
|
+
};
|
|
19
|
+
export declare class PlayerService {
|
|
20
|
+
private readonly config;
|
|
21
|
+
private readonly logger;
|
|
22
|
+
private readonly timers;
|
|
23
|
+
private readonly onBackend;
|
|
24
|
+
private resolvedPlayer?;
|
|
25
|
+
constructor(config: VoiceConfig, logger: VoiceLogger, timers: TimerRegistry, onBackend: (backend: string) => void);
|
|
26
|
+
buildArgs(file: string): string[];
|
|
27
|
+
resolvePlayerBin(): string;
|
|
28
|
+
playFile(file: string, current: PlayFileTask): Promise<void>;
|
|
29
|
+
stopChild(child?: ChildProcess): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { SpeechSource, VoiceBlock } from "../voice-types.js";
|
|
2
|
+
export type QueueTrace = {
|
|
3
|
+
origin: string;
|
|
4
|
+
eventSeq?: number;
|
|
5
|
+
sessionID?: string;
|
|
6
|
+
messageID?: string;
|
|
7
|
+
requestID?: string;
|
|
8
|
+
partID?: string;
|
|
9
|
+
block?: Extract<VoiceBlock, "reason" | "message">;
|
|
10
|
+
field?: string;
|
|
11
|
+
startOffset?: number;
|
|
12
|
+
endOffset?: number;
|
|
13
|
+
fullTextLength?: number;
|
|
14
|
+
deltaLength?: number;
|
|
15
|
+
nextTextLength?: number;
|
|
16
|
+
chunkIndex?: number;
|
|
17
|
+
chunkCount?: number;
|
|
18
|
+
questionIndex?: number;
|
|
19
|
+
questionCount?: number;
|
|
20
|
+
messageIndex?: number;
|
|
21
|
+
messageCount?: number;
|
|
22
|
+
restLength?: number;
|
|
23
|
+
finalFlush?: boolean;
|
|
24
|
+
cursorReset?: boolean;
|
|
25
|
+
replaySource?: "cache" | "state";
|
|
26
|
+
replayMode?: "single" | "continue";
|
|
27
|
+
};
|
|
28
|
+
export type QueueItem = {
|
|
29
|
+
id: number;
|
|
30
|
+
epoch: number;
|
|
31
|
+
text: string;
|
|
32
|
+
pauseMs: number;
|
|
33
|
+
source: SpeechSource;
|
|
34
|
+
voice?: string;
|
|
35
|
+
trace?: QueueTrace;
|
|
36
|
+
};
|
|
37
|
+
export type GeneratedAudio = {
|
|
38
|
+
text: string;
|
|
39
|
+
file: string;
|
|
40
|
+
};
|
|
41
|
+
export type ReadyAudioItem = {
|
|
42
|
+
id: number;
|
|
43
|
+
epoch: number;
|
|
44
|
+
sourceItem: QueueItem;
|
|
45
|
+
kind: "audio";
|
|
46
|
+
text: string;
|
|
47
|
+
file: string;
|
|
48
|
+
} | {
|
|
49
|
+
id: number;
|
|
50
|
+
epoch: number;
|
|
51
|
+
sourceItem: QueueItem;
|
|
52
|
+
kind: "pause";
|
|
53
|
+
durationMs: number;
|
|
54
|
+
};
|
|
55
|
+
type RecentChunkTrace = {
|
|
56
|
+
queuedAt: number;
|
|
57
|
+
itemID: number;
|
|
58
|
+
source: SpeechSource;
|
|
59
|
+
epoch: number;
|
|
60
|
+
trace?: QueueTrace;
|
|
61
|
+
preview: string;
|
|
62
|
+
};
|
|
63
|
+
export type PlaybackQueueEvent = {
|
|
64
|
+
type: "enqueued";
|
|
65
|
+
item: QueueItem;
|
|
66
|
+
fingerprint: string;
|
|
67
|
+
duplicate?: RecentChunkTrace;
|
|
68
|
+
} | {
|
|
69
|
+
type: "coalesced";
|
|
70
|
+
item: QueueItem;
|
|
71
|
+
fingerprint: string;
|
|
72
|
+
addedFingerprint: string;
|
|
73
|
+
addedTrace?: QueueTrace;
|
|
74
|
+
} | {
|
|
75
|
+
type: "stream-trimmed";
|
|
76
|
+
queueLength: number;
|
|
77
|
+
maxQueueLength: number;
|
|
78
|
+
};
|
|
79
|
+
export declare class PlaybackQueue {
|
|
80
|
+
readonly sourceItems: QueueItem[];
|
|
81
|
+
readonly readyAudio: ReadyAudioItem[];
|
|
82
|
+
private readonly recentChunkTraces;
|
|
83
|
+
private queueID;
|
|
84
|
+
private readyAudioID;
|
|
85
|
+
enqueuePreparedChunk(text: string, pauseMs: number, source: SpeechSource, epoch: number, maxSpeechChunkChars: number, trace?: QueueTrace, voice?: string): PlaybackQueueEvent[];
|
|
86
|
+
takeSourceItem(): QueueItem | undefined;
|
|
87
|
+
takeReadyAudioItem(): ReadyAudioItem | undefined;
|
|
88
|
+
enqueueReadyAudio(item: ReadyAudioItem): void;
|
|
89
|
+
createPauseReadyAudioItem(sourceItem: QueueItem): ReadyAudioItem;
|
|
90
|
+
createAudioReadyItem(sourceItem: QueueItem, generated: GeneratedAudio): ReadyAudioItem;
|
|
91
|
+
clearSourceItems(): void;
|
|
92
|
+
clearReadyAudio(): ReadyAudioItem[];
|
|
93
|
+
cloneQueueItems(items: QueueItem[], epoch: number): {
|
|
94
|
+
epoch: number;
|
|
95
|
+
id: number;
|
|
96
|
+
text: string;
|
|
97
|
+
pauseMs: number;
|
|
98
|
+
source: SpeechSource;
|
|
99
|
+
voice?: string;
|
|
100
|
+
trace?: QueueTrace;
|
|
101
|
+
}[];
|
|
102
|
+
bufferedAudioCount(): number;
|
|
103
|
+
snapshot(): {
|
|
104
|
+
queueLength: number;
|
|
105
|
+
readyAudioLength: number;
|
|
106
|
+
recentChunkTraceLength: number;
|
|
107
|
+
};
|
|
108
|
+
private coalesceStreamChunk;
|
|
109
|
+
private rememberChunkTrace;
|
|
110
|
+
private trimStreamQueue;
|
|
111
|
+
}
|
|
112
|
+
export {};
|