@genex-ai/embed-sdk 0.37.0 → 0.38.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 +118 -2
- package/dist/{chunk-5VDV25LF.js → chunk-M2KOZMPE.js} +764 -47
- package/dist/{chunk-WQJM5MJL.js → chunk-YQY2WLAJ.js} +111 -0
- package/dist/development.d.ts +1 -1
- package/dist/development.js +1 -1
- package/dist/index.d.ts +220 -3
- package/dist/index.js +12 -2
- package/dist/{runtime-generation-D4RMgsvn.d.ts → runtime-generation-DhyQ9taA.d.ts} +246 -2
- package/dist/sentry.js +2 -2
- package/package.json +1 -1
|
@@ -526,6 +526,104 @@ function createBridgeId(random = Math.random) {
|
|
|
526
526
|
return out;
|
|
527
527
|
}
|
|
528
528
|
|
|
529
|
+
// ../embed-protocol/src/runtime-voice.ts
|
|
530
|
+
var VoiceTier = { Premium: "premium", Standard: "standard", Economy: "economy" };
|
|
531
|
+
var VOICE_TIERS = [VoiceTier.Premium, VoiceTier.Standard, VoiceTier.Economy];
|
|
532
|
+
function isVoiceTier(value) {
|
|
533
|
+
return typeof value === "string" && VOICE_TIERS.includes(value);
|
|
534
|
+
}
|
|
535
|
+
var VOICE_SPEECH_ENCODING = "pcm_s16le";
|
|
536
|
+
var VOICE_SPEECH_SAMPLE_RATE = 24e3;
|
|
537
|
+
var VOICE_SPEECH_CHANNELS = 1;
|
|
538
|
+
var VOICE_AUDIO_CONTENT_TYPE = "audio/wav";
|
|
539
|
+
var VOICE_RECORDING_SAMPLE_RATE = 16e3;
|
|
540
|
+
var VOICE_IDEMPOTENCY_HEADER = "Idempotency-Key";
|
|
541
|
+
var VOICE_LANGUAGE_PARAM = "language";
|
|
542
|
+
var VOICE_MODEL_PARAM = "model";
|
|
543
|
+
function isVoiceLanguage(value) {
|
|
544
|
+
return typeof value === "string" && /^[a-z]{2,3}(?:-[A-Z]{2})?$/.test(value);
|
|
545
|
+
}
|
|
546
|
+
function parseSpeechStreamEvent(event, data) {
|
|
547
|
+
let value;
|
|
548
|
+
try {
|
|
549
|
+
value = JSON.parse(data);
|
|
550
|
+
} catch {
|
|
551
|
+
return void 0;
|
|
552
|
+
}
|
|
553
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
554
|
+
const fields = value;
|
|
555
|
+
if (event === "start") {
|
|
556
|
+
const valid = isGenerationId(fields.generationId) && typeof fields.encoding === "string" && typeof fields.sampleRate === "number" && typeof fields.channels === "number";
|
|
557
|
+
return valid ? { event, data: { generationId: fields.generationId, encoding: fields.encoding, sampleRate: fields.sampleRate, channels: fields.channels } } : void 0;
|
|
558
|
+
}
|
|
559
|
+
if (event === "audio") return typeof fields.data === "string" ? { event, data: { data: fields.data } } : void 0;
|
|
560
|
+
if (event === "done") return isGenerationId(fields.generationId) && typeof fields.status === "string" ? { event, data: value } : void 0;
|
|
561
|
+
return void 0;
|
|
562
|
+
}
|
|
563
|
+
var WAV_HEADER_BYTES = 44;
|
|
564
|
+
var WAV_FORMAT_PCM = 1;
|
|
565
|
+
var WAV_FORMAT_EXTENSIBLE = 65534;
|
|
566
|
+
var WAV_BITS = 16;
|
|
567
|
+
var WAV_MAX_CHUNKS = 32;
|
|
568
|
+
function ascii(view, offset, length) {
|
|
569
|
+
let text = "";
|
|
570
|
+
for (let i = 0; i < length; i++) text += String.fromCharCode(view.getUint8(offset + i));
|
|
571
|
+
return text;
|
|
572
|
+
}
|
|
573
|
+
function parseWavPcm16(bytes) {
|
|
574
|
+
if (bytes.byteLength < WAV_HEADER_BYTES) return null;
|
|
575
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
576
|
+
if (ascii(view, 0, 4) !== "RIFF" || ascii(view, 8, 4) !== "WAVE") return null;
|
|
577
|
+
let offset = 12;
|
|
578
|
+
let format = null;
|
|
579
|
+
for (let chunk = 0; chunk < WAV_MAX_CHUNKS && offset + 8 <= bytes.byteLength; chunk++) {
|
|
580
|
+
const id = ascii(view, offset, 4);
|
|
581
|
+
const size = view.getUint32(offset + 4, true);
|
|
582
|
+
const body = offset + 8;
|
|
583
|
+
if (id === "fmt ") {
|
|
584
|
+
if (size < 16 || body + 16 > bytes.byteLength) return null;
|
|
585
|
+
const tag = view.getUint16(body, true);
|
|
586
|
+
const channels = view.getUint16(body + 2, true);
|
|
587
|
+
const sampleRate = view.getUint32(body + 4, true);
|
|
588
|
+
const bits = view.getUint16(body + 14, true);
|
|
589
|
+
const extensiblePcm = tag === WAV_FORMAT_EXTENSIBLE && size >= 26 && body + 26 <= bytes.byteLength && view.getUint16(body + 24, true) === WAV_FORMAT_PCM;
|
|
590
|
+
if (tag !== WAV_FORMAT_PCM && !extensiblePcm || bits !== WAV_BITS || channels < 1 || sampleRate < 1) return null;
|
|
591
|
+
format = { sampleRate, channels };
|
|
592
|
+
} else if (id === "data") {
|
|
593
|
+
if (!format) return null;
|
|
594
|
+
const frame = format.channels * (WAV_BITS / 8);
|
|
595
|
+
const present = Math.min(size, bytes.byteLength - body);
|
|
596
|
+
const dataBytes = present - present % frame;
|
|
597
|
+
return { ...format, dataOffset: body, dataBytes, durationMs: Math.round(dataBytes / frame / format.sampleRate * 1e3) };
|
|
598
|
+
}
|
|
599
|
+
offset = body + size + size % 2;
|
|
600
|
+
}
|
|
601
|
+
return null;
|
|
602
|
+
}
|
|
603
|
+
function encodeWavPcm16(samples, sampleRate, channels = 1) {
|
|
604
|
+
const dataBytes = samples.length * 2;
|
|
605
|
+
const out = new Uint8Array(WAV_HEADER_BYTES + dataBytes);
|
|
606
|
+
const view = new DataView(out.buffer);
|
|
607
|
+
const put = (offset, text) => {
|
|
608
|
+
for (let i = 0; i < text.length; i++) view.setUint8(offset + i, text.charCodeAt(i));
|
|
609
|
+
};
|
|
610
|
+
put(0, "RIFF");
|
|
611
|
+
view.setUint32(4, 36 + dataBytes, true);
|
|
612
|
+
put(8, "WAVE");
|
|
613
|
+
put(12, "fmt ");
|
|
614
|
+
view.setUint32(16, 16, true);
|
|
615
|
+
view.setUint16(20, WAV_FORMAT_PCM, true);
|
|
616
|
+
view.setUint16(22, channels, true);
|
|
617
|
+
view.setUint32(24, sampleRate, true);
|
|
618
|
+
view.setUint32(28, sampleRate * channels * 2, true);
|
|
619
|
+
view.setUint16(32, channels * 2, true);
|
|
620
|
+
view.setUint16(34, WAV_BITS, true);
|
|
621
|
+
put(36, "data");
|
|
622
|
+
view.setUint32(40, dataBytes, true);
|
|
623
|
+
for (let i = 0; i < samples.length; i++) view.setInt16(WAV_HEADER_BYTES + i * 2, samples[i], true);
|
|
624
|
+
return out;
|
|
625
|
+
}
|
|
626
|
+
|
|
529
627
|
// ../embed-protocol/src/runtime-practice.ts
|
|
530
628
|
var PRACTICE_PARAM = "genex_llm_practice";
|
|
531
629
|
var PRACTICE_HOST = "127.0.0.1";
|
|
@@ -596,6 +694,19 @@ export {
|
|
|
596
694
|
foldRuntimeConversation,
|
|
597
695
|
parseGenerationStreamEvent,
|
|
598
696
|
isGenerationTerminal,
|
|
697
|
+
isVoiceTier,
|
|
698
|
+
VOICE_SPEECH_ENCODING,
|
|
699
|
+
VOICE_SPEECH_SAMPLE_RATE,
|
|
700
|
+
VOICE_SPEECH_CHANNELS,
|
|
701
|
+
VOICE_AUDIO_CONTENT_TYPE,
|
|
702
|
+
VOICE_RECORDING_SAMPLE_RATE,
|
|
703
|
+
VOICE_IDEMPOTENCY_HEADER,
|
|
704
|
+
VOICE_LANGUAGE_PARAM,
|
|
705
|
+
VOICE_MODEL_PARAM,
|
|
706
|
+
isVoiceLanguage,
|
|
707
|
+
parseSpeechStreamEvent,
|
|
708
|
+
parseWavPcm16,
|
|
709
|
+
encodeWavPcm16,
|
|
599
710
|
isLoopbackHttpOrigin,
|
|
600
711
|
readPracticeKey,
|
|
601
712
|
practiceOrigin
|
package/dist/development.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RuntimeConversationFields, a as RuntimeControlFields, b as RuntimeJudgeQuestion, c as RuntimeWorkflowInput, d as RuntimeGenerationView } from './runtime-generation-
|
|
1
|
+
import { R as RuntimeConversationFields, a as RuntimeControlFields, b as RuntimeJudgeQuestion, c as RuntimeWorkflowInput, d as RuntimeGenerationView } from './runtime-generation-DhyQ9taA.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Server-only benchmarks spend the authenticated creator's OWN CREDITS
|
package/dist/development.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RuntimeConversationFields, a as RuntimeControlFields, b as RuntimeJudgeQuestion, e as RuntimeJudgeAnswer, f as RuntimeJudgmentView, c as RuntimeWorkflowInput, g as RuntimeGenerationBilling, h as RuntimeGenerationFunding, i as
|
|
2
|
-
export {
|
|
1
|
+
import { R as RuntimeConversationFields, a as RuntimeControlFields, b as RuntimeJudgeQuestion, e as RuntimeJudgeAnswer, f as RuntimeJudgmentView, c as RuntimeWorkflowInput, g as RuntimeGenerationBilling, h as RuntimeGenerationFunding, i as RuntimeGrantVoiceRequest, j as RuntimeGrantView, k as RuntimeMessage, d as RuntimeGenerationView, l as RuntimeGenerationModels, m as RuntimeWorkflowOfferings, n as RuntimeRoomLendView, V as VoiceTier, o as RuntimeVoiceBilling, p as RuntimeVoiceCatalog } from './runtime-generation-DhyQ9taA.js';
|
|
2
|
+
export { q as RuntimeBillingPolicy, r as RuntimeControl, s as RuntimeCurrency, t as RuntimeExternalProvider, u as RuntimeGenerationFeatures, v as RuntimeGenerationStatus, w as RuntimeGenerationStreamEvent, x as RuntimeGrantJudgeTerms, y as RuntimeGrantStatus, z as RuntimeGrantTerms, A as RuntimeGrantVoiceTerms, B as RuntimeJudgeCriterion, C as RuntimeReasoningEffort, D as RuntimeSpeechModel, E as RuntimeSpeechRequest, F as RuntimeSpeechStreamEvent, G as RuntimeSpeechView, H as RuntimeTranscriptionModel, I as RuntimeTranscriptionView, J as RuntimeVoice, K as RuntimeVoiceGrantCounters, L as RuntimeVoiceLimits } from './runtime-generation-DhyQ9taA.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Why a platform call did not happen. One vocabulary for every SDK function,
|
|
@@ -450,6 +450,15 @@ interface SpendGrantOptions {
|
|
|
450
450
|
enabled: boolean;
|
|
451
451
|
estimatedCallsPerPeriod: number;
|
|
452
452
|
};
|
|
453
|
+
/**
|
|
454
|
+
* The game also listens (transcribe()) or speaks (speak(), createSpeaker()),
|
|
455
|
+
* or both. Sent as given; the sheet names every company the player's voice
|
|
456
|
+
* or the game's lines go to, and the budget's `terms.voice` comes back. A
|
|
457
|
+
* voice budget is paid in credits. With `voice`, `models` may be empty for a
|
|
458
|
+
* voice-only budget. Only on a stand whose getGenerationModels() says
|
|
459
|
+
* `features.voice` (getVoiceCatalog() answers `enabled: true` there).
|
|
460
|
+
*/
|
|
461
|
+
voice?: RuntimeGrantVoiceRequest;
|
|
453
462
|
/**
|
|
454
463
|
* The game's multiplayer server may also spend this budget (0.37+): in a
|
|
455
464
|
* server-authoritative room this player lends it to with
|
|
@@ -635,6 +644,214 @@ declare function judge(options: JudgeOptions): Promise<JudgeResult>;
|
|
|
635
644
|
*/
|
|
636
645
|
declare function generationErrorMessage(code: string | undefined): string;
|
|
637
646
|
|
|
647
|
+
/**
|
|
648
|
+
* VOICE on the player-funded lane: the game hears its player (transcribe())
|
|
649
|
+
* and speaks back (speak()). Both are calls under a standing budget the player
|
|
650
|
+
* approved with `voice` terms (requestSpendGrant({ voice })), billed as used
|
|
651
|
+
* on the budget's meter like judge(), and both apply every guard a budget
|
|
652
|
+
* call does. Genex stores no audio.
|
|
653
|
+
*
|
|
654
|
+
* The wire is the protocol's `runtime-voice.ts`. Recording the microphone and
|
|
655
|
+
* playing the spoken audio are the browser helpers in `voice-audio.ts`.
|
|
656
|
+
*/
|
|
657
|
+
|
|
658
|
+
type VoiceStatus = 'succeeded' | 'failed' | 'unknown' | 'canceled' | 'pending';
|
|
659
|
+
/** What every voice call resolves to, as judge() does: never a throw. */
|
|
660
|
+
interface VoiceCallResult {
|
|
661
|
+
/** `pending`: a retry of a call still running — send it again with the same
|
|
662
|
+
* `idempotencyKey` (a transcription) to read its answer. */
|
|
663
|
+
status: VoiceStatus;
|
|
664
|
+
generationId?: string;
|
|
665
|
+
/** Why it did not succeed, as a code for generationErrorMessage(). */
|
|
666
|
+
error?: string;
|
|
667
|
+
/** With `content_blocked`: which side the stand's content check refused. */
|
|
668
|
+
contentBlocked?: 'input' | 'output';
|
|
669
|
+
/** Where the call's money went: never a credit of its own, always the budget's meter. */
|
|
670
|
+
billing?: RuntimeVoiceBilling;
|
|
671
|
+
/** `practice`: answered by the builder's local helper. Absent on every real answer. */
|
|
672
|
+
source?: 'practice';
|
|
673
|
+
}
|
|
674
|
+
/** What transcribe() takes: a budget and one recording. */
|
|
675
|
+
interface TranscribeOptions {
|
|
676
|
+
/** A standing budget approved with `voice: { transcription: … }`. Required. */
|
|
677
|
+
grantId: string;
|
|
678
|
+
/** One WAV file, 16-bit PCM — what createVoiceRecorder().stop() resolves. */
|
|
679
|
+
audio: Blob | ArrayBuffer | Uint8Array;
|
|
680
|
+
/** A hint of the language spoken (`en`, `pt-BR`); the model detects it otherwise. */
|
|
681
|
+
language?: string;
|
|
682
|
+
/** A transcription model of getVoiceCatalog(); the budget's first otherwise. */
|
|
683
|
+
model?: string;
|
|
684
|
+
/** Reuse for retries of the same recording: a replay is answered, never billed twice. */
|
|
685
|
+
idempotencyKey?: string;
|
|
686
|
+
/** Stops WAITING: a call the stand already took still finishes and is charged. */
|
|
687
|
+
signal?: AbortSignal;
|
|
688
|
+
}
|
|
689
|
+
/** What transcribe() resolves: the words heard, on `succeeded`. */
|
|
690
|
+
interface TranscribeResult extends VoiceCallResult {
|
|
691
|
+
/** On `succeeded`: the words heard, `''` when nobody spoke. */
|
|
692
|
+
text?: string;
|
|
693
|
+
/** The language heard, as the provider names it, when it says. */
|
|
694
|
+
language?: string;
|
|
695
|
+
/** The recording's length. */
|
|
696
|
+
durationMs?: number;
|
|
697
|
+
}
|
|
698
|
+
/** What speak() takes: a budget, a line and a voice of the catalog. */
|
|
699
|
+
interface SpeakOptions {
|
|
700
|
+
/** A standing budget approved with `voice: { speech: … }`. Required. */
|
|
701
|
+
grantId: string;
|
|
702
|
+
/** The line to say. At most the catalog's `limits.speech.maxCharacters`. */
|
|
703
|
+
text: string;
|
|
704
|
+
/** A voice id of getVoiceCatalog(), never typed from memory. */
|
|
705
|
+
voice: string;
|
|
706
|
+
/** One of the budget's approved tiers; its first when absent. */
|
|
707
|
+
tier?: VoiceTier;
|
|
708
|
+
/** How to say it, in a few words (`a tired whisper`), for models that read it. */
|
|
709
|
+
style?: string;
|
|
710
|
+
language?: string;
|
|
711
|
+
/** Used once: a spoken line is never replayed, so reusing a key is `idempotency_conflict`. */
|
|
712
|
+
idempotencyKey?: string;
|
|
713
|
+
/** The audio's format, once the stand has started making it. */
|
|
714
|
+
onStart?(info: {
|
|
715
|
+
generationId: string;
|
|
716
|
+
sampleRate: number;
|
|
717
|
+
channels: number;
|
|
718
|
+
}): void;
|
|
719
|
+
/** Each piece of 16-bit little-endian PCM as it arrives, in order. */
|
|
720
|
+
onAudio?(pcm: Uint8Array): void;
|
|
721
|
+
/** Stops READING: the line is still made and charged. Resolves `unknown`
|
|
722
|
+
* with `request_aborted` and the audio that arrived before it. */
|
|
723
|
+
signal?: AbortSignal;
|
|
724
|
+
}
|
|
725
|
+
/** What speak() resolves: the line's receipt and every piece of its audio. */
|
|
726
|
+
interface SpeakResult extends VoiceCallResult {
|
|
727
|
+
voice?: string;
|
|
728
|
+
tier?: VoiceTier;
|
|
729
|
+
/** Characters the line was billed for. */
|
|
730
|
+
characters?: number;
|
|
731
|
+
/** Length of the audio that was made. */
|
|
732
|
+
durationMs?: number;
|
|
733
|
+
/** Every piece of PCM that arrived, joined — on a cut stream too. */
|
|
734
|
+
audio: Uint8Array;
|
|
735
|
+
sampleRate: number;
|
|
736
|
+
channels: number;
|
|
737
|
+
/** `audio` as a WAV file, to keep or hand to an `<audio>` element. */
|
|
738
|
+
wav(): Blob;
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* The voices, tiers, models, limits and estimated prices this stand serves,
|
|
742
|
+
* or `{ enabled: false }` where the game cannot use voice: a stand without
|
|
743
|
+
* it, a page where budget calls are refused (local test mode without the
|
|
744
|
+
* practice helper, the app, an untrusted frame, no player) or any failure.
|
|
745
|
+
* Never throws. Cast from it: voices and tiers are never typed from memory.
|
|
746
|
+
*/
|
|
747
|
+
declare function getVoiceCatalog(): Promise<RuntimeVoiceCatalog | {
|
|
748
|
+
enabled: false;
|
|
749
|
+
}>;
|
|
750
|
+
/**
|
|
751
|
+
* The words in one recording. No popup, no user gesture — the player approved
|
|
752
|
+
* the budget once — and every guard a budget call has. The recording is sent
|
|
753
|
+
* to the budget's transcription provider and not kept. Resolves, never
|
|
754
|
+
* throws: a refusal is `failed` with the server's code.
|
|
755
|
+
*/
|
|
756
|
+
declare function transcribe(options: TranscribeOptions): Promise<TranscribeResult>;
|
|
757
|
+
/**
|
|
758
|
+
* Say one line in a voice of the catalog, streamed as it is made: `onAudio`
|
|
759
|
+
* receives the PCM in order, and the result carries all of it (`audio`,
|
|
760
|
+
* `wav()`). No popup and no user gesture, and every guard a budget call has.
|
|
761
|
+
* A stream that ends without its last event resolves `unknown` with
|
|
762
|
+
* `provider_outcome_unknown` and the audio that arrived: the call settles on
|
|
763
|
+
* the server either way. To play lines back to back, use createSpeaker().
|
|
764
|
+
*/
|
|
765
|
+
declare function speak(options: SpeakOptions): Promise<SpeakResult>;
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* The browser half of voice: a push-to-talk recorder whose WAV transcribe()
|
|
769
|
+
* takes, and a speaker that plays speak()'s lines back to back with no gaps.
|
|
770
|
+
*
|
|
771
|
+
* This module is imported in Node like the rest of the SDK, so every touch of
|
|
772
|
+
* the microphone, the DOM or Web Audio stays inside a function. The arithmetic
|
|
773
|
+
* (resampling, sentences) is pure and exported for tests only.
|
|
774
|
+
*/
|
|
775
|
+
|
|
776
|
+
/** How createVoiceRecorder() records. */
|
|
777
|
+
interface VoiceRecorderOptions {
|
|
778
|
+
/** The longest recording: it stops itself there. Default 30, at most 60. */
|
|
779
|
+
maxSeconds?: number;
|
|
780
|
+
/** The microphone's loudness, 0..1, about twenty times a second — for a meter. */
|
|
781
|
+
onLevel?(level: number): void;
|
|
782
|
+
/** A microphone of `navigator.mediaDevices.enumerateDevices()`; the default one otherwise. */
|
|
783
|
+
deviceId?: string;
|
|
784
|
+
}
|
|
785
|
+
/** A push-to-talk recorder: start on press, stop on release. */
|
|
786
|
+
interface VoiceRecorder {
|
|
787
|
+
/** Ask for the microphone and start recording. Call it from the player's
|
|
788
|
+
* press. Rejects with `code` `microphone_denied` or `microphone_unavailable`. */
|
|
789
|
+
start(): Promise<void>;
|
|
790
|
+
/** The recording as an `audio/wav` Blob for transcribe(). After a recording
|
|
791
|
+
* stopped itself at `maxSeconds`, that one. Rejects `not_recording` otherwise. */
|
|
792
|
+
stop(): Promise<Blob>;
|
|
793
|
+
/** Throw the recording away. */
|
|
794
|
+
cancel(): void;
|
|
795
|
+
readonly recording: boolean;
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Push-to-talk recording for transcribe(): `start()` on press, `stop()` on
|
|
799
|
+
* release. Captures mono, resamples to 16 kHz and resolves a WAV Blob. The
|
|
800
|
+
* microphone and the audio graph are let go on stop, cancel and the
|
|
801
|
+
* `maxSeconds` cut-off. On the game's Genex page the build must declare the
|
|
802
|
+
* microphone (`"genex": { "capabilities": ["microphone"] }` in package.json).
|
|
803
|
+
*/
|
|
804
|
+
declare function createVoiceRecorder(options?: VoiceRecorderOptions): VoiceRecorder;
|
|
805
|
+
/** One line a speaker says: its text and its place in the queue, from 0. */
|
|
806
|
+
interface SpeakerLine {
|
|
807
|
+
text: string;
|
|
808
|
+
index: number;
|
|
809
|
+
}
|
|
810
|
+
/** Who a speaker's lines are spoken by, and on which budget. */
|
|
811
|
+
interface SpeakerOptions {
|
|
812
|
+
/** A standing budget approved with `voice: { speech: … }`. */
|
|
813
|
+
grantId: string;
|
|
814
|
+
/** A voice id of getVoiceCatalog(). */
|
|
815
|
+
voice: string;
|
|
816
|
+
tier?: VoiceTier;
|
|
817
|
+
style?: string;
|
|
818
|
+
language?: string;
|
|
819
|
+
/** A line starts playing: show its subtitle. */
|
|
820
|
+
onLineStart?(line: SpeakerLine): void;
|
|
821
|
+
/** A line finished playing, or failed (`grant_limit_reached`, `voice_busy`, …)
|
|
822
|
+
* or was stopped: every line queued ends here, in order. */
|
|
823
|
+
onLineEnd?(line: SpeakerLine & {
|
|
824
|
+
status: string;
|
|
825
|
+
error?: string;
|
|
826
|
+
}): void;
|
|
827
|
+
/** Characters in one call: pass the catalog's `limits.speech.maxCharacters`. Longer lines are split. */
|
|
828
|
+
maxCharacters?: number;
|
|
829
|
+
}
|
|
830
|
+
/** A queue of spoken lines that plays them back to back. */
|
|
831
|
+
interface Speaker {
|
|
832
|
+
/** Queue one line; resolves once it has played (or failed). A line split
|
|
833
|
+
* into several calls resolves with the first that did not succeed, else the last. */
|
|
834
|
+
say(text: string): Promise<SpeakResult>;
|
|
835
|
+
/** Streamed text (a model's `onDelta`): each sentence is queued as it closes. */
|
|
836
|
+
feed(delta: string): void;
|
|
837
|
+
/** Queue what feed() still holds; resolves when everything queued has played. */
|
|
838
|
+
end(): Promise<void>;
|
|
839
|
+
/** Silence at once: the line being made is let go and the queue is dropped. */
|
|
840
|
+
stop(): void;
|
|
841
|
+
readonly speaking: boolean;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Speak a game's lines one after another with no gaps between them, or a
|
|
845
|
+
* model's streamed reply as it arrives: `feed()` each delta and `end()` it.
|
|
846
|
+
* Each line is one speak() call under the budget, made while the line before
|
|
847
|
+
* it plays. Create the speaker, or call `say()`, from a click or a key press:
|
|
848
|
+
* browsers start audio only after the player has interacted with the page.
|
|
849
|
+
* A line refused only because the budget or the stand is busy is asked again
|
|
850
|
+
* after a short pause; one that still fails is reported through `onLineEnd`
|
|
851
|
+
* and the queue moves on.
|
|
852
|
+
*/
|
|
853
|
+
declare function createSpeaker(options: SpeakerOptions): Speaker;
|
|
854
|
+
|
|
638
855
|
/** How a platform call ended: done, or not done and the one reason why. */
|
|
639
856
|
type PlatformOutcome = {
|
|
640
857
|
ok: true;
|
|
@@ -1289,4 +1506,4 @@ declare function __resetForTests(overrides?: {
|
|
|
1289
1506
|
platformConfirmTimeoutMs?: number;
|
|
1290
1507
|
}): void;
|
|
1291
1508
|
|
|
1292
|
-
export { type AppendEventResult, type AuthState, type AuthorityRegion, type DeleteSharedResult, type EmbedConfig, type EmbedEntry, type EmbedEvent, type EmbedShell, type EmbedUser, type Entitlement, type GenerateOptions, type GenerateStreamOptions, type HapticKind, ItemState, type JudgeOptions, type JudgeResult, type Leaderboard, type LeaderboardEntry, type PaymentOptions, type PaymentPage, type PaymentReceipt, type PaymentResult, type PaymentStatus, type PlatformError, type PlatformFeature, type PlatformOutcome, type PlayerStateResult, type PurchaseResult, type PurchaseStatus, type PutSharedResult, type RequestWorkflowOptions, RuntimeGenerationBilling, RuntimeGenerationFunding, RuntimeGenerationModels, type RuntimeGenerationResult, RuntimeGenerationView, RuntimeGrantView, RuntimeJudgeAnswer, RuntimeJudgeQuestion, RuntimeJudgmentView, RuntimeMessage, RuntimeRoomLendView, type RuntimeWorkflowAuthorization, RuntimeWorkflowInput, RuntimeWorkflowOfferings, type SaveStateResult, type ShareOptions, type ShareResult, type SharedEventPage, type SharedEventRecord, type SharedObject, type SharedObjectInfo, type SharedPage, type ShopItem, type SpendGrantDisclosure, type SpendGrantOptions, type SpendGrantResult, type SponsoredGrantOptions, type SubmitScoreResult, type WorldStateResult, __resetForTests, _stashTicketFromUrl, appendEvent, buy, consumeEntitlement, copyText, deleteShared, foldGenerationRequest, generate, generateStream, generationErrorMessage, getActiveSpendGrant, getAuthState, getAuthorityHome, getAuthorityRegions, getAuthorityUrls, getColyseusAuth, getColyseusUrls, getEmbedToken, getEntitlements, getEntry, getGeneration, getGenerationModels, getLeaderboard, getPayment, getPayments, getShared, getShell, getShop, getSpendGrant, getUser, getWorkflowOfferings, haptic, initEmbed, isEmbedded, judge, keepAwake, lendSpendGrantToRoom, listEvents, listShared, loadPlayerState, loadWorldState, on, onShellClosing, openExternal, putShared, requestPayment, requestSpendGrant, requestWorkflow, resumeWorkflow, returnSpendGrantFromRoom, saveFile, savePlayerState, saveWorldState, setFullscreen, share, stopSpendGrant, submitScore, supports, waitForAuth, waitForGeneration, waitForPlayer };
|
|
1509
|
+
export { type AppendEventResult, type AuthState, type AuthorityRegion, type DeleteSharedResult, type EmbedConfig, type EmbedEntry, type EmbedEvent, type EmbedShell, type EmbedUser, type Entitlement, type GenerateOptions, type GenerateStreamOptions, type HapticKind, ItemState, type JudgeOptions, type JudgeResult, type Leaderboard, type LeaderboardEntry, type PaymentOptions, type PaymentPage, type PaymentReceipt, type PaymentResult, type PaymentStatus, type PlatformError, type PlatformFeature, type PlatformOutcome, type PlayerStateResult, type PurchaseResult, type PurchaseStatus, type PutSharedResult, type RequestWorkflowOptions, RuntimeGenerationBilling, RuntimeGenerationFunding, RuntimeGenerationModels, type RuntimeGenerationResult, RuntimeGenerationView, RuntimeGrantView, RuntimeGrantVoiceRequest, RuntimeJudgeAnswer, RuntimeJudgeQuestion, RuntimeJudgmentView, RuntimeMessage, RuntimeRoomLendView, RuntimeVoiceBilling, RuntimeVoiceCatalog, type RuntimeWorkflowAuthorization, RuntimeWorkflowInput, RuntimeWorkflowOfferings, type SaveStateResult, type ShareOptions, type ShareResult, type SharedEventPage, type SharedEventRecord, type SharedObject, type SharedObjectInfo, type SharedPage, type ShopItem, type SpeakOptions, type SpeakResult, type Speaker, type SpeakerLine, type SpeakerOptions, type SpendGrantDisclosure, type SpendGrantOptions, type SpendGrantResult, type SponsoredGrantOptions, type SubmitScoreResult, type TranscribeOptions, type TranscribeResult, type VoiceCallResult, type VoiceRecorder, type VoiceRecorderOptions, VoiceTier, type WorldStateResult, __resetForTests, _stashTicketFromUrl, appendEvent, buy, consumeEntitlement, copyText, createSpeaker, createVoiceRecorder, deleteShared, foldGenerationRequest, generate, generateStream, generationErrorMessage, getActiveSpendGrant, getAuthState, getAuthorityHome, getAuthorityRegions, getAuthorityUrls, getColyseusAuth, getColyseusUrls, getEmbedToken, getEntitlements, getEntry, getGeneration, getGenerationModels, getLeaderboard, getPayment, getPayments, getShared, getShell, getShop, getSpendGrant, getUser, getVoiceCatalog, getWorkflowOfferings, haptic, initEmbed, isEmbedded, judge, keepAwake, lendSpendGrantToRoom, listEvents, listShared, loadPlayerState, loadWorldState, on, onShellClosing, openExternal, putShared, requestPayment, requestSpendGrant, requestWorkflow, resumeWorkflow, returnSpendGrantFromRoom, saveFile, savePlayerState, saveWorldState, setFullscreen, share, speak, stopSpendGrant, submitScore, supports, transcribe, waitForAuth, waitForGeneration, waitForPlayer };
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
buy,
|
|
7
7
|
consumeEntitlement,
|
|
8
8
|
copyText,
|
|
9
|
+
createSpeaker,
|
|
10
|
+
createVoiceRecorder,
|
|
9
11
|
deleteShared,
|
|
10
12
|
foldGenerationRequest,
|
|
11
13
|
generate,
|
|
@@ -31,6 +33,7 @@ import {
|
|
|
31
33
|
getShop,
|
|
32
34
|
getSpendGrant,
|
|
33
35
|
getUser,
|
|
36
|
+
getVoiceCatalog,
|
|
34
37
|
getWorkflowOfferings,
|
|
35
38
|
haptic,
|
|
36
39
|
initEmbed,
|
|
@@ -56,14 +59,16 @@ import {
|
|
|
56
59
|
saveWorldState,
|
|
57
60
|
setFullscreen,
|
|
58
61
|
share,
|
|
62
|
+
speak,
|
|
59
63
|
stopSpendGrant,
|
|
60
64
|
submitScore,
|
|
61
65
|
supports,
|
|
66
|
+
transcribe,
|
|
62
67
|
waitForAuth,
|
|
63
68
|
waitForGeneration,
|
|
64
69
|
waitForPlayer
|
|
65
|
-
} from "./chunk-
|
|
66
|
-
import "./chunk-
|
|
70
|
+
} from "./chunk-M2KOZMPE.js";
|
|
71
|
+
import "./chunk-YQY2WLAJ.js";
|
|
67
72
|
export {
|
|
68
73
|
ItemState,
|
|
69
74
|
__resetForTests,
|
|
@@ -72,6 +77,8 @@ export {
|
|
|
72
77
|
buy,
|
|
73
78
|
consumeEntitlement,
|
|
74
79
|
copyText,
|
|
80
|
+
createSpeaker,
|
|
81
|
+
createVoiceRecorder,
|
|
75
82
|
deleteShared,
|
|
76
83
|
foldGenerationRequest,
|
|
77
84
|
generate,
|
|
@@ -97,6 +104,7 @@ export {
|
|
|
97
104
|
getShop,
|
|
98
105
|
getSpendGrant,
|
|
99
106
|
getUser,
|
|
107
|
+
getVoiceCatalog,
|
|
100
108
|
getWorkflowOfferings,
|
|
101
109
|
haptic,
|
|
102
110
|
initEmbed,
|
|
@@ -122,9 +130,11 @@ export {
|
|
|
122
130
|
saveWorldState,
|
|
123
131
|
setFullscreen,
|
|
124
132
|
share,
|
|
133
|
+
speak,
|
|
125
134
|
stopSpendGrant,
|
|
126
135
|
submitScore,
|
|
127
136
|
supports,
|
|
137
|
+
transcribe,
|
|
128
138
|
waitForAuth,
|
|
129
139
|
waitForGeneration,
|
|
130
140
|
waitForPlayer
|