spitch 0.0.1-alpha.1 → 1.16.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +4 -5
  2. package/LICENSE +1 -1
  3. package/README.md +61 -27
  4. package/_shims/index.d.ts +2 -0
  5. package/_shims/index.js +5 -1
  6. package/_shims/index.mjs +5 -1
  7. package/_shims/web-runtime.js +1 -1
  8. package/_shims/web-runtime.js.map +1 -1
  9. package/_shims/web-runtime.mjs +1 -1
  10. package/_shims/web-runtime.mjs.map +1 -1
  11. package/core.d.ts +22 -9
  12. package/core.d.ts.map +1 -1
  13. package/core.js +50 -29
  14. package/core.js.map +1 -1
  15. package/core.mjs +51 -30
  16. package/core.mjs.map +1 -1
  17. package/error.d.ts +18 -24
  18. package/error.d.ts.map +1 -1
  19. package/error.js +1 -31
  20. package/error.js.map +1 -1
  21. package/error.mjs +1 -31
  22. package/error.mjs.map +1 -1
  23. package/index.d.mts +15 -18
  24. package/index.d.ts +15 -18
  25. package/index.d.ts.map +1 -1
  26. package/index.js +29 -11
  27. package/index.js.map +1 -1
  28. package/index.mjs +13 -10
  29. package/index.mjs.map +1 -1
  30. package/package.json +4 -4
  31. package/resource.d.ts +1 -1
  32. package/resource.d.ts.map +1 -1
  33. package/resource.js.map +1 -1
  34. package/resource.mjs.map +1 -1
  35. package/resources/index.d.ts +2 -2
  36. package/resources/index.d.ts.map +1 -1
  37. package/resources/index.js.map +1 -1
  38. package/resources/index.mjs +2 -2
  39. package/resources/index.mjs.map +1 -1
  40. package/resources/speech.d.ts +24 -13
  41. package/resources/speech.d.ts.map +1 -1
  42. package/resources/speech.js +8 -4
  43. package/resources/speech.js.map +1 -1
  44. package/resources/speech.mjs +8 -4
  45. package/resources/speech.mjs.map +1 -1
  46. package/resources/text.d.ts +20 -6
  47. package/resources/text.d.ts.map +1 -1
  48. package/resources/text.js +6 -2
  49. package/resources/text.js.map +1 -1
  50. package/resources/text.mjs +6 -2
  51. package/resources/text.mjs.map +1 -1
  52. package/resources.d.ts +2 -0
  53. package/resources.d.ts.map +1 -0
  54. package/resources.js +18 -0
  55. package/resources.js.map +1 -0
  56. package/resources.mjs +2 -0
  57. package/resources.mjs.map +1 -0
  58. package/src/_shims/index.d.ts +2 -0
  59. package/src/_shims/index.js +5 -1
  60. package/src/_shims/index.mjs +5 -1
  61. package/src/_shims/web-runtime.ts +1 -1
  62. package/src/core.ts +81 -37
  63. package/src/error.ts +25 -41
  64. package/src/index.ts +52 -25
  65. package/src/resource.ts +1 -1
  66. package/src/resources/index.ts +13 -2
  67. package/src/resources/speech.ts +69 -15
  68. package/src/resources/text.ts +38 -7
  69. package/src/resources.ts +1 -0
  70. package/src/version.ts +1 -1
  71. package/version.d.ts +1 -1
  72. package/version.d.ts.map +1 -1
  73. package/version.js +1 -1
  74. package/version.js.map +1 -1
  75. package/version.mjs +1 -1
  76. package/version.mjs.map +1 -1
package/src/index.ts CHANGED
@@ -1,10 +1,23 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import * as Errors from './error';
4
- import * as Uploads from './uploads';
5
3
  import { type Agent } from './_shims/index';
6
4
  import * as Core from './core';
5
+ import * as Errors from './error';
6
+ import * as Uploads from './uploads';
7
7
  import * as API from './resources/index';
8
+ import {
9
+ Speech,
10
+ SpeechGenerateParams,
11
+ SpeechTranscribeParams,
12
+ SpeechTranscribeResponse,
13
+ } from './resources/speech';
14
+ import {
15
+ Text,
16
+ TextToneMarkParams,
17
+ TextToneMarkResponse,
18
+ TextTranslateParams,
19
+ TextTranslateResponse,
20
+ } from './resources/text';
8
21
 
9
22
  export interface ClientOptions {
10
23
  /**
@@ -26,7 +39,7 @@ export interface ClientOptions {
26
39
  * Note that request timeouts are retried by default, so in a worst-case scenario you may wait
27
40
  * much longer than this timeout before the promise succeeds or fails.
28
41
  */
29
- timeout?: number;
42
+ timeout?: number | undefined;
30
43
 
31
44
  /**
32
45
  * An HTTP agent used to manage HTTP(S) connections.
@@ -34,7 +47,7 @@ export interface ClientOptions {
34
47
  * If not provided, an agent will be constructed by default in the Node.js environment,
35
48
  * otherwise no agent is used.
36
49
  */
37
- httpAgent?: Agent;
50
+ httpAgent?: Agent | undefined;
38
51
 
39
52
  /**
40
53
  * Specify a custom `fetch` function implementation.
@@ -50,7 +63,7 @@ export interface ClientOptions {
50
63
  *
51
64
  * @default 2
52
65
  */
53
- maxRetries?: number;
66
+ maxRetries?: number | undefined;
54
67
 
55
68
  /**
56
69
  * Default headers to include with every request to the API.
@@ -58,7 +71,7 @@ export interface ClientOptions {
58
71
  * These can be removed in individual requests by explicitly setting the
59
72
  * header to `undefined` or `null` in request options.
60
73
  */
61
- defaultHeaders?: Core.Headers;
74
+ defaultHeaders?: Core.Headers | undefined;
62
75
 
63
76
  /**
64
77
  * Default query parameters to include with every request to the API.
@@ -66,7 +79,7 @@ export interface ClientOptions {
66
79
  * These can be removed in individual requests by explicitly setting the
67
80
  * param to `undefined` in request options.
68
81
  */
69
- defaultQuery?: Core.DefaultQuery;
82
+ defaultQuery?: Core.DefaultQuery | undefined;
70
83
  }
71
84
 
72
85
  /**
@@ -108,6 +121,7 @@ export class Spitch extends Core.APIClient {
108
121
 
109
122
  super({
110
123
  baseURL: options.baseURL!,
124
+ baseURLOverridden: baseURL ? baseURL !== 'https://api.spi-tch.com' : false,
111
125
  timeout: options.timeout ?? 60000 /* 1 minute */,
112
126
  httpAgent: options.httpAgent,
113
127
  maxRetries: options.maxRetries,
@@ -122,6 +136,13 @@ export class Spitch extends Core.APIClient {
122
136
  speech: API.Speech = new API.Speech(this);
123
137
  text: API.Text = new API.Text(this);
124
138
 
139
+ /**
140
+ * Check whether the base URL is set to its default.
141
+ */
142
+ #baseURLOverridden(): boolean {
143
+ return this.baseURL !== 'https://api.spi-tch.com';
144
+ }
145
+
125
146
  protected override defaultQuery(): Core.DefaultQuery | undefined {
126
147
  return this._options.defaultQuery;
127
148
  }
@@ -158,7 +179,29 @@ export class Spitch extends Core.APIClient {
158
179
  static fileFromPath = Uploads.fileFromPath;
159
180
  }
160
181
 
161
- export const {
182
+ Spitch.Speech = Speech;
183
+ Spitch.Text = Text;
184
+ export declare namespace Spitch {
185
+ export type RequestOptions = Core.RequestOptions;
186
+
187
+ export {
188
+ Speech as Speech,
189
+ type SpeechTranscribeResponse as SpeechTranscribeResponse,
190
+ type SpeechGenerateParams as SpeechGenerateParams,
191
+ type SpeechTranscribeParams as SpeechTranscribeParams,
192
+ };
193
+
194
+ export {
195
+ Text as Text,
196
+ type TextToneMarkResponse as TextToneMarkResponse,
197
+ type TextTranslateResponse as TextTranslateResponse,
198
+ type TextToneMarkParams as TextToneMarkParams,
199
+ type TextTranslateParams as TextTranslateParams,
200
+ };
201
+ }
202
+
203
+ export { toFile, fileFromPath } from './uploads';
204
+ export {
162
205
  SpitchError,
163
206
  APIError,
164
207
  APIConnectionError,
@@ -172,22 +215,6 @@ export const {
172
215
  InternalServerError,
173
216
  PermissionDeniedError,
174
217
  UnprocessableEntityError,
175
- } = Errors;
176
-
177
- export import toFile = Uploads.toFile;
178
- export import fileFromPath = Uploads.fileFromPath;
179
-
180
- export namespace Spitch {
181
- export import RequestOptions = Core.RequestOptions;
182
-
183
- export import Speech = API.Speech;
184
- export import SpeechTranscibeResponse = API.SpeechTranscibeResponse;
185
- export import SpeechGenerateParams = API.SpeechGenerateParams;
186
- export import SpeechTranscibeParams = API.SpeechTranscibeParams;
187
-
188
- export import Text = API.Text;
189
- export import TextToneMarkResponse = API.TextToneMarkResponse;
190
- export import TextToneMarkParams = API.TextToneMarkParams;
191
- }
218
+ } from './error';
192
219
 
193
220
  export default Spitch;
package/src/resource.ts CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import type { Spitch } from './index';
4
4
 
5
- export class APIResource {
5
+ export abstract class APIResource {
6
6
  protected _client: Spitch;
7
7
 
8
8
  constructor(client: Spitch) {
@@ -1,4 +1,15 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- export { SpeechTranscibeResponse, SpeechGenerateParams, SpeechTranscibeParams, Speech } from './speech';
4
- export { TextToneMarkResponse, TextToneMarkParams, Text } from './text';
3
+ export {
4
+ Speech,
5
+ type SpeechTranscribeResponse,
6
+ type SpeechGenerateParams,
7
+ type SpeechTranscribeParams,
8
+ } from './speech';
9
+ export {
10
+ Text,
11
+ type TextToneMarkResponse,
12
+ type TextTranslateResponse,
13
+ type TextToneMarkParams,
14
+ type TextTranslateParams,
15
+ } from './text';
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { APIResource } from '../resource';
4
4
  import * as Core from '../core';
5
- import * as SpeechAPI from './speech';
6
5
  import { type Response } from '../_shims/index';
7
6
 
8
7
  export class Speech extends APIResource {
@@ -11,24 +10,51 @@ export class Speech extends APIResource {
11
10
  */
12
11
  generate(params: SpeechGenerateParams, options?: Core.RequestOptions): Core.APIPromise<Response> {
13
12
  const { stream, ...body } = params;
14
- return this._client.post('/v1/speech', { query: { stream }, body, ...options, __binaryResponse: true });
13
+ return this._client.post('/v1/speech', {
14
+ query: { stream },
15
+ body,
16
+ ...options,
17
+ headers: { Accept: 'audio/wav', ...options?.headers },
18
+ __binaryResponse: true,
19
+ });
15
20
  }
16
21
 
17
22
  /**
18
23
  * Transcribe
19
24
  */
20
- transcibe(body: SpeechTranscibeParams, options?: Core.RequestOptions): Core.APIPromise<unknown> {
25
+ transcribe(
26
+ body: SpeechTranscribeParams,
27
+ options?: Core.RequestOptions,
28
+ ): Core.APIPromise<SpeechTranscribeResponse> {
21
29
  return this._client.post('/v1/transcriptions', Core.multipartFormRequestOptions({ body, ...options }));
22
30
  }
23
31
  }
24
32
 
25
- export type SpeechTranscibeResponse = unknown;
33
+ export interface SpeechTranscribeResponse {
34
+ request_id: string;
35
+
36
+ segments?: Array<SpeechTranscribeResponse.Segment | null>;
37
+
38
+ text?: string | null;
39
+ }
40
+
41
+ export namespace SpeechTranscribeResponse {
42
+ export interface Segment {
43
+ end?: number;
44
+
45
+ speaker?: number | null;
46
+
47
+ start?: number;
48
+
49
+ text?: number;
50
+ }
51
+ }
26
52
 
27
53
  export interface SpeechGenerateParams {
28
54
  /**
29
55
  * Body param:
30
56
  */
31
- language: 'yo' | 'en' | 'ha' | 'ig';
57
+ language: 'yo' | 'en' | 'ha' | 'ig' | 'am';
32
58
 
33
59
  /**
34
60
  * Body param:
@@ -36,26 +62,54 @@ export interface SpeechGenerateParams {
36
62
  text: string;
37
63
 
38
64
  /**
39
- * Query param:
65
+ * Body param:
40
66
  */
41
- stream?: boolean;
67
+ voice:
68
+ | 'sade'
69
+ | 'segun'
70
+ | 'femi'
71
+ | 'funmi'
72
+ | 'amina'
73
+ | 'aliyu'
74
+ | 'hasan'
75
+ | 'zainab'
76
+ | 'ngozi'
77
+ | 'amara'
78
+ | 'ebuka'
79
+ | 'obinna'
80
+ | 'lucy'
81
+ | 'lina'
82
+ | 'john'
83
+ | 'jude'
84
+ | 'henry'
85
+ | 'kani'
86
+ | 'hana'
87
+ | 'selam'
88
+ | 'tena'
89
+ | 'tesfaye';
42
90
 
43
91
  /**
44
- * Body param:
92
+ * Query param:
45
93
  */
46
- voice?: 'sade' | 'segun' | 'femi' | 'funmi';
94
+ stream?: boolean;
47
95
  }
48
96
 
49
- export interface SpeechTranscibeParams {
50
- language: 'yo' | 'en' | 'ha' | 'ig';
97
+ export interface SpeechTranscribeParams {
98
+ language: 'yo' | 'en' | 'ha' | 'ig' | 'am';
51
99
 
52
100
  content?: Core.Uploadable | null;
53
101
 
102
+ multispeaker?: boolean | null;
103
+
104
+ timestamp?: boolean | null;
105
+
54
106
  url?: string | null;
55
107
  }
56
108
 
57
- export namespace Speech {
58
- export import SpeechTranscibeResponse = SpeechAPI.SpeechTranscibeResponse;
59
- export import SpeechGenerateParams = SpeechAPI.SpeechGenerateParams;
60
- export import SpeechTranscibeParams = SpeechAPI.SpeechTranscibeParams;
109
+ export declare namespace Speech {
110
+ export {
111
+ type SpeechTranscribeResponse as SpeechTranscribeResponse,
112
+ type SpeechGenerateParams as SpeechGenerateParams,
113
+ type SpeechTranscribeParams as SpeechTranscribeParams,
114
+ };
61
115
  }
@@ -2,26 +2,57 @@
2
2
 
3
3
  import { APIResource } from '../resource';
4
4
  import * as Core from '../core';
5
- import * as TextAPI from './text';
6
5
 
7
6
  export class Text extends APIResource {
8
7
  /**
9
8
  * Tone Mark
10
9
  */
11
- toneMark(body: TextToneMarkParams, options?: Core.RequestOptions): Core.APIPromise<unknown> {
10
+ toneMark(body: TextToneMarkParams, options?: Core.RequestOptions): Core.APIPromise<TextToneMarkResponse> {
12
11
  return this._client.post('/v1/diacritics', { body, ...options });
13
12
  }
13
+
14
+ /**
15
+ * Translate
16
+ */
17
+ translate(
18
+ body: TextTranslateParams,
19
+ options?: Core.RequestOptions,
20
+ ): Core.APIPromise<TextTranslateResponse> {
21
+ return this._client.post('/v1/translate', { body, ...options });
22
+ }
23
+ }
24
+
25
+ export interface TextToneMarkResponse {
26
+ request_id: string;
27
+
28
+ text?: string;
14
29
  }
15
30
 
16
- export type TextToneMarkResponse = unknown;
31
+ export interface TextTranslateResponse {
32
+ request_id: string;
33
+
34
+ text?: string;
35
+ }
17
36
 
18
37
  export interface TextToneMarkParams {
19
- language: 'yo' | 'en' | 'ha' | 'ig';
38
+ language: 'yo' | 'en' | 'ha' | 'ig' | 'am';
39
+
40
+ text: string;
41
+ }
42
+
43
+ export interface TextTranslateParams {
44
+ source: 'yo' | 'en' | 'ha' | 'ig' | 'am';
45
+
46
+ target: 'yo' | 'en' | 'ha' | 'ig' | 'am';
20
47
 
21
48
  text: string;
22
49
  }
23
50
 
24
- export namespace Text {
25
- export import TextToneMarkResponse = TextAPI.TextToneMarkResponse;
26
- export import TextToneMarkParams = TextAPI.TextToneMarkParams;
51
+ export declare namespace Text {
52
+ export {
53
+ type TextToneMarkResponse as TextToneMarkResponse,
54
+ type TextTranslateResponse as TextTranslateResponse,
55
+ type TextToneMarkParams as TextToneMarkParams,
56
+ type TextTranslateParams as TextTranslateParams,
57
+ };
27
58
  }
@@ -0,0 +1 @@
1
+ export * from './resources/index';
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.0.1-alpha.1'; // x-release-please-version
1
+ export const VERSION = '1.16.1'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.0.1-alpha.1";
1
+ export declare const VERSION = "1.16.1";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,kBAAkB,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.0.1-alpha.1'; // x-release-please-version
4
+ exports.VERSION = '1.16.1'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,eAAe,CAAC,CAAC,2BAA2B"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,QAAQ,CAAC,CAAC,2BAA2B"}
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.0.1-alpha.1'; // x-release-please-version
1
+ export const VERSION = '1.16.1'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map
package/version.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC,CAAC,2BAA2B"}
1
+ {"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,2BAA2B"}