spitch 1.19.0 → 1.22.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/CHANGELOG.md +22 -16
- package/README.md +50 -10
- package/client.d.mts +13 -4
- package/client.d.mts.map +1 -1
- package/client.d.ts +13 -4
- package/client.d.ts.map +1 -1
- package/client.js +11 -2
- package/client.js.map +1 -1
- package/client.mjs +13 -4
- package/client.mjs.map +1 -1
- package/core/pagination.d.mts +54 -0
- package/core/pagination.d.mts.map +1 -0
- package/core/pagination.d.ts +54 -0
- package/core/pagination.d.ts.map +1 -0
- package/core/pagination.js +101 -0
- package/core/pagination.js.map +1 -0
- package/core/pagination.mjs +95 -0
- package/core/pagination.mjs.map +1 -0
- package/index.d.mts +1 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/internal/to-file.d.mts +1 -1
- package/internal/to-file.d.ts +1 -1
- package/internal/to-file.js +1 -1
- package/internal/to-file.mjs +1 -1
- package/internal/utils/values.js +3 -3
- package/internal/utils/values.js.map +1 -1
- package/internal/utils/values.mjs +3 -3
- package/internal/utils/values.mjs.map +1 -1
- package/package.json +14 -1
- package/pagination.d.mts +2 -0
- package/pagination.d.mts.map +1 -0
- package/pagination.d.ts +2 -0
- package/pagination.d.ts.map +1 -0
- package/pagination.js +6 -0
- package/pagination.js.map +1 -0
- package/pagination.mjs +2 -0
- package/pagination.mjs.map +1 -0
- package/resources/files.d.mts +74 -0
- package/resources/files.d.mts.map +1 -0
- package/resources/files.d.ts +74 -0
- package/resources/files.d.ts.map +1 -0
- package/resources/files.js +48 -0
- package/resources/files.js.map +1 -0
- package/resources/files.mjs +44 -0
- package/resources/files.mjs.map +1 -0
- package/resources/index.d.mts +3 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +3 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -1
- package/resources/index.mjs.map +1 -1
- package/resources/speech.d.mts +8 -8
- package/resources/speech.d.mts.map +1 -1
- package/resources/speech.d.ts +8 -8
- package/resources/speech.d.ts.map +1 -1
- package/resources/speech.js +7 -1
- package/resources/speech.js.map +1 -1
- package/resources/speech.mjs +7 -1
- package/resources/speech.mjs.map +1 -1
- package/resources/text.d.mts +5 -5
- package/resources/text.d.mts.map +1 -1
- package/resources/text.d.ts +5 -5
- package/resources/text.d.ts.map +1 -1
- package/src/client.ts +56 -19
- package/src/core/pagination.ts +157 -0
- package/src/index.ts +1 -0
- package/src/internal/to-file.ts +1 -1
- package/src/internal/utils/values.ts +3 -3
- package/src/pagination.ts +2 -0
- package/src/resources/files.ts +136 -0
- package/src/resources/index.ts +13 -8
- package/src/resources/speech.ts +16 -11
- package/src/resources/text.ts +6 -6
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/client.ts
CHANGED
|
@@ -13,23 +13,24 @@ import * as Shims from './internal/shims';
|
|
|
13
13
|
import * as Opts from './internal/request-options';
|
|
14
14
|
import { VERSION } from './version';
|
|
15
15
|
import * as Errors from './core/error';
|
|
16
|
+
import * as Pagination from './core/pagination';
|
|
17
|
+
import { AbstractPage, type FilesCursorParams, FilesCursorResponse } from './core/pagination';
|
|
16
18
|
import * as Uploads from './core/uploads';
|
|
17
19
|
import * as API from './resources/index';
|
|
18
20
|
import { APIPromise } from './core/api-promise';
|
|
19
21
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} from './resources/text';
|
|
22
|
+
File,
|
|
23
|
+
FileDeleteResponse,
|
|
24
|
+
FileDownloadParams,
|
|
25
|
+
FileDownloadResponse,
|
|
26
|
+
FileListParams,
|
|
27
|
+
FileUploadParams,
|
|
28
|
+
FileUsage,
|
|
29
|
+
Files,
|
|
30
|
+
FilesFilesCursor,
|
|
31
|
+
} from './resources/files';
|
|
32
|
+
import { Speech, SpeechGenerateParams, SpeechTranscribeParams, Transcription } from './resources/speech';
|
|
33
|
+
import { Diacritics, Text, TextToneMarkParams, TextTranslateParams, Translation } from './resources/text';
|
|
33
34
|
import { type Fetch } from './internal/builtin-types';
|
|
34
35
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
35
36
|
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
@@ -381,7 +382,7 @@ export class Spitch {
|
|
|
381
382
|
const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
|
|
382
383
|
const headersTime = Date.now();
|
|
383
384
|
|
|
384
|
-
if (response instanceof Error) {
|
|
385
|
+
if (response instanceof globalThis.Error) {
|
|
385
386
|
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
386
387
|
if (options.signal?.aborted) {
|
|
387
388
|
throw new Errors.APIUserAbortError();
|
|
@@ -495,6 +496,25 @@ export class Spitch {
|
|
|
495
496
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
496
497
|
}
|
|
497
498
|
|
|
499
|
+
getAPIList<Item, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(
|
|
500
|
+
path: string,
|
|
501
|
+
Page: new (...args: any[]) => PageClass,
|
|
502
|
+
opts?: RequestOptions,
|
|
503
|
+
): Pagination.PagePromise<PageClass, Item> {
|
|
504
|
+
return this.requestAPIList(Page, { method: 'get', path, ...opts });
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
requestAPIList<
|
|
508
|
+
Item = unknown,
|
|
509
|
+
PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>,
|
|
510
|
+
>(
|
|
511
|
+
Page: new (...args: ConstructorParameters<typeof Pagination.AbstractPage>) => PageClass,
|
|
512
|
+
options: FinalRequestOptions,
|
|
513
|
+
): Pagination.PagePromise<PageClass, Item> {
|
|
514
|
+
const request = this.makeRequest(options, null, undefined);
|
|
515
|
+
return new Pagination.PagePromise<PageClass, Item>(this as any as Spitch, request, Page);
|
|
516
|
+
}
|
|
517
|
+
|
|
498
518
|
async fetchWithTimeout(
|
|
499
519
|
url: RequestInfo,
|
|
500
520
|
init: RequestInit | undefined,
|
|
@@ -688,7 +708,7 @@ export class Spitch {
|
|
|
688
708
|
// Preserve legacy string encoding behavior for now
|
|
689
709
|
headers.values.has('content-type')) ||
|
|
690
710
|
// `Blob` is superset of `File`
|
|
691
|
-
body instanceof Blob ||
|
|
711
|
+
((globalThis as any).Blob && body instanceof (globalThis as any).Blob) ||
|
|
692
712
|
// `FormData` -> `multipart/form-data`
|
|
693
713
|
body instanceof FormData ||
|
|
694
714
|
// `URLSearchParams` -> `application/x-www-form-urlencoded`
|
|
@@ -729,25 +749,42 @@ export class Spitch {
|
|
|
729
749
|
|
|
730
750
|
speech: API.Speech = new API.Speech(this);
|
|
731
751
|
text: API.Text = new API.Text(this);
|
|
752
|
+
files: API.Files = new API.Files(this);
|
|
732
753
|
}
|
|
754
|
+
|
|
733
755
|
Spitch.Speech = Speech;
|
|
734
756
|
Spitch.Text = Text;
|
|
757
|
+
|
|
735
758
|
export declare namespace Spitch {
|
|
736
759
|
export type RequestOptions = Opts.RequestOptions;
|
|
737
760
|
|
|
761
|
+
export import FilesCursor = Pagination.FilesCursor;
|
|
762
|
+
export { type FilesCursorParams as FilesCursorParams, type FilesCursorResponse as FilesCursorResponse };
|
|
763
|
+
|
|
738
764
|
export {
|
|
739
765
|
Speech as Speech,
|
|
740
|
-
type
|
|
741
|
-
type SpeechTranscribeResponse as SpeechTranscribeResponse,
|
|
766
|
+
type Transcription as Transcription,
|
|
742
767
|
type SpeechGenerateParams as SpeechGenerateParams,
|
|
743
768
|
type SpeechTranscribeParams as SpeechTranscribeParams,
|
|
744
769
|
};
|
|
745
770
|
|
|
746
771
|
export {
|
|
747
772
|
Text as Text,
|
|
748
|
-
type
|
|
749
|
-
type
|
|
773
|
+
type Diacritics as Diacritics,
|
|
774
|
+
type Translation as Translation,
|
|
750
775
|
type TextToneMarkParams as TextToneMarkParams,
|
|
751
776
|
type TextTranslateParams as TextTranslateParams,
|
|
752
777
|
};
|
|
778
|
+
|
|
779
|
+
export {
|
|
780
|
+
type Files as Files,
|
|
781
|
+
type File as File,
|
|
782
|
+
type FileUsage as FileUsage,
|
|
783
|
+
type FileDeleteResponse as FileDeleteResponse,
|
|
784
|
+
type FileDownloadResponse as FileDownloadResponse,
|
|
785
|
+
type FilesFilesCursor as FilesFilesCursor,
|
|
786
|
+
type FileListParams as FileListParams,
|
|
787
|
+
type FileDownloadParams as FileDownloadParams,
|
|
788
|
+
type FileUploadParams as FileUploadParams,
|
|
789
|
+
};
|
|
753
790
|
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { SpitchError } from './error';
|
|
4
|
+
import { FinalRequestOptions } from '../internal/request-options';
|
|
5
|
+
import { defaultParseResponse } from '../internal/parse';
|
|
6
|
+
import { type Spitch } from '../client';
|
|
7
|
+
import { APIPromise } from './api-promise';
|
|
8
|
+
import { type APIResponseProps } from '../internal/parse';
|
|
9
|
+
import { maybeObj } from '../internal/utils/values';
|
|
10
|
+
|
|
11
|
+
export type PageRequestOptions = Pick<FinalRequestOptions, 'query' | 'headers' | 'body' | 'path' | 'method'>;
|
|
12
|
+
|
|
13
|
+
export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
|
|
14
|
+
#client: Spitch;
|
|
15
|
+
protected options: FinalRequestOptions;
|
|
16
|
+
|
|
17
|
+
protected response: Response;
|
|
18
|
+
protected body: unknown;
|
|
19
|
+
|
|
20
|
+
constructor(client: Spitch, response: Response, body: unknown, options: FinalRequestOptions) {
|
|
21
|
+
this.#client = client;
|
|
22
|
+
this.options = options;
|
|
23
|
+
this.response = response;
|
|
24
|
+
this.body = body;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
abstract nextPageRequestOptions(): PageRequestOptions | null;
|
|
28
|
+
|
|
29
|
+
abstract getPaginatedItems(): Item[];
|
|
30
|
+
|
|
31
|
+
hasNextPage(): boolean {
|
|
32
|
+
const items = this.getPaginatedItems();
|
|
33
|
+
if (!items.length) return false;
|
|
34
|
+
return this.nextPageRequestOptions() != null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async getNextPage(): Promise<this> {
|
|
38
|
+
const nextOptions = this.nextPageRequestOptions();
|
|
39
|
+
if (!nextOptions) {
|
|
40
|
+
throw new SpitchError(
|
|
41
|
+
'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.',
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return await this.#client.requestAPIList(this.constructor as any, nextOptions);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async *iterPages(): AsyncGenerator<this> {
|
|
49
|
+
let page: this = this;
|
|
50
|
+
yield page;
|
|
51
|
+
while (page.hasNextPage()) {
|
|
52
|
+
page = await page.getNextPage();
|
|
53
|
+
yield page;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
|
|
58
|
+
for await (const page of this.iterPages()) {
|
|
59
|
+
for (const item of page.getPaginatedItems()) {
|
|
60
|
+
yield item;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* This subclass of Promise will resolve to an instantiated Page once the request completes.
|
|
68
|
+
*
|
|
69
|
+
* It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg:
|
|
70
|
+
*
|
|
71
|
+
* for await (const item of client.items.list()) {
|
|
72
|
+
* console.log(item)
|
|
73
|
+
* }
|
|
74
|
+
*/
|
|
75
|
+
export class PagePromise<
|
|
76
|
+
PageClass extends AbstractPage<Item>,
|
|
77
|
+
Item = ReturnType<PageClass['getPaginatedItems']>[number],
|
|
78
|
+
>
|
|
79
|
+
extends APIPromise<PageClass>
|
|
80
|
+
implements AsyncIterable<Item>
|
|
81
|
+
{
|
|
82
|
+
constructor(
|
|
83
|
+
client: Spitch,
|
|
84
|
+
request: Promise<APIResponseProps>,
|
|
85
|
+
Page: new (...args: ConstructorParameters<typeof AbstractPage>) => PageClass,
|
|
86
|
+
) {
|
|
87
|
+
super(
|
|
88
|
+
client,
|
|
89
|
+
request,
|
|
90
|
+
async (client, props) =>
|
|
91
|
+
new Page(client, props.response, await defaultParseResponse(client, props), props.options),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Allow auto-paginating iteration on an unawaited list call, eg:
|
|
97
|
+
*
|
|
98
|
+
* for await (const item of client.items.list()) {
|
|
99
|
+
* console.log(item)
|
|
100
|
+
* }
|
|
101
|
+
*/
|
|
102
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
|
|
103
|
+
const page = await this;
|
|
104
|
+
for await (const item of page) {
|
|
105
|
+
yield item;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface FilesCursorResponse<Item> {
|
|
111
|
+
items: Array<Item>;
|
|
112
|
+
|
|
113
|
+
next_cursor: string | null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface FilesCursorParams {
|
|
117
|
+
cursor?: string;
|
|
118
|
+
|
|
119
|
+
limit?: number;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export class FilesCursor<Item> extends AbstractPage<Item> implements FilesCursorResponse<Item> {
|
|
123
|
+
items: Array<Item>;
|
|
124
|
+
|
|
125
|
+
next_cursor: string | null;
|
|
126
|
+
|
|
127
|
+
constructor(
|
|
128
|
+
client: Spitch,
|
|
129
|
+
response: Response,
|
|
130
|
+
body: FilesCursorResponse<Item>,
|
|
131
|
+
options: FinalRequestOptions,
|
|
132
|
+
) {
|
|
133
|
+
super(client, response, body, options);
|
|
134
|
+
|
|
135
|
+
this.items = body.items || [];
|
|
136
|
+
this.next_cursor = body.next_cursor || null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
getPaginatedItems(): Item[] {
|
|
140
|
+
return this.items ?? [];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
nextPageRequestOptions(): PageRequestOptions | null {
|
|
144
|
+
const cursor = this.next_cursor;
|
|
145
|
+
if (!cursor) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
...this.options,
|
|
151
|
+
query: {
|
|
152
|
+
...maybeObj(this.options.query),
|
|
153
|
+
cursor,
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { Spitch as default } from './client';
|
|
|
5
5
|
export { type Uploadable, toFile } from './core/uploads';
|
|
6
6
|
export { APIPromise } from './core/api-promise';
|
|
7
7
|
export { Spitch, type ClientOptions } from './client';
|
|
8
|
+
export { PagePromise } from './core/pagination';
|
|
8
9
|
export {
|
|
9
10
|
SpitchError,
|
|
10
11
|
APIError,
|
package/src/internal/to-file.ts
CHANGED
|
@@ -73,7 +73,7 @@ export type ToFileInput =
|
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats
|
|
76
|
-
* @param value the raw content of the file.
|
|
76
|
+
* @param value the raw content of the file. Can be an {@link Uploadable}, BlobLikePart, or AsyncIterable of BlobLikeParts
|
|
77
77
|
* @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible
|
|
78
78
|
* @param {Object=} options additional properties
|
|
79
79
|
* @param {string=} options.type the MIME type of the content
|
|
@@ -76,21 +76,21 @@ export const coerceBoolean = (value: unknown): boolean => {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
export const maybeCoerceInteger = (value: unknown): number | undefined => {
|
|
79
|
-
if (value
|
|
79
|
+
if (value == null) {
|
|
80
80
|
return undefined;
|
|
81
81
|
}
|
|
82
82
|
return coerceInteger(value);
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
export const maybeCoerceFloat = (value: unknown): number | undefined => {
|
|
86
|
-
if (value
|
|
86
|
+
if (value == null) {
|
|
87
87
|
return undefined;
|
|
88
88
|
}
|
|
89
89
|
return coerceFloat(value);
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
export const maybeCoerceBoolean = (value: unknown): boolean | undefined => {
|
|
93
|
-
if (value
|
|
93
|
+
if (value == null) {
|
|
94
94
|
return undefined;
|
|
95
95
|
}
|
|
96
96
|
return coerceBoolean(value);
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../core/resource';
|
|
4
|
+
import { APIPromise } from '../core/api-promise';
|
|
5
|
+
import { FilesCursor, type FilesCursorParams, PagePromise } from '../core/pagination';
|
|
6
|
+
import { type Uploadable } from '../core/uploads';
|
|
7
|
+
import { RequestOptions } from '../internal/request-options';
|
|
8
|
+
import { multipartFormRequestOptions } from '../internal/uploads';
|
|
9
|
+
import { path } from '../internal/utils/path';
|
|
10
|
+
|
|
11
|
+
export class Files extends APIResource {
|
|
12
|
+
/**
|
|
13
|
+
* Get Files
|
|
14
|
+
*/
|
|
15
|
+
list(
|
|
16
|
+
query: FileListParams | null | undefined = {},
|
|
17
|
+
options?: RequestOptions,
|
|
18
|
+
): PagePromise<FilesFilesCursor, File> {
|
|
19
|
+
return this._client.getAPIList('/v1/files', FilesCursor<File>, { query, ...options });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Delete File
|
|
24
|
+
*/
|
|
25
|
+
delete(fileID: string, options?: RequestOptions): APIPromise<FileDeleteResponse> {
|
|
26
|
+
return this._client.delete(path`/v1/files/${fileID}`, options);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Download File
|
|
31
|
+
*/
|
|
32
|
+
download(
|
|
33
|
+
fileID: string,
|
|
34
|
+
query: FileDownloadParams | null | undefined = {},
|
|
35
|
+
options?: RequestOptions,
|
|
36
|
+
): APIPromise<FileDownloadResponse> {
|
|
37
|
+
return this._client.get(path`/v1/files/${fileID}/url`, { query, ...options });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get File
|
|
42
|
+
*/
|
|
43
|
+
get(fileID: string, options?: RequestOptions): APIPromise<File> {
|
|
44
|
+
return this._client.get(path`/v1/files/${fileID}`, options);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Upload File
|
|
49
|
+
*/
|
|
50
|
+
upload(body: FileUploadParams, options?: RequestOptions): APIPromise<File> {
|
|
51
|
+
return this._client.post('/v1/files', multipartFormRequestOptions({ body, ...options }, this._client));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Get Usage
|
|
56
|
+
*/
|
|
57
|
+
usage(options?: RequestOptions): APIPromise<FileUsage> {
|
|
58
|
+
return this._client.get('/v1/files:usage', options);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type FilesFilesCursor = FilesCursor<File>;
|
|
63
|
+
|
|
64
|
+
export interface File {
|
|
65
|
+
category: string | null;
|
|
66
|
+
|
|
67
|
+
content_type: string | null;
|
|
68
|
+
|
|
69
|
+
created_at: string;
|
|
70
|
+
|
|
71
|
+
file_id: string;
|
|
72
|
+
|
|
73
|
+
original_name: string | null;
|
|
74
|
+
|
|
75
|
+
size_bytes: number | null;
|
|
76
|
+
|
|
77
|
+
status: string;
|
|
78
|
+
|
|
79
|
+
uploaded_by: string | null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface FileUsage {
|
|
83
|
+
num_files: number;
|
|
84
|
+
|
|
85
|
+
total: string;
|
|
86
|
+
|
|
87
|
+
total_bytes: number;
|
|
88
|
+
|
|
89
|
+
used: string;
|
|
90
|
+
|
|
91
|
+
used_bytes: number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface Files {
|
|
95
|
+
items: Array<File>;
|
|
96
|
+
|
|
97
|
+
next_cursor?: string | null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface FileDeleteResponse {
|
|
101
|
+
status?: boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface FileDownloadResponse {
|
|
105
|
+
expires_at: string;
|
|
106
|
+
|
|
107
|
+
file_id: string;
|
|
108
|
+
|
|
109
|
+
url: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface FileListParams extends FilesCursorParams {
|
|
113
|
+
status?: 'uploading' | 'ready' | null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface FileDownloadParams {
|
|
117
|
+
ttl?: number;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface FileUploadParams {
|
|
121
|
+
file: Uploadable;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export declare namespace Files {
|
|
125
|
+
export {
|
|
126
|
+
type File as File,
|
|
127
|
+
type FileUsage as FileUsage,
|
|
128
|
+
type Files as Files,
|
|
129
|
+
type FileDeleteResponse as FileDeleteResponse,
|
|
130
|
+
type FileDownloadResponse as FileDownloadResponse,
|
|
131
|
+
type FilesFilesCursor as FilesFilesCursor,
|
|
132
|
+
type FileListParams as FileListParams,
|
|
133
|
+
type FileDownloadParams as FileDownloadParams,
|
|
134
|
+
type FileUploadParams as FileUploadParams,
|
|
135
|
+
};
|
|
136
|
+
}
|
package/src/resources/index.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
type
|
|
9
|
-
|
|
4
|
+
Files,
|
|
5
|
+
type File,
|
|
6
|
+
type FileUsage,
|
|
7
|
+
type FileDeleteResponse,
|
|
8
|
+
type FileDownloadResponse,
|
|
9
|
+
type FileListParams,
|
|
10
|
+
type FileDownloadParams,
|
|
11
|
+
type FileUploadParams,
|
|
12
|
+
type FilesFilesCursor,
|
|
13
|
+
} from './files';
|
|
14
|
+
export { Speech, type Transcription, type SpeechGenerateParams, type SpeechTranscribeParams } from './speech';
|
|
10
15
|
export {
|
|
11
16
|
Text,
|
|
12
|
-
type
|
|
13
|
-
type
|
|
17
|
+
type Diacritics,
|
|
18
|
+
type Translation,
|
|
14
19
|
type TextToneMarkParams,
|
|
15
20
|
type TextTranslateParams,
|
|
16
21
|
} from './text';
|
package/src/resources/speech.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { APIResource } from '../core/resource';
|
|
4
4
|
import { APIPromise } from '../core/api-promise';
|
|
5
5
|
import { type Uploadable } from '../core/uploads';
|
|
6
|
+
import { buildHeaders } from '../internal/headers';
|
|
6
7
|
import { RequestOptions } from '../internal/request-options';
|
|
7
8
|
import { multipartFormRequestOptions } from '../internal/uploads';
|
|
8
9
|
|
|
@@ -10,14 +11,19 @@ export class Speech extends APIResource {
|
|
|
10
11
|
/**
|
|
11
12
|
* Synthesize
|
|
12
13
|
*/
|
|
13
|
-
generate(body: SpeechGenerateParams, options?: RequestOptions): APIPromise<
|
|
14
|
-
return this._client.post('/v1/speech', {
|
|
14
|
+
generate(body: SpeechGenerateParams, options?: RequestOptions): APIPromise<Response> {
|
|
15
|
+
return this._client.post('/v1/speech', {
|
|
16
|
+
body,
|
|
17
|
+
...options,
|
|
18
|
+
headers: buildHeaders([{ Accept: 'audio/wav' }, options?.headers]),
|
|
19
|
+
__binaryResponse: true,
|
|
20
|
+
});
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
/**
|
|
18
24
|
* Transcribe
|
|
19
25
|
*/
|
|
20
|
-
transcribe(body: SpeechTranscribeParams, options?: RequestOptions): APIPromise<
|
|
26
|
+
transcribe(body: SpeechTranscribeParams, options?: RequestOptions): APIPromise<Transcription> {
|
|
21
27
|
return this._client.post(
|
|
22
28
|
'/v1/transcriptions',
|
|
23
29
|
multipartFormRequestOptions({ body, ...options }, this._client),
|
|
@@ -25,17 +31,15 @@ export class Speech extends APIResource {
|
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
export interface SpeechTranscribeResponse {
|
|
34
|
+
export interface Transcription {
|
|
31
35
|
request_id: string;
|
|
32
36
|
|
|
33
37
|
text: string;
|
|
34
38
|
|
|
35
|
-
timestamps?: Array<
|
|
39
|
+
timestamps?: Array<Transcription.Timestamp> | null;
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
export namespace
|
|
42
|
+
export namespace Transcription {
|
|
39
43
|
export interface Timestamp {
|
|
40
44
|
end: number;
|
|
41
45
|
|
|
@@ -74,6 +78,8 @@ export interface SpeechGenerateParams {
|
|
|
74
78
|
| 'tena'
|
|
75
79
|
| 'tesfaye';
|
|
76
80
|
|
|
81
|
+
format?: 'wav' | 'mp3' | 'ogg_opus' | 'webm_opus' | 'flac' | 'pcm_s16le' | 'mulaw' | 'alaw';
|
|
82
|
+
|
|
77
83
|
model?: 'legacy' | null;
|
|
78
84
|
}
|
|
79
85
|
|
|
@@ -82,7 +88,7 @@ export interface SpeechTranscribeParams {
|
|
|
82
88
|
|
|
83
89
|
content?: Uploadable | null;
|
|
84
90
|
|
|
85
|
-
model?: 'mansa_v1' | 'legacy' | null;
|
|
91
|
+
model?: 'mansa_v1' | 'legacy' | 'human' | null;
|
|
86
92
|
|
|
87
93
|
special_words?: string | null;
|
|
88
94
|
|
|
@@ -93,8 +99,7 @@ export interface SpeechTranscribeParams {
|
|
|
93
99
|
|
|
94
100
|
export declare namespace Speech {
|
|
95
101
|
export {
|
|
96
|
-
type
|
|
97
|
-
type SpeechTranscribeResponse as SpeechTranscribeResponse,
|
|
102
|
+
type Transcription as Transcription,
|
|
98
103
|
type SpeechGenerateParams as SpeechGenerateParams,
|
|
99
104
|
type SpeechTranscribeParams as SpeechTranscribeParams,
|
|
100
105
|
};
|
package/src/resources/text.ts
CHANGED
|
@@ -8,25 +8,25 @@ export class Text extends APIResource {
|
|
|
8
8
|
/**
|
|
9
9
|
* Tone Mark
|
|
10
10
|
*/
|
|
11
|
-
toneMark(body: TextToneMarkParams, options?: RequestOptions): APIPromise<
|
|
11
|
+
toneMark(body: TextToneMarkParams, options?: RequestOptions): APIPromise<Diacritics> {
|
|
12
12
|
return this._client.post('/v1/diacritics', { body, ...options });
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Translate
|
|
17
17
|
*/
|
|
18
|
-
translate(body: TextTranslateParams, options?: RequestOptions): APIPromise<
|
|
18
|
+
translate(body: TextTranslateParams, options?: RequestOptions): APIPromise<Translation> {
|
|
19
19
|
return this._client.post('/v1/translate', { body, ...options });
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export interface
|
|
23
|
+
export interface Diacritics {
|
|
24
24
|
request_id: string;
|
|
25
25
|
|
|
26
26
|
text: string;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export interface
|
|
29
|
+
export interface Translation {
|
|
30
30
|
request_id: string;
|
|
31
31
|
|
|
32
32
|
text: string;
|
|
@@ -48,8 +48,8 @@ export interface TextTranslateParams {
|
|
|
48
48
|
|
|
49
49
|
export declare namespace Text {
|
|
50
50
|
export {
|
|
51
|
-
type
|
|
52
|
-
type
|
|
51
|
+
type Diacritics as Diacritics,
|
|
52
|
+
type Translation as Translation,
|
|
53
53
|
type TextToneMarkParams as TextToneMarkParams,
|
|
54
54
|
type TextTranslateParams as TextTranslateParams,
|
|
55
55
|
};
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '1.
|
|
1
|
+
export const VERSION = '1.22.0'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.22.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.22.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '1.
|
|
1
|
+
export const VERSION = '1.22.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|