@vocasync/astro 0.1.3 → 0.1.7
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 +32 -27
- package/dist/api/client.d.ts +10 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +11 -0
- package/dist/api/client.js.map +1 -1
- package/dist/cli.js +0 -0
- package/dist/components/AudioPlayer.astro +80 -32
- package/dist/config/schema.d.ts +6 -5
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +16 -7
- package/dist/config/schema.js.map +1 -1
- package/dist/core/audio-map.js +1 -1
- package/dist/rehype/audio-words.d.ts.map +1 -1
- package/dist/rehype/audio-words.js +14 -4
- package/dist/rehype/audio-words.js.map +1 -1
- package/dist/styles/variables.css +3 -20
- package/dist/sync/orchestrator.d.ts.map +1 -1
- package/dist/sync/orchestrator.js +33 -2
- package/dist/sync/orchestrator.js.map +1 -1
- package/dist/types/index.d.ts +12 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -5
- package/src/api/client.ts +15 -0
- package/src/components/AudioPlayer.astro +80 -32
- package/src/config/schema.ts +16 -7
- package/src/core/audio-map.ts +1 -1
- package/src/data/audio-map.example.json +2 -5
- package/src/rehype/audio-words.ts +15 -4
- package/src/styles/variables.css +3 -20
- package/src/sync/orchestrator.ts +39 -2
- package/src/types/index.ts +13 -1
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
margin: 0 -0.0625rem;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
.vocasync-word
|
|
133
|
+
.vocasync-word.is-active {
|
|
134
134
|
background-color: color-mix(
|
|
135
135
|
in oklch,
|
|
136
136
|
var(--vocasync-highlight) calc(var(--vocasync-highlight-active-opacity) * 100%),
|
|
@@ -138,8 +138,8 @@
|
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
/* Trail effect for previous words */
|
|
142
|
-
.vocasync-word
|
|
141
|
+
/* Trail effect for previous words - fading gradient */
|
|
142
|
+
.vocasync-word.is-trail {
|
|
143
143
|
background-color: color-mix(
|
|
144
144
|
in oklch,
|
|
145
145
|
var(--vocasync-highlight) calc(var(--vocasync-highlight-trail-opacity) * 100%),
|
|
@@ -147,23 +147,6 @@
|
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
.vocasync-word[data-trail="2"] {
|
|
151
|
-
background-color: color-mix(
|
|
152
|
-
in oklch,
|
|
153
|
-
var(--vocasync-highlight) calc(var(--vocasync-highlight-trail-opacity) * 50%),
|
|
154
|
-
transparent
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.vocasync-word[data-trail="3"],
|
|
159
|
-
.vocasync-word[data-trail="4"] {
|
|
160
|
-
background-color: color-mix(
|
|
161
|
-
in oklch,
|
|
162
|
-
var(--vocasync-highlight) calc(var(--vocasync-highlight-trail-opacity) * 25%),
|
|
163
|
-
transparent
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
150
|
/* ========================================
|
|
168
151
|
* MATH SPEECH (hidden visually, accessible to highlighter)
|
|
169
152
|
* ======================================== */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/sync/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAKV,WAAW,EAEZ,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,cAAc,EAAoB,MAAM,kBAAkB,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,qCAAqC;IACrC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wBAAwB;IACxB,UAAU,CAAC,EAAE,CA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|
@@ -71,10 +71,37 @@ async function processItem(item, config, client, audioMap, options) {
|
|
|
71
71
|
// Check if content has changed
|
|
72
72
|
const existingEntry = getAudioEntry(audioMap, item.slug);
|
|
73
73
|
const contentChanged = hasChanged(existingEntry?.contentHash, speechDoc.hash);
|
|
74
|
-
if
|
|
74
|
+
// Check if existing entry is missing publishable key (migration from v1)
|
|
75
|
+
const needsPublishableKey = existingEntry && !existingEntry.publishableKey;
|
|
76
|
+
if (!force && !contentChanged && existingEntry && !needsPublishableKey) {
|
|
75
77
|
onProgress(`⏭ ${item.slug} - unchanged`, "info");
|
|
76
78
|
return { slug: item.slug, status: "unchanged" };
|
|
77
79
|
}
|
|
80
|
+
// If only missing publishable key, create it without re-synthesizing
|
|
81
|
+
if (!force && !contentChanged && existingEntry && needsPublishableKey) {
|
|
82
|
+
onProgress(`🔑 ${item.slug} - creating missing publishable key...`, "info");
|
|
83
|
+
if (dryRun) {
|
|
84
|
+
onProgress(`🔍 ${item.slug} - would create publishable key (dry run)`, "info");
|
|
85
|
+
return { slug: item.slug, status: "unchanged" };
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const { publishableKey } = await client.createPublishableKey(existingEntry.projectUuid);
|
|
89
|
+
// Update existing entry with publishable key
|
|
90
|
+
const updatedArtifact = {
|
|
91
|
+
...existingEntry,
|
|
92
|
+
publishableKey,
|
|
93
|
+
updatedAt: new Date().toISOString(),
|
|
94
|
+
};
|
|
95
|
+
setAudioEntry(audioMap, item.slug, updatedArtifact);
|
|
96
|
+
onProgress(`✅ ${item.slug} - publishable key added`, "success");
|
|
97
|
+
return { slug: item.slug, status: "updated", projectUuid: existingEntry.projectUuid };
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
101
|
+
onProgress(`❌ ${item.slug} - failed to create publishable key: ${message}`, "error");
|
|
102
|
+
return { slug: item.slug, status: "error", error: message };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
78
105
|
const status = existingEntry ? "updated" : "new";
|
|
79
106
|
onProgress(`📤 ${item.slug} - ${status}, submitting...`, "info");
|
|
80
107
|
if (dryRun) {
|
|
@@ -103,15 +130,19 @@ async function processItem(item, config, client, audioMap, options) {
|
|
|
103
130
|
throw new Error("No alignment URL returned");
|
|
104
131
|
}
|
|
105
132
|
const alignmentData = await client.getAlignment(finalStatus.alignmentJob.alignmentUrl);
|
|
133
|
+
// Create publishable key for public streaming access
|
|
134
|
+
onProgress(`🔑 ${item.slug} - creating publishable key...`, "info");
|
|
135
|
+
const { publishableKey } = await client.createPublishableKey(response.projectUuid);
|
|
106
136
|
// Get stable streaming URLs
|
|
107
137
|
const streamingUrls = getStreamingUrls(response.projectUuid);
|
|
108
|
-
// Create audio artifact
|
|
138
|
+
// Create audio artifact with publishable key
|
|
109
139
|
const artifact = {
|
|
110
140
|
projectUuid: response.projectUuid,
|
|
111
141
|
contentHash: speechDoc.hash,
|
|
112
142
|
duration: alignmentData.duration,
|
|
113
143
|
audioUrl: streamingUrls.synthesisUrl,
|
|
114
144
|
alignmentUrl: streamingUrls.alignmentUrl,
|
|
145
|
+
publishableKey,
|
|
115
146
|
createdAt: existingEntry?.createdAt || new Date().toISOString(),
|
|
116
147
|
updatedAt: new Date().toISOString(),
|
|
117
148
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../src/sync/orchestrator.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAgBpE;;;;;;;;;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AAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,OAAO,EAAE,oEAAoE;aAC9E,CAAC;QACJ,CAAC;QAED,2BAA2B;QAC3B,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAE5E,OAAO;YACL,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,8BAA8B,KAAK,CAAC,MAAM,6BAA6B,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG;YACxH,OAAO,EAAE,UAAU,CAAC,OAAO;SAC5B,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE,wBAAwB,OAAO,EAAE;SAC3C,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ export interface AudioArtifact {
|
|
|
49
49
|
audioUrl: string;
|
|
50
50
|
/** URL to fetch alignment JSON (stable, non-expiring) */
|
|
51
51
|
alignmentUrl: string;
|
|
52
|
+
/** Publishable key for streaming endpoint authentication */
|
|
53
|
+
publishableKey?: string;
|
|
52
54
|
/** When this artifact was created */
|
|
53
55
|
createdAt: string;
|
|
54
56
|
/** When this artifact was last updated */
|
|
@@ -59,7 +61,7 @@ export interface AudioArtifact {
|
|
|
59
61
|
*/
|
|
60
62
|
export interface AudioMap {
|
|
61
63
|
/** Version of the audio-map schema */
|
|
62
|
-
version: 1;
|
|
64
|
+
version: 1 | 2;
|
|
63
65
|
/** When the map was last updated */
|
|
64
66
|
updatedAt: string;
|
|
65
67
|
/** Map of slug -> audio artifact */
|
|
@@ -84,6 +86,15 @@ export interface SynthesisResponse {
|
|
|
84
86
|
projectUuid: string;
|
|
85
87
|
estimatedCost: number;
|
|
86
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* VocaSync API publishable key response
|
|
91
|
+
*/
|
|
92
|
+
export interface PublishableKeyResponse {
|
|
93
|
+
publishableKey: string;
|
|
94
|
+
projectUuid: string;
|
|
95
|
+
prefix: string;
|
|
96
|
+
createdAt: string;
|
|
97
|
+
}
|
|
87
98
|
/**
|
|
88
99
|
* Job status from VocaSync API
|
|
89
100
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,WAAW,EAAE,MAAM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{
|
|
2
2
|
"name": "@vocasync/astro",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "VocaSync integration for Astro - Text-to-speech synthesis and word-level alignment for static sites",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -24,10 +24,7 @@
|
|
|
24
24
|
"bin": {
|
|
25
25
|
"vocasync": "./dist/cli.js"
|
|
26
26
|
},
|
|
27
|
-
"files": [
|
|
28
|
-
"dist",
|
|
29
|
-
"src"
|
|
30
|
-
],
|
|
27
|
+
"files": ["dist", "src"],
|
|
31
28
|
"scripts": {
|
|
32
29
|
"build": "tsc && cp -r src/components/*.astro dist/components/ && cp -r src/styles dist/",
|
|
33
30
|
"dev": "tsc --watch",
|
package/src/api/client.ts
CHANGED
|
@@ -98,6 +98,21 @@ export class VocaSyncClient {
|
|
|
98
98
|
return (await response.json()) as SynthesisResponse;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Create a publishable key for a project.
|
|
103
|
+
* The publishable key enables public access to project artifacts via stream endpoints.
|
|
104
|
+
*
|
|
105
|
+
* @param projectUuid - The project UUID
|
|
106
|
+
* @returns The publishable key (only returned once at creation)
|
|
107
|
+
*/
|
|
108
|
+
async createPublishableKey(projectUuid: string): Promise<{ publishableKey: string }> {
|
|
109
|
+
const response = await this.request<{ publishableKey: string; projectUuid: string }>(
|
|
110
|
+
"POST",
|
|
111
|
+
`/projects/${projectUuid}/publishable-key`
|
|
112
|
+
);
|
|
113
|
+
return { publishableKey: response.publishableKey };
|
|
114
|
+
}
|
|
115
|
+
|
|
101
116
|
/**
|
|
102
117
|
* Get project status including synthesis and alignment job status.
|
|
103
118
|
*/
|
|
@@ -22,6 +22,7 @@ interface AudioEntry {
|
|
|
22
22
|
alignmentUrl?: string;
|
|
23
23
|
words?: AlignedWord[];
|
|
24
24
|
duration?: number;
|
|
25
|
+
publishableKey?: string;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
interface Props {
|
|
@@ -41,6 +42,8 @@ interface Props {
|
|
|
41
42
|
enableMiniPlayer?: boolean;
|
|
42
43
|
/** Enable word highlighting during playback */
|
|
43
44
|
enableHighlighting?: boolean;
|
|
45
|
+
/** Enable click on words to seek to that position */
|
|
46
|
+
enableClickToSeek?: boolean;
|
|
44
47
|
/** Number of trailing highlighted words */
|
|
45
48
|
trailLength?: number;
|
|
46
49
|
}
|
|
@@ -54,6 +57,7 @@ const {
|
|
|
54
57
|
articleSelector = "[data-article-body]",
|
|
55
58
|
enableMiniPlayer = true,
|
|
56
59
|
enableHighlighting = true,
|
|
60
|
+
enableClickToSeek = true,
|
|
57
61
|
trailLength = 4,
|
|
58
62
|
} = Astro.props;
|
|
59
63
|
|
|
@@ -66,6 +70,7 @@ const audioDataJson = audioEntry ? JSON.stringify({
|
|
|
66
70
|
audioUrl: audioEntry.audioUrl,
|
|
67
71
|
words: audioEntry.words || [],
|
|
68
72
|
duration: audioEntry.duration,
|
|
73
|
+
publishableKey: audioEntry.publishableKey,
|
|
69
74
|
}) : null;
|
|
70
75
|
---
|
|
71
76
|
|
|
@@ -77,6 +82,7 @@ const audioDataJson = audioEntry ? JSON.stringify({
|
|
|
77
82
|
data-article-selector={articleSelector}
|
|
78
83
|
data-enable-mini={enableMiniPlayer}
|
|
79
84
|
data-enable-highlighting={enableHighlighting}
|
|
85
|
+
data-enable-click-to-seek={enableClickToSeek}
|
|
80
86
|
data-trail-length={trailLength}
|
|
81
87
|
aria-label={label}
|
|
82
88
|
tabindex="0"
|
|
@@ -754,9 +760,10 @@ const audioDataJson = audioEntry ? JSON.stringify({
|
|
|
754
760
|
}
|
|
755
761
|
|
|
756
762
|
// Word highlighting state (populated from DOM)
|
|
763
|
+
const EPS = 0.0001; // Epsilon for floating-point comparisons
|
|
757
764
|
let wordEls = [];
|
|
758
|
-
let starts =
|
|
759
|
-
let ends =
|
|
765
|
+
let starts = new Float64Array(0);
|
|
766
|
+
let ends = new Float64Array(0);
|
|
760
767
|
let activeIndex = -1;
|
|
761
768
|
|
|
762
769
|
// Initialize word highlighting from DOM elements
|
|
@@ -767,37 +774,43 @@ const audioDataJson = audioEntry ? JSON.stringify({
|
|
|
767
774
|
wordEls = Array.from(article.querySelectorAll('.vocasync-word[data-start][data-end]'));
|
|
768
775
|
if (!wordEls.length) return false;
|
|
769
776
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
777
|
+
const n = wordEls.length;
|
|
778
|
+
starts = new Float64Array(n);
|
|
779
|
+
ends = new Float64Array(n);
|
|
780
|
+
for (let i = 0; i < n; i++) {
|
|
773
781
|
starts[i] = Number(wordEls[i].dataset.start || '0');
|
|
774
782
|
ends[i] = Number(wordEls[i].dataset.end || '0');
|
|
775
|
-
if (!(ends[i] >= starts[i])) ends[i] = starts[i] +
|
|
783
|
+
if (!(ends[i] >= starts[i])) ends[i] = starts[i] + EPS;
|
|
776
784
|
}
|
|
777
785
|
return true;
|
|
778
786
|
}
|
|
779
787
|
|
|
780
788
|
// Binary search: find index of word for current time
|
|
781
789
|
function idxForTime(t) {
|
|
782
|
-
|
|
783
|
-
|
|
790
|
+
const n = wordEls.length;
|
|
791
|
+
if (!n) return -1;
|
|
792
|
+
let lo = 0, hi = n - 1, ans = 0;
|
|
784
793
|
while (lo <= hi) {
|
|
785
794
|
const mid = (lo + hi) >> 1;
|
|
786
795
|
if (starts[mid] <= t) { ans = mid; lo = mid + 1; } else { hi = mid - 1; }
|
|
787
796
|
}
|
|
788
|
-
if (ans >= 0 && t >= ends[ans] && ans + 1 <
|
|
789
|
-
//
|
|
790
|
-
if (
|
|
797
|
+
if (ans >= 0 && t >= ends[ans] && ans + 1 < n) ans++;
|
|
798
|
+
// Ensure strict containment by adjusting neighbor-wise
|
|
799
|
+
if (t < starts[ans] - EPS && ans > 0) {
|
|
800
|
+
while (ans > 0 && t < starts[ans] - EPS) ans--;
|
|
801
|
+
} else if (t >= ends[ans] + EPS && ans < n - 1) {
|
|
802
|
+
while (ans < n - 1 && t >= ends[ans] + EPS) ans++;
|
|
803
|
+
}
|
|
791
804
|
return ans;
|
|
792
805
|
}
|
|
793
806
|
|
|
794
807
|
// Clear all highlights
|
|
795
808
|
function clearHighlights() {
|
|
796
809
|
if (activeIndex >= 0 && activeIndex < wordEls.length) {
|
|
797
|
-
wordEls[activeIndex].
|
|
810
|
+
wordEls[activeIndex].classList.remove('is-active');
|
|
798
811
|
for (let j = 1; j <= trailLength; j++) {
|
|
799
812
|
const k = activeIndex - j;
|
|
800
|
-
if (k >= 0) wordEls[k].
|
|
813
|
+
if (k >= 0) wordEls[k].classList.remove('is-trail');
|
|
801
814
|
}
|
|
802
815
|
}
|
|
803
816
|
activeIndex = -1;
|
|
@@ -807,18 +820,18 @@ const audioDataJson = audioEntry ? JSON.stringify({
|
|
|
807
820
|
function markActive(i) {
|
|
808
821
|
if (i === activeIndex) return;
|
|
809
822
|
if (activeIndex >= 0 && activeIndex < wordEls.length) {
|
|
810
|
-
wordEls[activeIndex].
|
|
823
|
+
wordEls[activeIndex].classList.remove('is-active');
|
|
811
824
|
for (let j = 1; j <= trailLength; j++) {
|
|
812
825
|
const k = activeIndex - j;
|
|
813
|
-
if (k >= 0) wordEls[k].
|
|
826
|
+
if (k >= 0) wordEls[k].classList.remove('is-trail');
|
|
814
827
|
}
|
|
815
828
|
}
|
|
816
829
|
activeIndex = i;
|
|
817
830
|
if (highlightingEnabled && i >= 0 && i < wordEls.length) {
|
|
818
|
-
wordEls[i].
|
|
831
|
+
wordEls[i].classList.add('is-active');
|
|
819
832
|
for (let j = 1; j <= trailLength; j++) {
|
|
820
833
|
const k = i - j;
|
|
821
|
-
if (k >= 0) wordEls[k].
|
|
834
|
+
if (k >= 0) wordEls[k].classList.add('is-trail');
|
|
822
835
|
}
|
|
823
836
|
}
|
|
824
837
|
}
|
|
@@ -826,29 +839,51 @@ const audioDataJson = audioEntry ? JSON.stringify({
|
|
|
826
839
|
// Update word highlighting based on current time
|
|
827
840
|
function updateHighlighting() {
|
|
828
841
|
if (!wordEls.length) return;
|
|
829
|
-
const t = audio.currentTime;
|
|
830
|
-
|
|
842
|
+
const t = Number(audio.currentTime || 0);
|
|
843
|
+
if (!Number.isFinite(t)) return;
|
|
844
|
+
const i = idxForTime(t + EPS);
|
|
831
845
|
if (i !== activeIndex) {
|
|
832
846
|
markActive(i);
|
|
833
847
|
}
|
|
834
848
|
}
|
|
835
849
|
|
|
836
850
|
// Animation loop for highlighting
|
|
837
|
-
function
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
851
|
+
function highlightTick() {
|
|
852
|
+
if (!highlightingEnabled) return;
|
|
853
|
+
const t = Number(audio.currentTime || 0);
|
|
854
|
+
if (!Number.isFinite(t)) {
|
|
855
|
+
animationFrame = requestAnimationFrame(highlightTick);
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
const i = idxForTime(t + EPS);
|
|
859
|
+
markActive(i);
|
|
860
|
+
if (!audio.paused && !audio.ended) {
|
|
861
|
+
animationFrame = requestAnimationFrame(highlightTick);
|
|
843
862
|
}
|
|
844
|
-
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
function startHighlightLoop() {
|
|
866
|
+
cancelAnimationFrame(animationFrame); // Always cancel first to prevent stacking
|
|
867
|
+
animationFrame = requestAnimationFrame(highlightTick);
|
|
845
868
|
}
|
|
846
869
|
|
|
847
870
|
function stopHighlightLoop() {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
871
|
+
cancelAnimationFrame(animationFrame);
|
|
872
|
+
animationFrame = null;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
// Handle seeking - update highlight immediately
|
|
876
|
+
function onSeeking() {
|
|
877
|
+
if (!highlightingEnabled || !wordEls.length) return;
|
|
878
|
+
const i = idxForTime(Number(audio.currentTime || 0) + EPS);
|
|
879
|
+
if (i >= 0) markActive(i);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
function onSeeked() {
|
|
883
|
+
if (!highlightingEnabled || !wordEls.length) return;
|
|
884
|
+
const i = idxForTime(Number(audio.currentTime || 0) + EPS);
|
|
885
|
+
if (i >= 0) markActive(i);
|
|
886
|
+
if (!audio.paused && !audio.ended) startHighlightLoop();
|
|
852
887
|
}
|
|
853
888
|
|
|
854
889
|
// Toggle highlighting on/off
|
|
@@ -915,6 +950,9 @@ const audioDataJson = audioEntry ? JSON.stringify({
|
|
|
915
950
|
|
|
916
951
|
// Setup click handlers for pre-wrapped words (from rehype plugin)
|
|
917
952
|
function setupWordClickHandlers() {
|
|
953
|
+
const enableClickToSeek = player.dataset.enableClickToSeek === 'true';
|
|
954
|
+
if (!enableClickToSeek) return;
|
|
955
|
+
|
|
918
956
|
const article = document.querySelector(articleSelector);
|
|
919
957
|
if (!article) return;
|
|
920
958
|
|
|
@@ -955,8 +993,14 @@ const audioDataJson = audioEntry ? JSON.stringify({
|
|
|
955
993
|
return;
|
|
956
994
|
}
|
|
957
995
|
|
|
958
|
-
// Set audio source
|
|
959
|
-
|
|
996
|
+
// Set audio source (append publishable key if provided)
|
|
997
|
+
let audioSrc = entry.audioUrl;
|
|
998
|
+
if (entry.publishableKey) {
|
|
999
|
+
const url = new URL(entry.audioUrl);
|
|
1000
|
+
url.searchParams.set('pk', entry.publishableKey);
|
|
1001
|
+
audioSrc = url.toString();
|
|
1002
|
+
}
|
|
1003
|
+
audio.src = audioSrc;
|
|
960
1004
|
|
|
961
1005
|
// Initialize word highlighting from DOM spans (from rehype plugin)
|
|
962
1006
|
// Defer to DOMContentLoaded since the content div comes after the player in the HTML
|
|
@@ -1037,6 +1081,10 @@ const audioDataJson = audioEntry ? JSON.stringify({
|
|
|
1037
1081
|
stopHighlightLoop();
|
|
1038
1082
|
});
|
|
1039
1083
|
|
|
1084
|
+
// Handle seeking for smooth highlight updates
|
|
1085
|
+
audio.addEventListener('seeking', onSeeking);
|
|
1086
|
+
audio.addEventListener('seeked', onSeeked);
|
|
1087
|
+
|
|
1040
1088
|
audio.addEventListener('loadedmetadata', () => {
|
|
1041
1089
|
durationTimeEl.textContent = formatTime(audio.duration);
|
|
1042
1090
|
progressInput.max = audio.duration;
|
package/src/config/schema.ts
CHANGED
|
@@ -19,16 +19,25 @@ export const FormatSchema = z.enum(["mp3", "opus", "aac", "flac"]);
|
|
|
19
19
|
export type Format = z.infer<typeof FormatSchema>;
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* Supported languages for synthesis
|
|
22
|
+
* Supported languages for synthesis + alignment
|
|
23
23
|
* Uses short ISO 639-1 codes as expected by the VocaSync API
|
|
24
|
+
* Only languages where both OpenAI TTS synthesis and MFA forced alignment are available
|
|
24
25
|
*/
|
|
25
26
|
export const LanguageSchema = z.enum([
|
|
26
|
-
"
|
|
27
|
-
"cs",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
27
|
+
"zh",
|
|
28
|
+
"cs",
|
|
29
|
+
"en",
|
|
30
|
+
"fr",
|
|
31
|
+
"de",
|
|
32
|
+
"ja",
|
|
33
|
+
"ko",
|
|
34
|
+
"pl",
|
|
35
|
+
"pt",
|
|
36
|
+
"ru",
|
|
37
|
+
"es",
|
|
38
|
+
"sv",
|
|
39
|
+
"tr",
|
|
40
|
+
"uk",
|
|
32
41
|
]);
|
|
33
42
|
export type Language = z.infer<typeof LanguageSchema>;
|
|
34
43
|
|
package/src/core/audio-map.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version":
|
|
2
|
+
"version": 2,
|
|
3
3
|
"updatedAt": "2024-01-01T00:00:00.000Z",
|
|
4
4
|
"entries": {
|
|
5
5
|
"example-post": {
|
|
@@ -8,10 +8,7 @@
|
|
|
8
8
|
"duration": 125.5,
|
|
9
9
|
"audioUrl": "https://vocasync.io/api/v1/stream/550e8400-e29b-41d4-a716-446655440000/audio.mp3",
|
|
10
10
|
"alignmentUrl": "https://vocasync.io/api/v1/stream/550e8400-e29b-41d4-a716-446655440000/alignment.json",
|
|
11
|
-
"
|
|
12
|
-
{ "word": "Hello", "start": 0.0, "end": 0.35 },
|
|
13
|
-
{ "word": "world", "start": 0.35, "end": 0.75 }
|
|
14
|
-
],
|
|
11
|
+
"publishableKey": "pk_live_xxxxxxxxxxxxxxxxxxxx",
|
|
15
12
|
"createdAt": "2024-01-01T00:00:00.000Z",
|
|
16
13
|
"updatedAt": "2024-01-01T00:00:00.000Z"
|
|
17
14
|
}
|
|
@@ -58,18 +58,29 @@ function loadAudioMapSync(audioMapPath: string): AudioMap | null {
|
|
|
58
58
|
/**
|
|
59
59
|
* Fetch alignment data from URL (synchronously using a worker thread approach).
|
|
60
60
|
* Since rehype plugins must be synchronous, we use a sync HTTP request.
|
|
61
|
+
* @param alignmentUrl - The base alignment URL
|
|
62
|
+
* @param slug - The content slug for caching
|
|
63
|
+
* @param publishableKey - Optional publishable key for authentication
|
|
61
64
|
*/
|
|
62
|
-
function fetchAlignmentSync(alignmentUrl: string, slug: string): AlignedWord[] | null {
|
|
65
|
+
function fetchAlignmentSync(alignmentUrl: string, slug: string, publishableKey?: string): AlignedWord[] | null {
|
|
63
66
|
// Check cache first
|
|
64
67
|
if (alignmentCache.has(slug)) {
|
|
65
68
|
return alignmentCache.get(slug) ?? null;
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
try {
|
|
72
|
+
// Build the URL with publishable key if provided
|
|
73
|
+
let fetchUrl = alignmentUrl;
|
|
74
|
+
if (publishableKey) {
|
|
75
|
+
const url = new URL(alignmentUrl);
|
|
76
|
+
url.searchParams.set("pk", publishableKey);
|
|
77
|
+
fetchUrl = url.toString();
|
|
78
|
+
}
|
|
79
|
+
|
|
69
80
|
// Use sync-fetch or execSync to make a synchronous HTTP request
|
|
70
81
|
// We'll use child_process.execSync with curl as a simple solution
|
|
71
82
|
// Note: -L flag follows redirects (required for vocasync.io signed URLs)
|
|
72
|
-
const result = execSync(`curl -sL "${
|
|
83
|
+
const result = execSync(`curl -sL "${fetchUrl}"`, {
|
|
73
84
|
encoding: "utf-8",
|
|
74
85
|
timeout: 30000,
|
|
75
86
|
});
|
|
@@ -164,8 +175,8 @@ const rehypeAudioWords: Plugin<[RehypeAudioWordsOptions?], Root> = (options = {}
|
|
|
164
175
|
return; // No alignment URL, skip
|
|
165
176
|
}
|
|
166
177
|
|
|
167
|
-
// Fetch alignment words from URL
|
|
168
|
-
const words = fetchAlignmentSync(entry.alignmentUrl, slug);
|
|
178
|
+
// Fetch alignment words from URL with publishable key
|
|
179
|
+
const words = fetchAlignmentSync(entry.alignmentUrl, slug, entry.publishableKey);
|
|
169
180
|
|
|
170
181
|
if (!words || words.length === 0) {
|
|
171
182
|
return; // No alignment data, skip
|
package/src/styles/variables.css
CHANGED
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
margin: 0 -0.0625rem;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
.vocasync-word
|
|
133
|
+
.vocasync-word.is-active {
|
|
134
134
|
background-color: color-mix(
|
|
135
135
|
in oklch,
|
|
136
136
|
var(--vocasync-highlight) calc(var(--vocasync-highlight-active-opacity) * 100%),
|
|
@@ -138,8 +138,8 @@
|
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
/* Trail effect for previous words */
|
|
142
|
-
.vocasync-word
|
|
141
|
+
/* Trail effect for previous words - fading gradient */
|
|
142
|
+
.vocasync-word.is-trail {
|
|
143
143
|
background-color: color-mix(
|
|
144
144
|
in oklch,
|
|
145
145
|
var(--vocasync-highlight) calc(var(--vocasync-highlight-trail-opacity) * 100%),
|
|
@@ -147,23 +147,6 @@
|
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
.vocasync-word[data-trail="2"] {
|
|
151
|
-
background-color: color-mix(
|
|
152
|
-
in oklch,
|
|
153
|
-
var(--vocasync-highlight) calc(var(--vocasync-highlight-trail-opacity) * 50%),
|
|
154
|
-
transparent
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.vocasync-word[data-trail="3"],
|
|
159
|
-
.vocasync-word[data-trail="4"] {
|
|
160
|
-
background-color: color-mix(
|
|
161
|
-
in oklch,
|
|
162
|
-
var(--vocasync-highlight) calc(var(--vocasync-highlight-trail-opacity) * 25%),
|
|
163
|
-
transparent
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
150
|
/* ========================================
|
|
168
151
|
* MATH SPEECH (hidden visually, accessible to highlighter)
|
|
169
152
|
* ======================================== */
|