@adea-ai/app-framework 0.47.0 → 0.48.1
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 +1 -0
- package/dist/framework-source.json +1 -1
- package/dist/voice/voice-build.d.ts +62 -0
- package/dist/voice/voice-build.js +247 -0
- package/dist/voice/voice-client.d.ts +130 -0
- package/dist/voice/voice-client.js +405 -0
- package/dist/voice/voice-controls.d.ts +43 -0
- package/dist/voice/voice-controls.js +313 -0
- package/dist/voice/voice-host.d.ts +29 -0
- package/dist/voice/voice-host.js +248 -0
- package/dist/voice/voice-protocol.d.ts +127 -0
- package/dist/voice/voice-protocol.js +120 -0
- package/dist/voice/voice-settings.d.ts +15 -0
- package/dist/voice/voice-settings.js +1095 -0
- package/dist/voice/voice.d.ts +5 -0
- package/dist/voice/voice.js +5 -0
- package/package.json +21 -4
- package/src/voice/voice-client.ts +579 -0
- package/src/voice/voice-controls.tsx +354 -0
- package/src/voice/voice-protocol.ts +189 -0
- package/src/voice/voice-settings.tsx +879 -0
- package/src/voice/voice.ts +13 -0
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
import { VOICE_SERVICES } from "./voice-protocol.js";
|
|
2
|
+
import { VoiceError, route } from "@adea-ai/voice/contract";
|
|
3
|
+
import { createVoiceSettingsStore } from "@adea-ai/voice/settings";
|
|
4
|
+
import { SystemVoiceProvider, browserRecognitionLocal, browserRecognitionService } from "@adea-ai/voice/web";
|
|
5
|
+
// src/voice/voice-client.ts
|
|
6
|
+
/**
|
|
7
|
+
* The renderer's voice client: one interface the shared Voice view, the dictation button and the
|
|
8
|
+
* read-aloud action use, whether the app runs in the desktop shell (the helpers, over the voice
|
|
9
|
+
* services) or in a browser (`@adea-ai/voice/web`). The person's choices live in a per-device
|
|
10
|
+
* settings store; every call sends the current settings, so the shell never caches a stale choice.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* A renderer client over a desktop shell. `transport.invoke` must reject with an error whose
|
|
14
|
+
* `code` is the shell's typed error code (a framework `ServiceError` result, or Adea's command
|
|
15
|
+
* error); it is normalised into `VoiceError`.
|
|
16
|
+
*/
|
|
17
|
+
function createDesktopVoiceClient(options) {
|
|
18
|
+
const settings = createVoiceSettingsStore(options.storage ?? safeLocalStorage());
|
|
19
|
+
const call = async (name, input) => {
|
|
20
|
+
try {
|
|
21
|
+
return await options.transport.invoke(name, input);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
throw VoiceError.wrapping(error);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
27
|
+
let polling = false;
|
|
28
|
+
const lifecycle = { disposed: false };
|
|
29
|
+
let cursor = 0;
|
|
30
|
+
const poll = async () => {
|
|
31
|
+
if (polling || lifecycle.disposed) return;
|
|
32
|
+
polling = true;
|
|
33
|
+
let failures = 0;
|
|
34
|
+
while (!lifecycle.disposed && listeners.size > 0) try {
|
|
35
|
+
const batch = await call(VOICE_SERVICES.events, { after: cursor });
|
|
36
|
+
cursor = batch.cursor;
|
|
37
|
+
failures = 0;
|
|
38
|
+
for (const event of batch.events) for (const listener of listeners) listener(event);
|
|
39
|
+
} catch {
|
|
40
|
+
failures++;
|
|
41
|
+
cursor = 0;
|
|
42
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(5e3, 250 * 2 ** failures)));
|
|
43
|
+
}
|
|
44
|
+
polling = false;
|
|
45
|
+
};
|
|
46
|
+
const subscribe = (listener) => {
|
|
47
|
+
listeners.add(listener);
|
|
48
|
+
poll();
|
|
49
|
+
return () => listeners.delete(listener);
|
|
50
|
+
};
|
|
51
|
+
const current = () => settings.read().settings;
|
|
52
|
+
return {
|
|
53
|
+
platform: "desktop",
|
|
54
|
+
settings,
|
|
55
|
+
...options.pickFolder ? { pickFolder: options.pickFolder } : {},
|
|
56
|
+
async capabilities(locale) {
|
|
57
|
+
return {
|
|
58
|
+
...await call(VOICE_SERVICES.capabilities, {
|
|
59
|
+
settings: current(),
|
|
60
|
+
...locale ? { locale } : {}
|
|
61
|
+
}),
|
|
62
|
+
platform: "desktop"
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
permission: (request = false) => call(VOICE_SERVICES.permission, { request }),
|
|
66
|
+
async dictate(dictateOptions = {}) {
|
|
67
|
+
let id;
|
|
68
|
+
const early = [];
|
|
69
|
+
let settle;
|
|
70
|
+
const result = new Promise((resolve, reject) => {
|
|
71
|
+
settle = {
|
|
72
|
+
resolve,
|
|
73
|
+
reject
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
result.catch(() => void 0);
|
|
77
|
+
const handle = (event) => {
|
|
78
|
+
if (!("id" in event) || !event.type.startsWith("dictation-")) return;
|
|
79
|
+
if (id === void 0) {
|
|
80
|
+
early.push(event);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (event.id !== id) return;
|
|
84
|
+
if (event.type === "dictation-partial") dictateOptions.onPartial?.(event.text);
|
|
85
|
+
else {
|
|
86
|
+
unsubscribe();
|
|
87
|
+
if (event.type === "dictation-final") settle.resolve(event.text);
|
|
88
|
+
else if (event.type === "dictation-cancelled") settle.reject(new VoiceError("cancelled", "Dictation was cancelled."));
|
|
89
|
+
else if (event.type === "dictation-failed") settle.reject(new VoiceError(event.code, event.message));
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const unsubscribe = subscribe(handle);
|
|
93
|
+
try {
|
|
94
|
+
id = (await call(VOICE_SERVICES.dictateStart, {
|
|
95
|
+
settings: current(),
|
|
96
|
+
...dictateOptions.locale ? { locale: dictateOptions.locale } : {}
|
|
97
|
+
})).id;
|
|
98
|
+
} catch (error) {
|
|
99
|
+
unsubscribe();
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
for (const event of early.splice(0)) handle(event);
|
|
103
|
+
const started = id;
|
|
104
|
+
return {
|
|
105
|
+
result,
|
|
106
|
+
end: () => call(VOICE_SERVICES.dictateEnd, { id: started }).then(() => void 0),
|
|
107
|
+
cancel: () => call(VOICE_SERVICES.dictateCancel, { id: started }).then(() => void 0)
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
async speak(text, speakOptions = {}) {
|
|
111
|
+
let id;
|
|
112
|
+
const early = [];
|
|
113
|
+
let settle;
|
|
114
|
+
let markStarted;
|
|
115
|
+
const started = new Promise((resolve) => {
|
|
116
|
+
markStarted = resolve;
|
|
117
|
+
});
|
|
118
|
+
const done = new Promise((resolve, reject) => {
|
|
119
|
+
settle = {
|
|
120
|
+
resolve,
|
|
121
|
+
reject
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
done.catch(() => void 0);
|
|
125
|
+
const handle = (event) => {
|
|
126
|
+
if (!event.type.startsWith("speech-")) return;
|
|
127
|
+
if (id === void 0) {
|
|
128
|
+
early.push(event);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (event.id !== id) return;
|
|
132
|
+
if (event.type === "speech-started") markStarted(event.voice ? { voice: event.voice } : {});
|
|
133
|
+
else if (event.type === "speech-finished" || event.type === "speech-cancelled") {
|
|
134
|
+
unsubscribe();
|
|
135
|
+
markStarted(void 0);
|
|
136
|
+
settle.resolve(event.type === "speech-finished" ? "finished" : "cancelled");
|
|
137
|
+
} else if (event.type === "speech-failed") {
|
|
138
|
+
unsubscribe();
|
|
139
|
+
markStarted(void 0);
|
|
140
|
+
settle.reject(new VoiceError(event.code, event.message));
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const unsubscribe = subscribe(handle);
|
|
144
|
+
try {
|
|
145
|
+
id = (await call(VOICE_SERVICES.speak, {
|
|
146
|
+
settings: current(),
|
|
147
|
+
text,
|
|
148
|
+
...speakOptions.locale ? { locale: speakOptions.locale } : {}
|
|
149
|
+
})).id;
|
|
150
|
+
} catch (error) {
|
|
151
|
+
unsubscribe();
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
for (const event of early.splice(0)) handle(event);
|
|
155
|
+
return {
|
|
156
|
+
id,
|
|
157
|
+
started,
|
|
158
|
+
done,
|
|
159
|
+
cancel: () => call(VOICE_SERVICES.speakStop, null).then(() => void 0)
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
stopSpeaking: () => call(VOICE_SERVICES.speakStop, null).then(() => void 0),
|
|
163
|
+
voices: async (locale) => (await call(VOICE_SERVICES.voices, {
|
|
164
|
+
settings: current(),
|
|
165
|
+
...locale ? { locale } : {}
|
|
166
|
+
})).voices,
|
|
167
|
+
locales: async () => (await call(VOICE_SERVICES.locales, null)).locales,
|
|
168
|
+
async installAssets(locale, onProgress) {
|
|
169
|
+
let id;
|
|
170
|
+
const early = [];
|
|
171
|
+
let settle;
|
|
172
|
+
const done = new Promise((resolve, reject) => {
|
|
173
|
+
settle = {
|
|
174
|
+
resolve,
|
|
175
|
+
reject
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
done.catch(() => void 0);
|
|
179
|
+
const handle = (event) => {
|
|
180
|
+
if (!event.type.startsWith("install-")) return;
|
|
181
|
+
if (id === void 0) {
|
|
182
|
+
early.push(event);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (event.id !== id) return;
|
|
186
|
+
if (event.type === "install-progress") onProgress?.(event.fraction);
|
|
187
|
+
else {
|
|
188
|
+
unsubscribe();
|
|
189
|
+
if (event.type === "install-finished") settle.resolve();
|
|
190
|
+
else if (event.type === "install-failed") settle.reject(new VoiceError(event.code, event.message));
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const unsubscribe = subscribe(handle);
|
|
194
|
+
try {
|
|
195
|
+
id = (await call(VOICE_SERVICES.installAssets, { locale })).id;
|
|
196
|
+
} catch (error) {
|
|
197
|
+
unsubscribe();
|
|
198
|
+
throw error;
|
|
199
|
+
}
|
|
200
|
+
for (const event of early.splice(0)) handle(event);
|
|
201
|
+
const started = id;
|
|
202
|
+
return {
|
|
203
|
+
done,
|
|
204
|
+
cancel: () => call(VOICE_SERVICES.installCancel, { id: started }).then(() => void 0)
|
|
205
|
+
};
|
|
206
|
+
},
|
|
207
|
+
releaseAssets: (locale) => call(VOICE_SERVICES.releaseAssets, { locale }),
|
|
208
|
+
dispose() {
|
|
209
|
+
lifecycle.disposed = true;
|
|
210
|
+
listeners.clear();
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* A renderer client for a browser build: on-device browser dictation (the network service only
|
|
216
|
+
* with the person's consent and never in offline-only mode) and platform voices for read-aloud.
|
|
217
|
+
*/
|
|
218
|
+
function createWebVoiceClient(options = {}) {
|
|
219
|
+
const settings = createVoiceSettingsStore(options.storage ?? safeLocalStorage());
|
|
220
|
+
const current = () => settings.read().settings;
|
|
221
|
+
const local = browserRecognitionLocal();
|
|
222
|
+
const service = browserRecognitionService();
|
|
223
|
+
const voices = new SystemVoiceProvider();
|
|
224
|
+
const allowNetwork = () => !current().privacy.offlineOnly && current().stt.networkConsent;
|
|
225
|
+
const decide = async (locale) => {
|
|
226
|
+
const choice = current();
|
|
227
|
+
const sttLocale = locale ?? choice.stt.locale ?? browserLocale();
|
|
228
|
+
const ttsLocale = choice.tts.locale ?? sttLocale;
|
|
229
|
+
const sttProviders = allowNetwork() ? [local, service] : [local];
|
|
230
|
+
const [speechToText, textToSpeech] = await Promise.all([route({
|
|
231
|
+
kind: "speechToText",
|
|
232
|
+
locale: sttLocale,
|
|
233
|
+
providers: sttProviders,
|
|
234
|
+
policy: {
|
|
235
|
+
chains: { speechToText: allowNetwork() ? [local.descriptor.id, service.descriptor.id] : [local.descriptor.id] },
|
|
236
|
+
...choice.stt.provider ? { overrides: { speechToText: choice.stt.provider } } : {},
|
|
237
|
+
allowsOptInModelInstallation: false
|
|
238
|
+
}
|
|
239
|
+
}), route({
|
|
240
|
+
kind: "textToSpeech",
|
|
241
|
+
locale: ttsLocale,
|
|
242
|
+
providers: [voices],
|
|
243
|
+
policy: {
|
|
244
|
+
chains: { textToSpeech: [voices.descriptor.id] },
|
|
245
|
+
allowsOptInModelInstallation: false
|
|
246
|
+
}
|
|
247
|
+
})]);
|
|
248
|
+
return {
|
|
249
|
+
speechToText,
|
|
250
|
+
textToSpeech,
|
|
251
|
+
sttLocale,
|
|
252
|
+
ttsLocale
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
let active;
|
|
256
|
+
const speaking = /* @__PURE__ */ new Set();
|
|
257
|
+
return {
|
|
258
|
+
platform: "web",
|
|
259
|
+
settings,
|
|
260
|
+
async capabilities(locale) {
|
|
261
|
+
const { speechToText, textToSpeech, sttLocale, ttsLocale } = await decide(locale);
|
|
262
|
+
return {
|
|
263
|
+
platform: "web",
|
|
264
|
+
speechToText,
|
|
265
|
+
textToSpeech,
|
|
266
|
+
providers: await Promise.all([
|
|
267
|
+
local,
|
|
268
|
+
service,
|
|
269
|
+
voices
|
|
270
|
+
].map(async (provider) => ({
|
|
271
|
+
id: provider.descriptor.id,
|
|
272
|
+
displayName: provider.descriptor.displayName,
|
|
273
|
+
kind: provider.descriptor.kind,
|
|
274
|
+
bundled: true,
|
|
275
|
+
availability: await provider.availability(provider.descriptor.kind === "speechToText" ? sttLocale : ttsLocale)
|
|
276
|
+
}))),
|
|
277
|
+
permission: await (async () => {
|
|
278
|
+
const state = await browserMicrophonePermission(false);
|
|
279
|
+
return {
|
|
280
|
+
state,
|
|
281
|
+
microphone: state,
|
|
282
|
+
speech: state
|
|
283
|
+
};
|
|
284
|
+
})(),
|
|
285
|
+
localModels: []
|
|
286
|
+
};
|
|
287
|
+
},
|
|
288
|
+
permission: async (request = false) => {
|
|
289
|
+
const state = await browserMicrophonePermission(request);
|
|
290
|
+
return {
|
|
291
|
+
state,
|
|
292
|
+
microphone: state,
|
|
293
|
+
speech: state
|
|
294
|
+
};
|
|
295
|
+
},
|
|
296
|
+
async dictate(dictateOptions = {}) {
|
|
297
|
+
if (active) throw new VoiceError("busy", "A dictation is already running.");
|
|
298
|
+
const { speechToText, sttLocale } = await decide(dictateOptions.locale);
|
|
299
|
+
let chosen = speechToText.availability.status === "available" ? local : void 0;
|
|
300
|
+
if (!chosen && allowNetwork() && !current().stt.provider?.startsWith("web.speech-recognition-local")) {
|
|
301
|
+
const network = await service.availability(sttLocale);
|
|
302
|
+
if (network.status === "available" || network.unavailable.reason === "networkRequired") chosen = service;
|
|
303
|
+
}
|
|
304
|
+
if (!chosen) throw new VoiceError("unavailable", speechToText.availability.status === "unavailable" ? speechToText.availability.unavailable.message : "Dictation is unavailable in this browser.");
|
|
305
|
+
const session = await chosen.createSession({
|
|
306
|
+
locale: sttLocale,
|
|
307
|
+
allowNetwork: allowNetwork()
|
|
308
|
+
});
|
|
309
|
+
active = session;
|
|
310
|
+
const result = (async () => {
|
|
311
|
+
try {
|
|
312
|
+
for await (const event of session.events()) if (event.type === "partial") dictateOptions.onPartial?.([event.partial.finalizedText, event.partial.volatileText].filter(Boolean).join(" "));
|
|
313
|
+
else if (event.type === "final") return event.text;
|
|
314
|
+
else if (event.type === "failed") throw event.error;
|
|
315
|
+
else if (event.type === "cancelled") throw new VoiceError("cancelled", "Dictation was cancelled.");
|
|
316
|
+
throw new VoiceError("failed", "Dictation ended without a result.");
|
|
317
|
+
} finally {
|
|
318
|
+
if (active === session) active = void 0;
|
|
319
|
+
}
|
|
320
|
+
})();
|
|
321
|
+
result.catch(() => void 0);
|
|
322
|
+
return {
|
|
323
|
+
result,
|
|
324
|
+
end: () => session.end(),
|
|
325
|
+
cancel: () => session.cancel()
|
|
326
|
+
};
|
|
327
|
+
},
|
|
328
|
+
async speak(text, speakOptions = {}) {
|
|
329
|
+
const choice = current();
|
|
330
|
+
const locale = speakOptions.locale ?? choice.tts.locale ?? browserLocale();
|
|
331
|
+
const handle = voices.speak(text, {
|
|
332
|
+
locale,
|
|
333
|
+
...choice.tts.voice ? { voiceName: choice.tts.voice } : {},
|
|
334
|
+
...choice.tts.rate ? { rate: choice.tts.rate } : {},
|
|
335
|
+
allowNetwork: !choice.privacy.offlineOnly && choice.tts.networkConsent
|
|
336
|
+
});
|
|
337
|
+
speaking.add(handle);
|
|
338
|
+
const done = handle.done.finally(() => speaking.delete(handle)).then(() => "finished", (error) => {
|
|
339
|
+
const typed = VoiceError.wrapping(error);
|
|
340
|
+
if (typed.code === "cancelled") return "cancelled";
|
|
341
|
+
throw typed;
|
|
342
|
+
});
|
|
343
|
+
done.catch(() => void 0);
|
|
344
|
+
return {
|
|
345
|
+
id: `web-${Date.now().toString(36)}`,
|
|
346
|
+
done,
|
|
347
|
+
cancel: async () => handle.cancel()
|
|
348
|
+
};
|
|
349
|
+
},
|
|
350
|
+
async stopSpeaking() {
|
|
351
|
+
for (const handle of speaking) handle.cancel();
|
|
352
|
+
},
|
|
353
|
+
async voices(locale) {
|
|
354
|
+
return voices.voices(locale ?? current().tts.locale ?? browserLocale()).local.map((voice) => ({
|
|
355
|
+
id: voice.name,
|
|
356
|
+
name: voice.name,
|
|
357
|
+
locale: voice.lang,
|
|
358
|
+
quality: "default",
|
|
359
|
+
provider: voices.descriptor.id
|
|
360
|
+
}));
|
|
361
|
+
},
|
|
362
|
+
locales: async () => [],
|
|
363
|
+
async installAssets() {
|
|
364
|
+
throw new VoiceError("unavailable", "Language downloads are managed by the browser.");
|
|
365
|
+
},
|
|
366
|
+
async releaseAssets() {
|
|
367
|
+
throw new VoiceError("unavailable", "Language downloads are managed by the browser.");
|
|
368
|
+
},
|
|
369
|
+
dispose() {
|
|
370
|
+
active?.cancel();
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* The microphone permission as the browser reports it. `request` opens the browser prompt (a
|
|
376
|
+
* one-off `getUserMedia` whose tracks stop at once); without it nothing is asked.
|
|
377
|
+
*/
|
|
378
|
+
async function browserMicrophonePermission(request) {
|
|
379
|
+
if (typeof navigator === "undefined") return "unavailable";
|
|
380
|
+
if (request && navigator.mediaDevices?.getUserMedia) try {
|
|
381
|
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
382
|
+
for (const track of stream.getTracks()) track.stop();
|
|
383
|
+
return "granted";
|
|
384
|
+
} catch (error) {
|
|
385
|
+
return error instanceof DOMException && error.name === "NotFoundError" ? "unavailable" : "denied";
|
|
386
|
+
}
|
|
387
|
+
try {
|
|
388
|
+
const status = await navigator.permissions?.query({ name: "microphone" });
|
|
389
|
+
if (status?.state === "granted" || status?.state === "denied") return status.state;
|
|
390
|
+
return "prompt";
|
|
391
|
+
} catch {
|
|
392
|
+
return "prompt";
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function browserLocale() {
|
|
396
|
+
return (typeof navigator === "undefined" ? void 0 : navigator.language) || "en-US";
|
|
397
|
+
}
|
|
398
|
+
function safeLocalStorage() {
|
|
399
|
+
try {
|
|
400
|
+
return typeof localStorage === "undefined" ? void 0 : localStorage;
|
|
401
|
+
} catch {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
export { createDesktopVoiceClient, createWebVoiceClient };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ButtonProps } from '@adea-ai/ui/components/ui/button';
|
|
2
|
+
import { type Accessor } from 'solid-js';
|
|
3
|
+
import type { VoiceClient } from './voice-client';
|
|
4
|
+
export type DictationState = 'idle' | 'starting' | 'listening' | 'stopping';
|
|
5
|
+
export type DictationCallbacks = Readonly<{
|
|
6
|
+
/** Every partial (`final` false) and the final text (`final` true). */
|
|
7
|
+
onText?(text: string, final: boolean): void;
|
|
8
|
+
/** The final text, when the person chose to send after dictating. */
|
|
9
|
+
onFinal?(text: string): void;
|
|
10
|
+
}>;
|
|
11
|
+
export type Dictation = Readonly<{
|
|
12
|
+
state: Accessor<DictationState>;
|
|
13
|
+
/** The latest partial, then the final text. */
|
|
14
|
+
partial: Accessor<string>;
|
|
15
|
+
/** A short message for the last failure; cleared when a dictation starts. */
|
|
16
|
+
error: Accessor<string | undefined>;
|
|
17
|
+
/** Asks for permission when needed, then dictates. Resolves with the final text, if any. */
|
|
18
|
+
start(callbacks?: DictationCallbacks): Promise<string | undefined>;
|
|
19
|
+
/** Finishes listening and keeps what was said. */
|
|
20
|
+
stop(): Promise<void>;
|
|
21
|
+
/** Stops listening and drops the text, silently. */
|
|
22
|
+
cancel(): Promise<void>;
|
|
23
|
+
}>;
|
|
24
|
+
/** The dictation state machine behind `DictationButton`, for apps that draw their own status. */
|
|
25
|
+
export declare function createDictation(client: VoiceClient | undefined): Dictation;
|
|
26
|
+
export type DictationButtonProps = {
|
|
27
|
+
client?: VoiceClient;
|
|
28
|
+
onText(text: string, final: boolean): void;
|
|
29
|
+
onFinal?(text: string): void;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
size?: ButtonProps['size'];
|
|
32
|
+
/** Share a dictation made with `createDictation` to draw its status elsewhere. */
|
|
33
|
+
dictation?: Dictation;
|
|
34
|
+
};
|
|
35
|
+
/** A microphone button: click to dictate, click again to finish, Escape to cancel. */
|
|
36
|
+
export declare function DictationButton(props: DictationButtonProps): import("@solidjs/web").JSX.Element;
|
|
37
|
+
export type ReadAloudButtonProps = {
|
|
38
|
+
client?: VoiceClient;
|
|
39
|
+
text: string | (() => string);
|
|
40
|
+
locale?: string;
|
|
41
|
+
};
|
|
42
|
+
/** A message action that reads its text aloud, and stops it on a second click. */
|
|
43
|
+
export declare function ReadAloudButton(props: ReadAloudButtonProps): import("@solidjs/web").JSX.Element;
|