speechrevolutions 0.2.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.
@@ -0,0 +1,94 @@
1
+ import { type Transcript } from "./transcript.js";
2
+ import { type JobStatus, type OutputType, type ProgressCallback, type STTClientOptions, type TranscribeOptions, type UploadJob } from "./types.js";
3
+ export declare class STTClient {
4
+ readonly apiKey: string;
5
+ readonly baseUrl: string;
6
+ readonly timeout: number;
7
+ private readonly fetchFn;
8
+ private readonly maxRetries;
9
+ private readonly retryBackoffMs;
10
+ private readonly requestInit;
11
+ private readonly multipart;
12
+ constructor(opts?: STTClientOptions | string);
13
+ private retryDelayMs;
14
+ /**
15
+ * Transcribe a local file path, remote URL, bytes, or Blob. A URL is handed
16
+ * to the platform to fetch, so nothing is uploaded from here.
17
+ */
18
+ transcribe(audio: Uint8Array | ArrayBuffer | Blob | string, options?: TranscribeOptions, onProgress?: ProgressCallback): Promise<Transcript>;
19
+ /** Waits out the transcription phase and parses the result. */
20
+ private awaitTranscript;
21
+ /** Registers a job the platform fetches itself. No bytes leave this process. */
22
+ private submitUrl;
23
+ transcribeUrl(url: string, options?: TranscribeOptions, onProgress?: ProgressCallback): Promise<Transcript>;
24
+ transcribeFile(path: string, options?: TranscribeOptions, onProgress?: ProgressCallback): Promise<Transcript>;
25
+ /**
26
+ * Upload and enqueue a job, returning its `jobId` WITHOUT waiting for the
27
+ * result. Collect it later via a webhook (`callbackUrl`) or by polling
28
+ * `getJobStatus` / `getTranscript`. Ideal for batch workloads — submit many,
29
+ * then gather — since it holds no long-lived connection per job.
30
+ */
31
+ submit(audio: Uint8Array | ArrayBuffer | Blob | string, options?: TranscribeOptions): Promise<string>;
32
+ /** JSON body shared by the single-shot and multipart create endpoints. */
33
+ private uploadBody;
34
+ /**
35
+ * Get audio into the platform and return `{ jobId, downloadUrl }`. Prefers a
36
+ * multipart upload (when enabled) and falls back to a single presigned PUT if
37
+ * the server has multipart disabled or a multipart upload fails mid-flight.
38
+ */
39
+ private ingestUpload;
40
+ /**
41
+ * S3 multipart flow: create -> PUT each part -> complete. Throws
42
+ * {@link MultipartUnavailable} if the server has multipart disabled (404) or a
43
+ * mid-flight failure means we should retry via the single-shot path.
44
+ */
45
+ private uploadMultipart;
46
+ /** PUT one part to its presigned URL and return the S3 ETag. */
47
+ private putPart;
48
+ createUploadJob(fileSize: number, options?: TranscribeOptions): Promise<UploadJob>;
49
+ touchUploadProgress(jobId: string): Promise<void>;
50
+ uploadAudio(uploadUrl: string, data: Uint8Array, opts?: {
51
+ jobId?: string;
52
+ contentType?: string;
53
+ onProgress?: ProgressCallback;
54
+ }): Promise<void>;
55
+ completeUpload(jobId: string): Promise<void>;
56
+ waitForResult(jobId: string, downloadUrl: string, onProgress?: ProgressCallback, timeout?: number): Promise<{
57
+ content: Uint8Array;
58
+ downloadUrl: string;
59
+ }>;
60
+ downloadResult(downloadUrl: string): Promise<Uint8Array>;
61
+ cancelJob(jobId: string): Promise<void>;
62
+ checkFailed(jobIds: string[]): Promise<boolean[]>;
63
+ /** Fetch a job's current status (and a fresh download URL once complete). */
64
+ getJobStatus(jobId: string): Promise<JobStatus>;
65
+ /**
66
+ * Fetch and parse a completed job's transcript by id. Throws
67
+ * {@link JobFailedError} if it failed, or {@link APIError} if still processing.
68
+ */
69
+ getTranscript(jobId: string, opts?: {
70
+ outputType?: OutputType;
71
+ }): Promise<Transcript>;
72
+ /** List the caller's most-recent jobs (newest first), cursor-paginated. */
73
+ listJobs(opts?: {
74
+ limit?: number;
75
+ before?: string;
76
+ }): Promise<{
77
+ jobs: {
78
+ jobId: string;
79
+ createdAt: string;
80
+ }[];
81
+ nextBefore: string | null;
82
+ }>;
83
+ private headers;
84
+ private apiRequest;
85
+ private raiseForStatus;
86
+ private putUpload;
87
+ private waitSSE;
88
+ private sseAttempt;
89
+ private waitPoll;
90
+ }
91
+ /** @deprecated Use STTClient — alias for Deepgram / ElevenLabs naming. */
92
+ export declare class SpeechRevolutions extends STTClient {
93
+ }
94
+ export { SpeechRevolutions as SpeechRevolutionsClient };