@runappsai/sdk 0.7.1 → 0.7.3
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 +21 -1
- package/dist/audio.d.ts +3 -1
- package/dist/audio.d.ts.map +1 -1
- package/dist/audio.js +1 -1
- package/dist/audio.js.map +1 -1
- package/dist/realtime.d.ts +5 -2
- package/dist/realtime.d.ts.map +1 -1
- package/dist/realtime.js +3 -1
- package/dist/realtime.js.map +1 -1
- package/dist/sdk.umd.js +2 -2
- package/dist/sdk.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/audio.ts +5 -2
- package/src/realtime.ts +14 -2
package/package.json
CHANGED
package/src/audio.ts
CHANGED
|
@@ -90,7 +90,10 @@ export interface TranscribeParams {
|
|
|
90
90
|
*/
|
|
91
91
|
url?: string;
|
|
92
92
|
language?: string;
|
|
93
|
-
|
|
93
|
+
|
|
94
|
+
/** A vocabulary hint for the model, as text or a private prompt
|
|
95
|
+
* `{ id, vars }` (or a list; see `PromptInput`). */
|
|
96
|
+
prompt?: string | PromptInput;
|
|
94
97
|
response_format?: string;
|
|
95
98
|
timestamp_granularities?: ("segment" | "word")[];
|
|
96
99
|
user?: string;
|
|
@@ -406,7 +409,7 @@ function buildTranscribeForm(model: string, params: TranscribeParams): FormData
|
|
|
406
409
|
const form = new FormData();
|
|
407
410
|
form.set("model", model);
|
|
408
411
|
if (params.language) form.set("language", params.language);
|
|
409
|
-
if (params.prompt) form.set("prompt", params.prompt);
|
|
412
|
+
if (params.prompt) form.set("prompt", typeof params.prompt === "string" ? params.prompt : JSON.stringify(params.prompt));
|
|
410
413
|
if (params.response_format) form.set("response_format", params.response_format);
|
|
411
414
|
if (params.timestamp_granularities) {
|
|
412
415
|
for (const g of params.timestamp_granularities) {
|
package/src/realtime.ts
CHANGED
|
@@ -30,6 +30,15 @@ import type { Transport } from "./transport.js";
|
|
|
30
30
|
* Audio input must arrive at real-time pace (send ~20 ms chunks as they
|
|
31
31
|
* are captured); the model also expects a steady stream, so keep sending
|
|
32
32
|
* silence — or `mute()` — while the microphone is off.
|
|
33
|
+
*
|
|
34
|
+
* Transcription models (e.g. "Doubao ASR 2.0 Streaming") use the same
|
|
35
|
+
* session for live speech-to-text: `session.created` carries
|
|
36
|
+
* `session.mode: "transcription"`, `session.hotwords` (array or
|
|
37
|
+
* comma-separated string) favours words, and only the
|
|
38
|
+
* `…input_audio_transcription.started / .delta / .completed` events come
|
|
39
|
+
* back — `.delta` holds the sentence so far, `.completed` a finished
|
|
40
|
+
* sentence with `start_ms` / `end_ms`. `commitAudio()` or `close()` ends
|
|
41
|
+
* the audio; the last sentence settles before the session closes.
|
|
33
42
|
*/
|
|
34
43
|
|
|
35
44
|
/** One protocol event. `type` names it; the rest depends on the event. */
|
|
@@ -70,7 +79,8 @@ export interface WebSocketLike {
|
|
|
70
79
|
export type WebSocketConstructor = new (url: string, protocols?: string | string[]) => WebSocketLike;
|
|
71
80
|
|
|
72
81
|
export interface RealtimeConnectOptions {
|
|
73
|
-
/** Realtime model name (e.g. "Doubao Realtime Voice"
|
|
82
|
+
/** Realtime model name (e.g. "Doubao Realtime Voice", or "Doubao ASR 2.0
|
|
83
|
+
* Streaming" for live speech-to-text); omit for the platform default. */
|
|
74
84
|
model?: string;
|
|
75
85
|
/**
|
|
76
86
|
* Session settings sent in the opening `session.create`, e.g.
|
|
@@ -181,7 +191,9 @@ export class RealtimeSession {
|
|
|
181
191
|
this.send({ type: "input_audio_buffer.append", audio: bytesToBase64(asBytes(pcm16)) });
|
|
182
192
|
}
|
|
183
193
|
|
|
184
|
-
/** Tell the model the user has finished speaking (skips end-of-speech
|
|
194
|
+
/** Tell the model the user has finished speaking (skips end-of-speech
|
|
195
|
+
* detection). For a transcription model this ends the audio: the last
|
|
196
|
+
* sentence settles, then the session closes. */
|
|
185
197
|
commitAudio(): void {
|
|
186
198
|
this.send({ type: "input_audio_buffer.commit" });
|
|
187
199
|
}
|