@vocasync/astro 0.1.9 → 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/README.md +77 -41
- package/dist/api/client.d.ts +63 -50
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +132 -145
- package/dist/api/client.js.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/cli.js +7 -7
- package/dist/cli.js.map +1 -1
- package/dist/components/AudioPlayer.astro +136 -137
- package/dist/config/schema.d.ts +21 -20
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +15 -4
- package/dist/config/schema.js.map +1 -1
- package/dist/core/audio-map.js +1 -1
- package/dist/core/speech-builder.d.ts +10 -7
- package/dist/core/speech-builder.d.ts.map +1 -1
- package/dist/core/speech-builder.js +73 -168
- package/dist/core/speech-builder.js.map +1 -1
- package/dist/core/spoken-form.d.ts +52 -0
- package/dist/core/spoken-form.d.ts.map +1 -0
- package/dist/core/spoken-form.js +279 -0
- package/dist/core/spoken-form.js.map +1 -0
- package/dist/lib/latex-to-speech/index.d.ts +9 -2
- package/dist/lib/latex-to-speech/index.d.ts.map +1 -1
- package/dist/lib/latex-to-speech/index.js +20 -22
- package/dist/lib/latex-to-speech/index.js.map +1 -1
- package/dist/lib/latex-to-speech/speak.d.ts +13 -0
- package/dist/lib/latex-to-speech/speak.d.ts.map +1 -0
- package/dist/lib/latex-to-speech/speak.js +47 -0
- package/dist/lib/latex-to-speech/speak.js.map +1 -0
- package/dist/rehype/audio-words.d.ts +14 -24
- package/dist/rehype/audio-words.d.ts.map +1 -1
- package/dist/rehype/audio-words.js +131 -252
- package/dist/rehype/audio-words.js.map +1 -1
- package/dist/rehype/index.d.ts +1 -2
- package/dist/rehype/index.d.ts.map +1 -1
- package/dist/rehype/index.js +0 -1
- package/dist/rehype/index.js.map +1 -1
- package/dist/rehype/rehype-math-speech.d.ts +26 -10
- package/dist/rehype/rehype-math-speech.d.ts.map +1 -1
- package/dist/rehype/rehype-math-speech.js +59 -92
- package/dist/rehype/rehype-math-speech.js.map +1 -1
- package/dist/rehype/shared.d.ts +9 -0
- package/dist/rehype/shared.d.ts.map +1 -0
- package/dist/rehype/shared.js +31 -0
- package/dist/rehype/shared.js.map +1 -0
- package/dist/sync/orchestrator.d.ts +4 -22
- package/dist/sync/orchestrator.d.ts.map +1 -1
- package/dist/sync/orchestrator.js +123 -123
- package/dist/sync/orchestrator.js.map +1 -1
- package/dist/types/index.d.ts +82 -46
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +14 -11
- package/src/api/client.ts +175 -190
- package/src/api/index.ts +8 -1
- package/src/cli.ts +7 -14
- package/src/components/AudioPlayer.astro +136 -137
- package/src/config/schema.ts +15 -4
- package/src/core/audio-map.ts +1 -1
- package/src/core/speech-builder.ts +75 -192
- package/src/core/spoken-form.ts +298 -0
- package/src/lib/latex-to-speech/index.ts +32 -22
- package/src/lib/latex-to-speech/speak.ts +55 -0
- package/src/rehype/audio-words.ts +145 -307
- package/src/rehype/index.ts +1 -2
- package/src/rehype/rehype-math-speech.ts +64 -117
- package/src/rehype/shared.ts +36 -0
- package/src/sync/orchestrator.ts +150 -157
- package/src/types/index.ts +85 -47
- package/src/types/modules.d.ts +5 -2
- package/dist/rehype/remark-math-speech.d.ts +0 -13
- package/dist/rehype/remark-math-speech.d.ts.map +0 -1
- package/dist/rehype/remark-math-speech.js +0 -26
- package/dist/rehype/remark-math-speech.js.map +0 -1
- package/src/rehype/remark-math-speech.ts +0 -31
package/src/types/index.ts
CHANGED
|
@@ -13,15 +13,26 @@ export interface ContentItem {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Processed speech document ready for synthesis
|
|
16
|
+
* Processed speech document ready for synthesis + alignment.
|
|
17
|
+
*
|
|
18
|
+
* `speechtext` is POSTed to /synthesis (expanded spoken form, punctuation
|
|
19
|
+
* preserved). `normalisedSpeechtext` is POSTed as the alignment transcript
|
|
20
|
+
* (stripped form) and is the exact token stream the rehype plugin indexes.
|
|
17
21
|
*/
|
|
18
22
|
export interface SpeechDocument {
|
|
19
23
|
/** Unique slug identifier */
|
|
20
24
|
slug: string;
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
+
/** Expanded spoken text for TTS synthesis */
|
|
26
|
+
speechtext: string;
|
|
27
|
+
/** Normalised transcript for alignment (token-for-token with data-i) */
|
|
28
|
+
normalisedSpeechtext: string;
|
|
29
|
+
/**
|
|
30
|
+
* Spoken form of each math expression, keyed by `${'d'|'i'}:${latex}`
|
|
31
|
+
* (d = display/block, i = inline). The rehype plugin reuses these so the
|
|
32
|
+
* math tokens it counts match what was synthesized — math-to-speech runs
|
|
33
|
+
* only here (Node/CLI), never in the Astro/Vite build.
|
|
34
|
+
*/
|
|
35
|
+
mathSpeech: Record<string, string>;
|
|
25
36
|
/** Source file path */
|
|
26
37
|
source: string;
|
|
27
38
|
}
|
|
@@ -39,21 +50,34 @@ export interface AlignedWord {
|
|
|
39
50
|
}
|
|
40
51
|
|
|
41
52
|
/**
|
|
42
|
-
* Audio artifact entry in audio-map.json
|
|
53
|
+
* Audio artifact entry in audio-map.json (v3).
|
|
54
|
+
*
|
|
55
|
+
* The two-POST flow produces TWO projects: a synthesis project (whose
|
|
56
|
+
* stream serves the audio) and an alignment project (used at build time
|
|
57
|
+
* to fetch the word timings, which are embedded here as `words`). Each
|
|
58
|
+
* project has its own publishable key.
|
|
43
59
|
*/
|
|
44
60
|
export interface AudioArtifact {
|
|
45
|
-
/**
|
|
46
|
-
projectUuid: string;
|
|
47
|
-
/** Content hash used for change detection */
|
|
61
|
+
/** Hash of normalisedSpeechtext + resolved voice/language/format */
|
|
48
62
|
contentHash: string;
|
|
63
|
+
/** Resolved synthesis params (also part of change detection) */
|
|
64
|
+
voice: string;
|
|
65
|
+
language: string;
|
|
66
|
+
format: string;
|
|
67
|
+
/** Synthesis project (serves the audio stream) */
|
|
68
|
+
synthesisProjectUuid: string;
|
|
69
|
+
synthesisPublishableKey: string;
|
|
70
|
+
/** Stable audio stream URL (without the publishable key) */
|
|
71
|
+
audioUrl: string;
|
|
72
|
+
/** Alignment project (source of the embedded timings) */
|
|
73
|
+
alignmentProjectUuid: string;
|
|
74
|
+
alignmentPublishableKey: string;
|
|
75
|
+
/** Word timings, indexed positionally by the rehype plugin's data-i */
|
|
76
|
+
words: AlignedWord[];
|
|
49
77
|
/** Total audio duration in seconds */
|
|
50
78
|
duration: number;
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
/** URL to fetch alignment JSON (stable, non-expiring) */
|
|
54
|
-
alignmentUrl: string;
|
|
55
|
-
/** Publishable key for streaming endpoint authentication */
|
|
56
|
-
publishableKey?: string;
|
|
79
|
+
/** Spoken form of each math expression, keyed by `${'d'|'i'}:${latex}`. */
|
|
80
|
+
mathSpeech?: Record<string, string>;
|
|
57
81
|
/** When this artifact was created */
|
|
58
82
|
createdAt: string;
|
|
59
83
|
/** When this artifact was last updated */
|
|
@@ -65,7 +89,7 @@ export interface AudioArtifact {
|
|
|
65
89
|
*/
|
|
66
90
|
export interface AudioMap {
|
|
67
91
|
/** Version of the audio-map schema */
|
|
68
|
-
version: 1 | 2;
|
|
92
|
+
version: 1 | 2 | 3;
|
|
69
93
|
/** When the map was last updated */
|
|
70
94
|
updatedAt: string;
|
|
71
95
|
/** Map of slug -> audio artifact */
|
|
@@ -73,24 +97,55 @@ export interface AudioMap {
|
|
|
73
97
|
}
|
|
74
98
|
|
|
75
99
|
/**
|
|
76
|
-
* VocaSync API synthesis request
|
|
100
|
+
* VocaSync API synthesis request (FormData fields).
|
|
77
101
|
*/
|
|
78
102
|
export interface SynthesisRequest {
|
|
79
103
|
name: string;
|
|
80
104
|
text: string;
|
|
81
105
|
voice: string;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
106
|
+
quality: "sd" | "hd";
|
|
107
|
+
/** ISO 639-1 language code */
|
|
108
|
+
language: string;
|
|
109
|
+
/** Output container: mp3 | aac | opus | flac | wav */
|
|
110
|
+
outputFormat: string;
|
|
86
111
|
}
|
|
87
112
|
|
|
88
113
|
/**
|
|
89
|
-
* VocaSync API synthesis response
|
|
114
|
+
* VocaSync API synthesis response (POST /v1/synthesis).
|
|
90
115
|
*/
|
|
91
116
|
export interface SynthesisResponse {
|
|
92
117
|
projectUuid: string;
|
|
93
|
-
|
|
118
|
+
projectId?: string;
|
|
119
|
+
characterCount?: number;
|
|
120
|
+
status?: JobStatus;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Presigned upload target for one file.
|
|
125
|
+
*/
|
|
126
|
+
export interface PresignTarget {
|
|
127
|
+
key: string;
|
|
128
|
+
uploadUrl: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Response from POST /v1/alignment/presign.
|
|
133
|
+
*/
|
|
134
|
+
export interface AlignmentPresignResponse {
|
|
135
|
+
/** UUID minted for the alignment project; reused in the /alignment POST */
|
|
136
|
+
projectUuid: string;
|
|
137
|
+
audio: PresignTarget;
|
|
138
|
+
transcript: PresignTarget;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Response from POST /v1/alignment (JSON mode).
|
|
143
|
+
*/
|
|
144
|
+
export interface AlignmentSubmitResponse {
|
|
145
|
+
projectUuid: string;
|
|
146
|
+
projectId?: string;
|
|
147
|
+
jobId?: string;
|
|
148
|
+
status?: JobStatus;
|
|
94
149
|
}
|
|
95
150
|
|
|
96
151
|
/**
|
|
@@ -138,23 +193,14 @@ export interface JobResponse {
|
|
|
138
193
|
}
|
|
139
194
|
|
|
140
195
|
/**
|
|
141
|
-
*
|
|
142
|
-
*/
|
|
143
|
-
export interface LinkedAlignmentStatus {
|
|
144
|
-
projectUuid: string;
|
|
145
|
-
status: JobStatus;
|
|
146
|
-
error?: string | null;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Project response from /projects/{uuid} endpoint
|
|
196
|
+
* Project response from GET /v1/projects/{uuid}.
|
|
151
197
|
*/
|
|
152
198
|
export interface ProjectResponse {
|
|
153
199
|
id: string;
|
|
154
200
|
projectUuid: string;
|
|
155
201
|
name: string | null;
|
|
156
202
|
description: string | null;
|
|
157
|
-
projectType: "alignment" | "synthesis";
|
|
203
|
+
projectType: "alignment" | "synthesis" | "transcription" | "translation";
|
|
158
204
|
source: "web" | "api";
|
|
159
205
|
language: string | null;
|
|
160
206
|
status: JobStatus;
|
|
@@ -165,27 +211,19 @@ export interface ProjectResponse {
|
|
|
165
211
|
error: string | null;
|
|
166
212
|
artifacts: ArtifactResponse[];
|
|
167
213
|
latestJob?: JobResponse | null;
|
|
168
|
-
linkedAlignment?: LinkedAlignmentStatus | null;
|
|
169
214
|
}
|
|
170
215
|
|
|
171
216
|
/**
|
|
172
|
-
* Project status (internal representation
|
|
217
|
+
* Project status (internal, single-project representation used by the
|
|
218
|
+
* poller and the `status` CLI command).
|
|
173
219
|
*/
|
|
174
220
|
export interface ProjectStatus {
|
|
175
221
|
uuid: string;
|
|
176
222
|
name: string;
|
|
223
|
+
projectType: ProjectResponse["projectType"];
|
|
177
224
|
status: JobStatus;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
audioUrl?: string;
|
|
181
|
-
duration?: number;
|
|
182
|
-
error?: string;
|
|
183
|
-
};
|
|
184
|
-
alignmentJob?: {
|
|
185
|
-
status: JobStatus;
|
|
186
|
-
alignmentUrl?: string;
|
|
187
|
-
error?: string;
|
|
188
|
-
};
|
|
225
|
+
durationSeconds?: number;
|
|
226
|
+
error?: string;
|
|
189
227
|
}
|
|
190
228
|
|
|
191
229
|
/**
|
package/src/types/modules.d.ts
CHANGED
|
@@ -4,8 +4,11 @@ declare module "speech-rule-engine" {
|
|
|
4
4
|
export function engineReady(): Promise<void>;
|
|
5
5
|
export function setupEngine(options: {
|
|
6
6
|
locale?: string;
|
|
7
|
+
domain?: string;
|
|
7
8
|
modality?: string;
|
|
8
9
|
style?: string;
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
speech?: string;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
export function resetEngine(): void;
|
|
13
|
+
export function toSpeech(mml: string): string;
|
|
11
14
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Root } from "mdast";
|
|
2
|
-
import type { VFile } from "vfile";
|
|
3
|
-
export type MathSpeechEntry = {
|
|
4
|
-
latex: string;
|
|
5
|
-
display: boolean;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Remark plugin that collects all math expressions from markdown.
|
|
9
|
-
* Must run BEFORE remark-math.
|
|
10
|
-
* Stores entries in file.data.mathSpeech for rehypeMathSpeech to consume.
|
|
11
|
-
*/
|
|
12
|
-
export default function remarkMathSpeechCollector(): (tree: Root, file: VFile) => void;
|
|
13
|
-
//# sourceMappingURL=remark-math-speech.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remark-math-speech.d.ts","sourceRoot":"","sources":["../../src/rehype/remark-math-speech.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAEnC,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,KACnB,MAAM,IAAI,EAAE,MAAM,KAAK,UAepD"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { visit } from "unist-util-visit";
|
|
2
|
-
/**
|
|
3
|
-
* Remark plugin that collects all math expressions from markdown.
|
|
4
|
-
* Must run BEFORE remark-math.
|
|
5
|
-
* Stores entries in file.data.mathSpeech for rehypeMathSpeech to consume.
|
|
6
|
-
*/
|
|
7
|
-
export default function remarkMathSpeechCollector() {
|
|
8
|
-
return function transformer(tree, file) {
|
|
9
|
-
const entries = [];
|
|
10
|
-
visit(tree, (node) => {
|
|
11
|
-
if (node.type !== "math" && node.type !== "inlineMath")
|
|
12
|
-
return;
|
|
13
|
-
const latex = String("value" in node ? (node.value ?? "") : "").trim();
|
|
14
|
-
if (!latex)
|
|
15
|
-
return;
|
|
16
|
-
entries.push({
|
|
17
|
-
latex,
|
|
18
|
-
display: node.type === "math",
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
if (entries.length) {
|
|
22
|
-
file.data.mathSpeech = entries;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=remark-math-speech.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remark-math-speech.js","sourceRoot":"","sources":["../../src/rehype/remark-math-speech.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAQzC;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB;IAC/C,OAAO,SAAS,WAAW,CAAC,IAAU,EAAE,IAAW;QACjD,MAAM,OAAO,GAAsB,EAAE,CAAC;QACtC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;YACnB,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY;gBAAE,OAAO;YAC/D,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YACvE,IAAI,CAAC,KAAK;gBAAE,OAAO;YACnB,OAAO,CAAC,IAAI,CAAC;gBACX,KAAK;gBACL,OAAO,EAAE,IAAI,CAAC,IAAI,KAAK,MAAM;aAC9B,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC;QACjC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { Root } from "mdast";
|
|
2
|
-
import { visit } from "unist-util-visit";
|
|
3
|
-
import type { VFile } from "vfile";
|
|
4
|
-
|
|
5
|
-
export type MathSpeechEntry = {
|
|
6
|
-
latex: string;
|
|
7
|
-
display: boolean;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Remark plugin that collects all math expressions from markdown.
|
|
12
|
-
* Must run BEFORE remark-math.
|
|
13
|
-
* Stores entries in file.data.mathSpeech for rehypeMathSpeech to consume.
|
|
14
|
-
*/
|
|
15
|
-
export default function remarkMathSpeechCollector() {
|
|
16
|
-
return function transformer(tree: Root, file: VFile) {
|
|
17
|
-
const entries: MathSpeechEntry[] = [];
|
|
18
|
-
visit(tree, (node) => {
|
|
19
|
-
if (node.type !== "math" && node.type !== "inlineMath") return;
|
|
20
|
-
const latex = String("value" in node ? (node.value ?? "") : "").trim();
|
|
21
|
-
if (!latex) return;
|
|
22
|
-
entries.push({
|
|
23
|
-
latex,
|
|
24
|
-
display: node.type === "math",
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
if (entries.length) {
|
|
28
|
-
file.data.mathSpeech = entries;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|