@cartanova/qgrid-cli 2.15.4 → 2.15.5
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/bundle/dist/application/qgrid/qgrid.frame.js +18 -8
- package/bundle/dist/application/request-log/request-log.model.js +4 -3
- package/bundle/dist/application/sonamu.generated.js +20 -5
- package/bundle/dist/application/sonamu.generated.sso.js +5 -3
- package/bundle/dist/i18n/sd.generated.js +6 -1
- package/bundle/dist/migrations/20261109110340_alter_request_logs_add1_alter1.js +15 -0
- package/bundle/dist/utils/providers/grok/grok-types.js +1 -1
- package/bundle/dist/utils/providers/grok/grok-voice-client.js +4 -2
- package/bundle/dist/utils/providers/openai/openai-voice-client.js +6 -2
- package/bundle/src/application/qgrid/qgrid.frame.test.ts +37 -0
- package/bundle/src/application/qgrid/qgrid.frame.ts +35 -7
- package/bundle/src/application/request-log/request-log.entity.json +17 -2
- package/bundle/src/application/request-log/request-log.model.test.ts +17 -0
- package/bundle/src/application/request-log/request-log.model.ts +11 -3
- package/bundle/src/application/sonamu.generated.sso.ts +2 -0
- package/bundle/src/application/sonamu.generated.ts +14 -0
- package/bundle/src/i18n/sd.generated.ts +6 -0
- package/bundle/src/migrations/20261109110340_alter_request_logs_add1_alter1.ts +15 -0
- package/bundle/src/utils/providers/grok/grok-types.ts +2 -0
- package/bundle/src/utils/providers/grok/grok-voice-client.test.ts +2 -0
- package/bundle/src/utils/providers/grok/grok-voice-client.ts +2 -0
- package/bundle/src/utils/providers/openai/openai-voice-client.test.ts +6 -0
- package/bundle/src/utils/providers/openai/openai-voice-client.ts +6 -0
- package/bundle/web-dist/client/assets/index-DyrPRt6O.css +1 -0
- package/bundle/web-dist/client/assets/{index-CRdZwZsw.js → index-Wi8Wxte6.js} +34 -34
- package/bundle/web-dist/client/assets/{logs-DyLC_2Rf.js → logs-Bdg3wJV2.js} +1 -1
- package/bundle/web-dist/client/assets/{monit-C0hO3Fy6.js → monit-DcwHRAKu.js} +1 -1
- package/bundle/web-dist/client/assets/{routes-DTw4jsHI.js → routes-lxVC1DDJ.js} +1 -1
- package/bundle/web-dist/client/assets/{settings-Dg-1zSMq.js → settings-C0VCdd1C.js} +1 -1
- package/bundle/web-dist/client/assets/{show-BmqUEs1O.js → show-B7QRPxsY.js} +2 -2
- package/bundle/web-dist/client/assets/{tokens-FQ82u55y.js → tokens-CNRSm9sc.js} +1 -1
- package/bundle/web-dist/client/assets/{use-oauth-login-flow-BXmbUSjc.js → use-oauth-login-flow-eQnMzp8A.js} +1 -1
- package/bundle/web-dist/client/assets/{use-update-token-mutation-BWlMl3qg.js → use-update-token-mutation-KnwyYQjb.js} +1 -1
- package/bundle/web-dist/client/assets/voice-BydIuS0A.js +1 -0
- package/bundle/web-dist/client/index.html +2 -2
- package/bundle/web-dist/client/voice-samples/grok/altair.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/ara.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/atlas.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/aurora.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/carina.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/castor.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/celeste.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/cosmo.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/eve.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/helios.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/helix.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/iris.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/kepler.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/leo.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/liora.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/lumen.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/luna.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/lux.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/naksh.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/orion.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/perseus.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/rex.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/rigel.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/sal.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/sirius.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/ursa.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/zagan.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/grok/zenith.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/openai/alloy.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/openai/ash.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/openai/ballad.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/openai/cedar.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/openai/coral.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/openai/echo.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/openai/marin.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/openai/sage.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/openai/shimmer.mp3 +0 -0
- package/bundle/web-dist/client/voice-samples/openai/verse.mp3 +0 -0
- package/bundle/web-dist/server/assets/link-DrdV092C.js +4919 -0
- package/bundle/web-dist/server/assets/{logs-WZMx5ErO.js → logs-BmBpBe-j.js} +13 -6
- package/bundle/web-dist/server/assets/{monit-Bf6U1Xp5.js → monit-Db1WrIls.js} +2 -2
- package/bundle/web-dist/server/assets/{plus-BwpfWi3W.js → plus-CW9y_K7l.js} +1 -1
- package/bundle/web-dist/server/assets/{refresh-cw-Xk9nLu8E.js → refresh-cw-CRgcH5bT.js} +1 -1
- package/bundle/web-dist/server/assets/{request-model-ByadPBS5.js → request-model-DRF7hmJC.js} +1 -1
- package/bundle/web-dist/server/assets/{routes-WFysbWfc.js → routes-CARZj7or.js} +4 -4
- package/bundle/web-dist/server/assets/{services.generated-Bej_fJ74.js → services.generated-B6QpnL_N.js} +5 -0
- package/bundle/web-dist/server/assets/{settings-DnAbfheS.js → settings-B4jdpP5N.js} +4 -4
- package/bundle/web-dist/server/assets/{show-DvpdOIGn.js → show-D8r2sVK0.js} +17 -9
- package/bundle/web-dist/server/assets/{tokens-CAc4t_kZ.js → tokens-TDQguTdh.js} +5 -5
- package/bundle/web-dist/server/assets/{use-oauth-login-flow-Cxm_7Qg6.js → use-oauth-login-flow-du7pOh_H.js} +1 -1
- package/bundle/web-dist/server/assets/{use-update-token-mutation-DnxqIThp.js → use-update-token-mutation-DA6HiiWS.js} +1 -1
- package/bundle/web-dist/server/assets/voice-C2HfwkGp.js +668 -0
- package/bundle/web-dist/server/entry-server.generated.js +125 -4989
- package/bundle/web-dist/server/voice-samples/grok/altair.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/ara.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/atlas.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/aurora.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/carina.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/castor.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/celeste.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/cosmo.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/eve.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/helios.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/helix.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/iris.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/kepler.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/leo.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/liora.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/lumen.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/luna.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/lux.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/naksh.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/orion.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/perseus.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/rex.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/rigel.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/sal.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/sirius.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/ursa.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/zagan.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/grok/zenith.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/openai/alloy.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/openai/ash.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/openai/ballad.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/openai/cedar.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/openai/coral.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/openai/echo.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/openai/marin.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/openai/sage.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/openai/shimmer.mp3 +0 -0
- package/bundle/web-dist/server/voice-samples/openai/verse.mp3 +0 -0
- package/package.json +1 -1
- package/skills/qgrid/references/request-log-run-lifecycle.md +5 -0
- package/skills/qgrid/references/sonamu-api-web-flow.md +5 -1
- package/bundle/web-dist/client/assets/index-DLo1QCw7.css +0 -1
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
import { J as require_react, Q as __toESM, n as QgridService, q as require_jsx_runtime } from "./services.generated-B6QpnL_N.js";
|
|
2
|
+
import { t as Link } from "./link-DrdV092C.js";
|
|
3
|
+
import { a as ForwardRef$4, o as ForwardRef$5 } from "../entry-server.generated.js";
|
|
4
|
+
//#region ~icons/lucide/external-link.jsx
|
|
5
|
+
var import_react = /* @__PURE__ */ __toESM(require_react());
|
|
6
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
7
|
+
var lucideExternalLink = ({ title, titleId, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
|
|
8
|
+
viewBox: "0 0 24 24",
|
|
9
|
+
width: "1.2em",
|
|
10
|
+
height: "1.2em",
|
|
11
|
+
ref,
|
|
12
|
+
"aria-labelledby": titleId,
|
|
13
|
+
...props,
|
|
14
|
+
children: [title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", {
|
|
15
|
+
id: titleId,
|
|
16
|
+
children: title
|
|
17
|
+
}) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
|
|
18
|
+
fill: "none",
|
|
19
|
+
stroke: "currentColor",
|
|
20
|
+
strokeLinecap: "round",
|
|
21
|
+
strokeLinejoin: "round",
|
|
22
|
+
strokeWidth: 2,
|
|
23
|
+
d: "M15 3h6v6m-11 5L21 3m-3 10v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"
|
|
24
|
+
})]
|
|
25
|
+
});
|
|
26
|
+
var ForwardRef$3 = (0, import_react.forwardRef)(lucideExternalLink);
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region ~icons/lucide/loader-circle.jsx
|
|
29
|
+
var lucideLoaderCircle = ({ title, titleId, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
|
|
30
|
+
viewBox: "0 0 24 24",
|
|
31
|
+
width: "1.2em",
|
|
32
|
+
height: "1.2em",
|
|
33
|
+
ref,
|
|
34
|
+
"aria-labelledby": titleId,
|
|
35
|
+
...props,
|
|
36
|
+
children: [title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", {
|
|
37
|
+
id: titleId,
|
|
38
|
+
children: title
|
|
39
|
+
}) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
|
|
40
|
+
fill: "none",
|
|
41
|
+
stroke: "currentColor",
|
|
42
|
+
strokeLinecap: "round",
|
|
43
|
+
strokeLinejoin: "round",
|
|
44
|
+
strokeWidth: 2,
|
|
45
|
+
d: "M21 12a9 9 0 1 1-6.219-8.56"
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
48
|
+
var ForwardRef$2 = (0, import_react.forwardRef)(lucideLoaderCircle);
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region ~icons/lucide/mic.jsx
|
|
51
|
+
var lucideMic = ({ title, titleId, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
|
|
52
|
+
viewBox: "0 0 24 24",
|
|
53
|
+
width: "1.2em",
|
|
54
|
+
height: "1.2em",
|
|
55
|
+
ref,
|
|
56
|
+
"aria-labelledby": titleId,
|
|
57
|
+
...props,
|
|
58
|
+
children: [title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", {
|
|
59
|
+
id: titleId,
|
|
60
|
+
children: title
|
|
61
|
+
}) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
62
|
+
fill: "none",
|
|
63
|
+
stroke: "currentColor",
|
|
64
|
+
strokeLinecap: "round",
|
|
65
|
+
strokeLinejoin: "round",
|
|
66
|
+
strokeWidth: 2,
|
|
67
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 19v3m7-12v2a7 7 0 0 1-14 0v-2" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", {
|
|
68
|
+
width: 6,
|
|
69
|
+
height: 13,
|
|
70
|
+
x: 9,
|
|
71
|
+
y: 2,
|
|
72
|
+
rx: 3
|
|
73
|
+
})]
|
|
74
|
+
})]
|
|
75
|
+
});
|
|
76
|
+
var ForwardRef$1 = (0, import_react.forwardRef)(lucideMic);
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region ~icons/lucide/play.jsx
|
|
79
|
+
var lucidePlay = ({ title, titleId, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
|
|
80
|
+
viewBox: "0 0 24 24",
|
|
81
|
+
width: "1.2em",
|
|
82
|
+
height: "1.2em",
|
|
83
|
+
ref,
|
|
84
|
+
"aria-labelledby": titleId,
|
|
85
|
+
...props,
|
|
86
|
+
children: [title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", {
|
|
87
|
+
id: titleId,
|
|
88
|
+
children: title
|
|
89
|
+
}) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
|
|
90
|
+
fill: "none",
|
|
91
|
+
stroke: "currentColor",
|
|
92
|
+
strokeLinecap: "round",
|
|
93
|
+
strokeLinejoin: "round",
|
|
94
|
+
strokeWidth: 2,
|
|
95
|
+
d: "M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"
|
|
96
|
+
})]
|
|
97
|
+
});
|
|
98
|
+
var ForwardRef = (0, import_react.forwardRef)(lucidePlay);
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/components/qgrid/voice-audio.ts
|
|
101
|
+
var VOICE_SAMPLE_RATE = 24e3;
|
|
102
|
+
/** Mono PCM16 WAV from float samples in [-1, 1]; out-of-range samples are clipped. */
|
|
103
|
+
function encodeWav(samples, sampleRate = VOICE_SAMPLE_RATE) {
|
|
104
|
+
const out = new Uint8Array(44 + samples.length * 2);
|
|
105
|
+
const view = new DataView(out.buffer);
|
|
106
|
+
const ascii = (offset, text) => {
|
|
107
|
+
for (let i = 0; i < text.length; i++) view.setUint8(offset + i, text.charCodeAt(i));
|
|
108
|
+
};
|
|
109
|
+
ascii(0, "RIFF");
|
|
110
|
+
view.setUint32(4, 36 + samples.length * 2, true);
|
|
111
|
+
ascii(8, "WAVE");
|
|
112
|
+
ascii(12, "fmt ");
|
|
113
|
+
view.setUint32(16, 16, true);
|
|
114
|
+
view.setUint16(20, 1, true);
|
|
115
|
+
view.setUint16(22, 1, true);
|
|
116
|
+
view.setUint32(24, sampleRate, true);
|
|
117
|
+
view.setUint32(28, sampleRate * 2, true);
|
|
118
|
+
view.setUint16(32, 2, true);
|
|
119
|
+
view.setUint16(34, 16, true);
|
|
120
|
+
ascii(36, "data");
|
|
121
|
+
view.setUint32(40, samples.length * 2, true);
|
|
122
|
+
samples.forEach((sample, i) => {
|
|
123
|
+
const clipped = Math.max(-1, Math.min(1, sample));
|
|
124
|
+
view.setInt16(44 + i * 2, clipped < 0 ? clipped * 32768 : clipped * 32767, true);
|
|
125
|
+
});
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
128
|
+
function bytesToBase64(bytes) {
|
|
129
|
+
let binary = "";
|
|
130
|
+
for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
131
|
+
return btoa(binary);
|
|
132
|
+
}
|
|
133
|
+
/** Decodes any browser-playable audio, mixes it to mono at 24 kHz, and returns base64 WAV. */
|
|
134
|
+
async function audioToWavBase64(blob) {
|
|
135
|
+
const context = new AudioContext({ sampleRate: VOICE_SAMPLE_RATE });
|
|
136
|
+
try {
|
|
137
|
+
const buffer = await context.decodeAudioData(await blob.arrayBuffer());
|
|
138
|
+
const mono = new Float32Array(buffer.length);
|
|
139
|
+
for (let channel = 0; channel < buffer.numberOfChannels; channel++) {
|
|
140
|
+
const data = buffer.getChannelData(channel);
|
|
141
|
+
for (let i = 0; i < data.length; i++) mono[i] += data[i] / buffer.numberOfChannels;
|
|
142
|
+
}
|
|
143
|
+
return bytesToBase64(encodeWav(mono));
|
|
144
|
+
} finally {
|
|
145
|
+
await context.close();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/components/qgrid/VoicePlayground.tsx
|
|
150
|
+
var PROJECT_NAME = "qgrid_voice";
|
|
151
|
+
var TTS_MODELS = [
|
|
152
|
+
"grok/grok-tts",
|
|
153
|
+
"openai/gpt-realtime-2.1-mini",
|
|
154
|
+
"openai/gpt-realtime-2.1"
|
|
155
|
+
];
|
|
156
|
+
var STT_MODELS = [
|
|
157
|
+
"openai/gpt-4o-transcribe",
|
|
158
|
+
"openai/gpt-4o-mini-transcribe",
|
|
159
|
+
"grok/grok-voice-transcribe-2.0"
|
|
160
|
+
];
|
|
161
|
+
var OPENAI_VOICES = [
|
|
162
|
+
"marin",
|
|
163
|
+
"cedar",
|
|
164
|
+
"alloy",
|
|
165
|
+
"ash",
|
|
166
|
+
"ballad",
|
|
167
|
+
"coral",
|
|
168
|
+
"echo",
|
|
169
|
+
"sage",
|
|
170
|
+
"shimmer",
|
|
171
|
+
"verse"
|
|
172
|
+
];
|
|
173
|
+
var GROK_VOICE_GROUPS = [{
|
|
174
|
+
label: "Female",
|
|
175
|
+
voices: [
|
|
176
|
+
"ara",
|
|
177
|
+
"aurora",
|
|
178
|
+
"carina",
|
|
179
|
+
"celeste",
|
|
180
|
+
"eve",
|
|
181
|
+
"iris",
|
|
182
|
+
"liora",
|
|
183
|
+
"luna",
|
|
184
|
+
"ursa"
|
|
185
|
+
]
|
|
186
|
+
}, {
|
|
187
|
+
label: "Male",
|
|
188
|
+
voices: [
|
|
189
|
+
"altair",
|
|
190
|
+
"atlas",
|
|
191
|
+
"castor",
|
|
192
|
+
"cosmo",
|
|
193
|
+
"helios",
|
|
194
|
+
"helix",
|
|
195
|
+
"kepler",
|
|
196
|
+
"leo",
|
|
197
|
+
"lumen",
|
|
198
|
+
"lux",
|
|
199
|
+
"naksh",
|
|
200
|
+
"orion",
|
|
201
|
+
"perseus",
|
|
202
|
+
"rex",
|
|
203
|
+
"rigel",
|
|
204
|
+
"sal",
|
|
205
|
+
"sirius",
|
|
206
|
+
"zagan",
|
|
207
|
+
"zenith"
|
|
208
|
+
]
|
|
209
|
+
}];
|
|
210
|
+
var OPENAI_VOICE_GROUPS = [{
|
|
211
|
+
label: "",
|
|
212
|
+
voices: OPENAI_VOICES
|
|
213
|
+
}];
|
|
214
|
+
var isOpenAI = (model) => model.startsWith("openai/");
|
|
215
|
+
var FIELD = "w-full rounded-lg border border-sand-200/80 bg-white px-2.5 py-1.5 text-[12px] text-sand-800 placeholder:text-sand-400 focus:outline-none focus:border-sienna-300 disabled:opacity-50";
|
|
216
|
+
var CONTROL = `${FIELD} h-8`;
|
|
217
|
+
var BUTTON = "px-3.5 py-1.5 text-[12px] font-medium rounded-lg bg-sienna-500 text-white hover:bg-sienna-600 disabled:opacity-50 transition-all duration-150 active:scale-[0.97] inline-flex items-center gap-1.5 shadow-sm";
|
|
218
|
+
function Field({ label, children }) {
|
|
219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
|
|
220
|
+
className: "flex flex-col gap-1",
|
|
221
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
222
|
+
className: "text-[11px] font-medium text-sand-500",
|
|
223
|
+
children: label
|
|
224
|
+
}), children]
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
var shortModel = (model) => model.slice(model.indexOf("/") + 1);
|
|
228
|
+
/**
|
|
229
|
+
* One past result. The request-log link opens a new tab so leaving the playground does not drop
|
|
230
|
+
* the in-memory history.
|
|
231
|
+
*/
|
|
232
|
+
function HistoryRow({ title, meta, requestLogId, onRemove, children }) {
|
|
233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
|
|
234
|
+
className: "flex flex-col gap-1.5 px-4 py-3",
|
|
235
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
236
|
+
className: "flex items-center gap-2 text-[12px]",
|
|
237
|
+
children: [
|
|
238
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
239
|
+
className: "font-medium text-sand-800",
|
|
240
|
+
children: title
|
|
241
|
+
}),
|
|
242
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
243
|
+
className: "tabular-nums text-sand-400",
|
|
244
|
+
children: meta
|
|
245
|
+
}),
|
|
246
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
247
|
+
className: "ml-auto flex items-center gap-2",
|
|
248
|
+
children: [requestLogId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
|
|
249
|
+
to: "/requests/show",
|
|
250
|
+
search: { id: requestLogId },
|
|
251
|
+
target: "_blank",
|
|
252
|
+
className: "inline-flex items-center gap-1 tabular-nums text-sand-500 hover:text-sienna-500",
|
|
253
|
+
children: [
|
|
254
|
+
"request log #",
|
|
255
|
+
requestLogId,
|
|
256
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$3, { className: "size-3" })
|
|
257
|
+
]
|
|
258
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
259
|
+
type: "button",
|
|
260
|
+
onClick: onRemove,
|
|
261
|
+
title: "Remove from history",
|
|
262
|
+
className: "text-sand-300 hover:text-sand-600",
|
|
263
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$4, { className: "size-3.5" })
|
|
264
|
+
})]
|
|
265
|
+
})
|
|
266
|
+
]
|
|
267
|
+
}), children]
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
function History({ empty, children }) {
|
|
271
|
+
return children.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
272
|
+
className: "px-4 py-6 text-center text-[12px] text-sand-400",
|
|
273
|
+
children: empty
|
|
274
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
|
|
275
|
+
className: "divide-y divide-sand-100",
|
|
276
|
+
children
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
function TtsPanel() {
|
|
280
|
+
const [model, setModel] = (0, import_react.useState)(TTS_MODELS[0]);
|
|
281
|
+
const [voice, setVoice] = (0, import_react.useState)("ara");
|
|
282
|
+
const [instructions, setInstructions] = (0, import_react.useState)("");
|
|
283
|
+
const [text, setText] = (0, import_react.useState)("Hi! What did you do this weekend?");
|
|
284
|
+
const [history, setHistory] = (0, import_react.useState)([]);
|
|
285
|
+
const nextKey = (0, import_react.useRef)(0);
|
|
286
|
+
const speak = QgridService.useSpeakMutation();
|
|
287
|
+
const openai = isOpenAI(model);
|
|
288
|
+
const changeModel = (next) => {
|
|
289
|
+
if (isOpenAI(next) !== openai) setVoice(isOpenAI(next) ? OPENAI_VOICES[0] : "ara");
|
|
290
|
+
setModel(next);
|
|
291
|
+
};
|
|
292
|
+
const style = openai && instructions.trim() ? instructions.trim() : void 0;
|
|
293
|
+
const generate = (voiceId) => {
|
|
294
|
+
const startedAt = performance.now();
|
|
295
|
+
const params = {
|
|
296
|
+
model,
|
|
297
|
+
text,
|
|
298
|
+
voice: voiceId,
|
|
299
|
+
projectName: PROJECT_NAME
|
|
300
|
+
};
|
|
301
|
+
if (style) params.instructions = style;
|
|
302
|
+
speak.mutate({ params }, { onSuccess: (out) => {
|
|
303
|
+
const item = {
|
|
304
|
+
key: nextKey.current++,
|
|
305
|
+
src: `data:${out.mimeType};base64,${out.audio}`,
|
|
306
|
+
model,
|
|
307
|
+
voice: voiceId,
|
|
308
|
+
instructions: params.instructions,
|
|
309
|
+
text,
|
|
310
|
+
elapsedMs: performance.now() - startedAt,
|
|
311
|
+
requestLogId: out.requestLogId
|
|
312
|
+
};
|
|
313
|
+
setHistory((items) => [item, ...items]);
|
|
314
|
+
} });
|
|
315
|
+
};
|
|
316
|
+
const sampleRef = (0, import_react.useRef)(null);
|
|
317
|
+
const [playing, setPlaying] = (0, import_react.useState)();
|
|
318
|
+
(0, import_react.useEffect)(() => () => sampleRef.current?.pause(), []);
|
|
319
|
+
const playSample = (voiceId) => {
|
|
320
|
+
setVoice(voiceId);
|
|
321
|
+
sampleRef.current?.pause();
|
|
322
|
+
if (playing === voiceId) {
|
|
323
|
+
setPlaying(void 0);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const audio = new Audio(`/voice-samples/${openai ? "openai" : "grok"}/${voiceId}.mp3`);
|
|
327
|
+
audio.addEventListener("ended", () => setPlaying((current) => current === voiceId ? void 0 : current), { once: true });
|
|
328
|
+
sampleRef.current = audio;
|
|
329
|
+
setPlaying(voiceId);
|
|
330
|
+
audio.play();
|
|
331
|
+
};
|
|
332
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
333
|
+
className: "flex flex-col gap-3 p-4",
|
|
334
|
+
children: [
|
|
335
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
336
|
+
className: "grid grid-cols-2 gap-2",
|
|
337
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
|
|
338
|
+
label: "Model",
|
|
339
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
|
|
340
|
+
value: model,
|
|
341
|
+
onChange: (e) => changeModel(e.target.value),
|
|
342
|
+
className: CONTROL,
|
|
343
|
+
children: TTS_MODELS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
344
|
+
value: m,
|
|
345
|
+
children: m
|
|
346
|
+
}, m))
|
|
347
|
+
})
|
|
348
|
+
}), openai && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
|
|
349
|
+
label: "Style instructions (OpenAI only)",
|
|
350
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
351
|
+
value: instructions,
|
|
352
|
+
onChange: (e) => setInstructions(e.target.value),
|
|
353
|
+
placeholder: "e.g. Speak with a gentle Irish accent.",
|
|
354
|
+
className: CONTROL
|
|
355
|
+
})
|
|
356
|
+
})]
|
|
357
|
+
}),
|
|
358
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
359
|
+
className: "flex flex-col gap-1.5",
|
|
360
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
361
|
+
className: "text-[11px] font-medium text-sand-500",
|
|
362
|
+
children: "Voice — ▶ plays a short self-introduction sample, a name selects it"
|
|
363
|
+
}), (openai ? OPENAI_VOICE_GROUPS : GROK_VOICE_GROUPS).map((group) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
364
|
+
className: "flex items-start gap-2",
|
|
365
|
+
children: [group.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
366
|
+
className: "w-12 shrink-0 pt-1 text-[11px] text-sand-400",
|
|
367
|
+
children: group.label
|
|
368
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
369
|
+
className: "flex flex-wrap gap-1.5",
|
|
370
|
+
children: group.voices.map((v) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
371
|
+
className: `inline-flex items-center overflow-hidden rounded-full border text-[12px] ${voice === v ? "border-sienna-400 bg-sienna-50 text-sienna-700" : "border-sand-200/80 bg-white text-sand-700"}`,
|
|
372
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
373
|
+
type: "button",
|
|
374
|
+
onClick: () => setVoice(v),
|
|
375
|
+
"aria-pressed": voice === v,
|
|
376
|
+
className: "py-0.5 pl-2.5 pr-1 hover:text-sienna-600",
|
|
377
|
+
children: v
|
|
378
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
379
|
+
type: "button",
|
|
380
|
+
onClick: () => playSample(v),
|
|
381
|
+
title: playing === v ? `Stop "${v}"` : `Play a "${v}" sample`,
|
|
382
|
+
className: `py-1 pl-1 pr-2 hover:text-sienna-500 ${playing === v ? "text-sienna-500" : "text-sand-400"}`,
|
|
383
|
+
children: playing === v ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$5, { className: "size-3" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef, { className: "size-3" })
|
|
384
|
+
})]
|
|
385
|
+
}, v))
|
|
386
|
+
})]
|
|
387
|
+
}, group.label))]
|
|
388
|
+
}),
|
|
389
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
|
|
390
|
+
label: "Text",
|
|
391
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
|
|
392
|
+
value: text,
|
|
393
|
+
onChange: (e) => setText(e.target.value),
|
|
394
|
+
rows: 3,
|
|
395
|
+
className: `${FIELD} resize-y`
|
|
396
|
+
})
|
|
397
|
+
}),
|
|
398
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
399
|
+
className: "flex items-center gap-3",
|
|
400
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
401
|
+
type: "button",
|
|
402
|
+
onClick: () => generate(voice),
|
|
403
|
+
disabled: speak.isPending || !text.trim(),
|
|
404
|
+
className: BUTTON,
|
|
405
|
+
children: [
|
|
406
|
+
speak.isPending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$2, { className: "size-3.5 animate-spin" }),
|
|
407
|
+
"Generate with ",
|
|
408
|
+
voice
|
|
409
|
+
]
|
|
410
|
+
}), speak.isError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
411
|
+
className: "text-[12px] text-danger-500 break-words",
|
|
412
|
+
children: speak.error?.message
|
|
413
|
+
})]
|
|
414
|
+
})
|
|
415
|
+
]
|
|
416
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
417
|
+
className: "border-t border-sand-100",
|
|
418
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(History, {
|
|
419
|
+
empty: "Generated clips stack here, newest first, so voices can be compared side by side.",
|
|
420
|
+
children: history.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(HistoryRow, {
|
|
421
|
+
title: `${item.voice} · ${shortModel(item.model)}`,
|
|
422
|
+
meta: `${(item.elapsedMs / 1e3).toFixed(1)}s`,
|
|
423
|
+
requestLogId: item.requestLogId,
|
|
424
|
+
onRemove: () => setHistory((items) => items.filter((i) => i.key !== item.key)),
|
|
425
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
|
|
426
|
+
className: "truncate text-[12px] text-sand-600",
|
|
427
|
+
title: item.text,
|
|
428
|
+
children: [item.text, item.instructions && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
429
|
+
className: "text-sand-400",
|
|
430
|
+
children: [" — ", item.instructions]
|
|
431
|
+
})]
|
|
432
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("audio", {
|
|
433
|
+
controls: true,
|
|
434
|
+
autoPlay: true,
|
|
435
|
+
src: item.src,
|
|
436
|
+
className: "h-8 w-full"
|
|
437
|
+
})]
|
|
438
|
+
}, item.key))
|
|
439
|
+
})
|
|
440
|
+
})] });
|
|
441
|
+
}
|
|
442
|
+
function SttPanel() {
|
|
443
|
+
const [model, setModel] = (0, import_react.useState)(STT_MODELS[0]);
|
|
444
|
+
const [prompt, setPrompt] = (0, import_react.useState)("");
|
|
445
|
+
const [audio, setAudio] = (0, import_react.useState)();
|
|
446
|
+
const [recording, setRecording] = (0, import_react.useState)(false);
|
|
447
|
+
const [audioError, setAudioError] = (0, import_react.useState)();
|
|
448
|
+
const [history, setHistory] = (0, import_react.useState)([]);
|
|
449
|
+
const recorderRef = (0, import_react.useRef)(null);
|
|
450
|
+
const clipUrls = (0, import_react.useRef)([]);
|
|
451
|
+
const nextKey = (0, import_react.useRef)(0);
|
|
452
|
+
const transcribe = QgridService.useTranscribeMutation();
|
|
453
|
+
const openai = isOpenAI(model);
|
|
454
|
+
(0, import_react.useEffect)(() => () => {
|
|
455
|
+
recorderRef.current?.stream.getTracks().forEach((track) => track.stop());
|
|
456
|
+
clipUrls.current.forEach((url) => URL.revokeObjectURL(url));
|
|
457
|
+
}, []);
|
|
458
|
+
const takeAudio = (blob) => {
|
|
459
|
+
const url = URL.createObjectURL(blob);
|
|
460
|
+
clipUrls.current.push(url);
|
|
461
|
+
setAudio({
|
|
462
|
+
blob,
|
|
463
|
+
url,
|
|
464
|
+
clip: clipUrls.current.length
|
|
465
|
+
});
|
|
466
|
+
};
|
|
467
|
+
const toggleRecording = async () => {
|
|
468
|
+
if (recording) {
|
|
469
|
+
recorderRef.current?.stop();
|
|
470
|
+
setRecording(false);
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
setAudioError(void 0);
|
|
474
|
+
try {
|
|
475
|
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
476
|
+
const recorder = new MediaRecorder(stream);
|
|
477
|
+
const chunks = [];
|
|
478
|
+
recorder.ondataavailable = (e) => chunks.push(e.data);
|
|
479
|
+
recorder.onstop = () => {
|
|
480
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
481
|
+
takeAudio(new Blob(chunks, { type: recorder.mimeType }));
|
|
482
|
+
};
|
|
483
|
+
recorder.start();
|
|
484
|
+
recorderRef.current = recorder;
|
|
485
|
+
setRecording(true);
|
|
486
|
+
} catch (error) {
|
|
487
|
+
setAudioError(error instanceof Error ? error.message : String(error));
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
const submit = async () => {
|
|
491
|
+
if (!audio) return;
|
|
492
|
+
setAudioError(void 0);
|
|
493
|
+
let wav;
|
|
494
|
+
try {
|
|
495
|
+
wav = await audioToWavBase64(audio.blob);
|
|
496
|
+
} catch (error) {
|
|
497
|
+
setAudioError(`could not decode audio: ${error instanceof Error ? error.message : String(error)}`);
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
const params = {
|
|
501
|
+
model,
|
|
502
|
+
audio: wav,
|
|
503
|
+
mediaType: "audio/wav",
|
|
504
|
+
projectName: PROJECT_NAME
|
|
505
|
+
};
|
|
506
|
+
if (openai && prompt.trim()) params.prompt = prompt.trim();
|
|
507
|
+
const startedAt = performance.now();
|
|
508
|
+
transcribe.mutate({ params }, { onSuccess: (out) => {
|
|
509
|
+
const item = {
|
|
510
|
+
key: nextKey.current++,
|
|
511
|
+
clip: audio.clip,
|
|
512
|
+
clipUrl: audio.url,
|
|
513
|
+
model,
|
|
514
|
+
prompt: params.prompt,
|
|
515
|
+
text: out.text,
|
|
516
|
+
elapsedMs: performance.now() - startedAt,
|
|
517
|
+
durationSec: out.durationSec,
|
|
518
|
+
requestLogId: out.requestLogId
|
|
519
|
+
};
|
|
520
|
+
setHistory((items) => [item, ...items]);
|
|
521
|
+
} });
|
|
522
|
+
};
|
|
523
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
524
|
+
className: "flex flex-col gap-3 p-4",
|
|
525
|
+
children: [
|
|
526
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
527
|
+
className: "grid grid-cols-2 gap-2",
|
|
528
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
|
|
529
|
+
label: "Model",
|
|
530
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
|
|
531
|
+
value: model,
|
|
532
|
+
onChange: (e) => setModel(e.target.value),
|
|
533
|
+
className: CONTROL,
|
|
534
|
+
children: STT_MODELS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
535
|
+
value: m,
|
|
536
|
+
children: m
|
|
537
|
+
}, m))
|
|
538
|
+
})
|
|
539
|
+
}), openai && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
|
|
540
|
+
label: "Prompt (OpenAI only)",
|
|
541
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
542
|
+
value: prompt,
|
|
543
|
+
onChange: (e) => setPrompt(e.target.value),
|
|
544
|
+
placeholder: "domain words, e.g. qgrid, Kuma",
|
|
545
|
+
className: CONTROL
|
|
546
|
+
})
|
|
547
|
+
})]
|
|
548
|
+
}),
|
|
549
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
550
|
+
className: "flex flex-wrap items-center gap-2",
|
|
551
|
+
children: [
|
|
552
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
553
|
+
type: "button",
|
|
554
|
+
onClick: toggleRecording,
|
|
555
|
+
className: `${BUTTON} ${recording ? "bg-danger-500 hover:bg-danger-500" : ""}`,
|
|
556
|
+
children: [recording ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$5, { className: "size-3.5" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$1, { className: "size-3.5" }), recording ? "Stop" : "Record"]
|
|
557
|
+
}),
|
|
558
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
|
|
559
|
+
className: "text-[12px] text-sand-600 cursor-pointer hover:text-sienna-500",
|
|
560
|
+
children: ["or upload a file", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
561
|
+
type: "file",
|
|
562
|
+
accept: "audio/*",
|
|
563
|
+
className: "hidden",
|
|
564
|
+
onChange: (e) => {
|
|
565
|
+
const file = e.target.files?.[0];
|
|
566
|
+
if (file) takeAudio(file);
|
|
567
|
+
}
|
|
568
|
+
})]
|
|
569
|
+
}),
|
|
570
|
+
audioError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
571
|
+
className: "text-[12px] text-danger-500 break-words",
|
|
572
|
+
children: audioError
|
|
573
|
+
})
|
|
574
|
+
]
|
|
575
|
+
}),
|
|
576
|
+
audio && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
577
|
+
className: "flex items-center gap-2",
|
|
578
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
579
|
+
className: "shrink-0 text-[11px] font-medium text-sand-500",
|
|
580
|
+
children: ["clip ", audio.clip]
|
|
581
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("audio", {
|
|
582
|
+
controls: true,
|
|
583
|
+
src: audio.url,
|
|
584
|
+
className: "h-8 w-full"
|
|
585
|
+
})]
|
|
586
|
+
}),
|
|
587
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
588
|
+
className: "flex items-center gap-3",
|
|
589
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
590
|
+
type: "button",
|
|
591
|
+
onClick: submit,
|
|
592
|
+
disabled: !audio || recording || transcribe.isPending,
|
|
593
|
+
className: BUTTON,
|
|
594
|
+
children: [transcribe.isPending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$2, { className: "size-3.5 animate-spin" }), "Transcribe"]
|
|
595
|
+
}), transcribe.isError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
596
|
+
className: "text-[12px] text-danger-500 break-words",
|
|
597
|
+
children: transcribe.error?.message
|
|
598
|
+
})]
|
|
599
|
+
})
|
|
600
|
+
]
|
|
601
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
602
|
+
className: "border-t border-sand-100",
|
|
603
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(History, {
|
|
604
|
+
empty: "Transcripts stack here, newest first; run one clip through several models to compare.",
|
|
605
|
+
children: history.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HistoryRow, {
|
|
606
|
+
title: `clip ${item.clip} · ${shortModel(item.model)}`,
|
|
607
|
+
meta: [
|
|
608
|
+
`${(item.elapsedMs / 1e3).toFixed(1)}s`,
|
|
609
|
+
item.durationSec !== void 0 ? `${item.durationSec.toFixed(1)}s audio` : "",
|
|
610
|
+
item.prompt ? `prompt: ${item.prompt}` : ""
|
|
611
|
+
].filter(Boolean).join(" · "),
|
|
612
|
+
requestLogId: item.requestLogId,
|
|
613
|
+
onRemove: () => setHistory((items) => items.filter((i) => i.key !== item.key)),
|
|
614
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
615
|
+
className: "rounded-lg bg-sand-50 px-3 py-2 text-[13px] text-sand-800 whitespace-pre-wrap",
|
|
616
|
+
children: item.text || "(empty transcript)"
|
|
617
|
+
})
|
|
618
|
+
}, item.key))
|
|
619
|
+
})
|
|
620
|
+
})] });
|
|
621
|
+
}
|
|
622
|
+
var TABS = [{
|
|
623
|
+
id: "tts",
|
|
624
|
+
label: "Text to speech"
|
|
625
|
+
}, {
|
|
626
|
+
id: "stt",
|
|
627
|
+
label: "Speech to text"
|
|
628
|
+
}];
|
|
629
|
+
function VoicePlayground() {
|
|
630
|
+
const [tab, setTab] = (0, import_react.useState)("tts");
|
|
631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
|
|
632
|
+
className: "rounded-xl border border-sand-200/70 bg-white overflow-hidden",
|
|
633
|
+
children: [
|
|
634
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
635
|
+
role: "tablist",
|
|
636
|
+
className: "flex gap-1 border-b border-sand-100 px-3 pt-2",
|
|
637
|
+
children: TABS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
638
|
+
type: "button",
|
|
639
|
+
role: "tab",
|
|
640
|
+
"aria-selected": tab === t.id,
|
|
641
|
+
onClick: () => setTab(t.id),
|
|
642
|
+
className: `-mb-px border-b-2 px-3 py-2 text-[13px] transition-colors duration-150 ${tab === t.id ? "border-sienna-500 font-medium text-sand-800" : "border-transparent text-sand-500 hover:text-sand-700"}`,
|
|
643
|
+
children: t.label
|
|
644
|
+
}, t.id))
|
|
645
|
+
}),
|
|
646
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
647
|
+
role: "tabpanel",
|
|
648
|
+
hidden: tab !== "tts",
|
|
649
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TtsPanel, {})
|
|
650
|
+
}),
|
|
651
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
652
|
+
role: "tabpanel",
|
|
653
|
+
hidden: tab !== "stt",
|
|
654
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SttPanel, {})
|
|
655
|
+
})
|
|
656
|
+
]
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
//#endregion
|
|
660
|
+
//#region src/routes/voice.tsx?tsr-split=component
|
|
661
|
+
function VoicePage() {
|
|
662
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
663
|
+
className: "max-w-3xl mx-auto",
|
|
664
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VoicePlayground, {})
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
//#endregion
|
|
668
|
+
export { VoicePage as component };
|