spitch 1.47.0 → 1.49.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +12 -18
  3. package/client.d.mts +5 -4
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +5 -4
  6. package/client.d.ts.map +1 -1
  7. package/client.js +39 -23
  8. package/client.js.map +1 -1
  9. package/client.mjs +39 -23
  10. package/client.mjs.map +1 -1
  11. package/internal/types.d.mts +6 -6
  12. package/internal/types.d.mts.map +1 -1
  13. package/internal/types.d.ts +6 -6
  14. package/internal/types.d.ts.map +1 -1
  15. package/internal/utils/env.js +2 -2
  16. package/internal/utils/env.js.map +1 -1
  17. package/internal/utils/env.mjs +2 -2
  18. package/internal/utils/env.mjs.map +1 -1
  19. package/internal/utils/query.d.mts +5 -0
  20. package/internal/utils/query.d.mts.map +1 -0
  21. package/internal/utils/query.d.ts +5 -0
  22. package/internal/utils/query.d.ts.map +1 -0
  23. package/internal/utils/query.js +23 -0
  24. package/internal/utils/query.js.map +1 -0
  25. package/internal/utils/query.mjs +20 -0
  26. package/internal/utils/query.mjs.map +1 -0
  27. package/internal/utils.d.mts +1 -0
  28. package/internal/utils.d.ts +1 -0
  29. package/internal/utils.js +1 -0
  30. package/internal/utils.js.map +1 -1
  31. package/internal/utils.mjs +1 -0
  32. package/package.json +12 -1
  33. package/resources/files.d.mts +4 -0
  34. package/resources/files.d.mts.map +1 -1
  35. package/resources/files.d.ts +4 -0
  36. package/resources/files.d.ts.map +1 -1
  37. package/resources/files.js +6 -0
  38. package/resources/files.js.map +1 -1
  39. package/resources/files.mjs +6 -0
  40. package/resources/files.mjs.map +1 -1
  41. package/resources/speech.d.mts +37 -22
  42. package/resources/speech.d.mts.map +1 -1
  43. package/resources/speech.d.ts +37 -22
  44. package/resources/speech.d.ts.map +1 -1
  45. package/resources/speech.js +1 -2
  46. package/resources/speech.js.map +1 -1
  47. package/resources/speech.mjs +1 -2
  48. package/resources/speech.mjs.map +1 -1
  49. package/resources/text.d.mts +24 -4
  50. package/resources/text.d.mts.map +1 -1
  51. package/resources/text.d.ts +24 -4
  52. package/resources/text.d.ts.map +1 -1
  53. package/resources/text.js +1 -1
  54. package/resources/text.mjs +1 -1
  55. package/src/client.ts +50 -30
  56. package/src/internal/types.ts +6 -8
  57. package/src/internal/utils/env.ts +2 -2
  58. package/src/internal/utils/query.ts +23 -0
  59. package/src/internal/utils.ts +1 -0
  60. package/src/resources/files.ts +7 -0
  61. package/src/resources/speech.ts +45 -26
  62. package/src/resources/text.ts +27 -5
  63. package/src/version.ts +1 -1
  64. package/version.d.mts +1 -1
  65. package/version.d.ts +1 -1
  66. package/version.js +1 -1
  67. package/version.mjs +1 -1
@@ -0,0 +1,23 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { SpitchError } from '../../core/error';
4
+
5
+ /**
6
+ * Basic re-implementation of `qs.stringify` for primitive types.
7
+ */
8
+ export function stringifyQuery(query: object | Record<string, unknown>) {
9
+ return Object.entries(query)
10
+ .filter(([_, value]) => typeof value !== 'undefined')
11
+ .map(([key, value]) => {
12
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
13
+ return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
14
+ }
15
+ if (value === null) {
16
+ return `${encodeURIComponent(key)}=`;
17
+ }
18
+ throw new SpitchError(
19
+ `Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
20
+ );
21
+ })
22
+ .join('&');
23
+ }
@@ -6,3 +6,4 @@ export * from './utils/env';
6
6
  export * from './utils/log';
7
7
  export * from './utils/uuid';
8
8
  export * from './utils/sleep';
9
+ export * from './utils/query';
@@ -37,6 +37,13 @@ export class Files extends APIResource {
37
37
  return this._client.get(path`/v1/files/${fileID}/url`, { query, ...options });
38
38
  }
39
39
 
40
+ /**
41
+ * Get File
42
+ */
43
+ get(fileID: string, options?: RequestOptions): APIPromise<FileMeta> {
44
+ return this._client.get(path`/v1/files/${fileID}`, options);
45
+ }
46
+
40
47
  /**
41
48
  * Upload a file to your storage.
42
49
  */
@@ -12,8 +12,7 @@ import { multipartFormRequestOptions } from '../internal/uploads';
12
12
  */
13
13
  export class Speech extends APIResource {
14
14
  /**
15
- * Convert text to speech. Select a voice and use that to generate audio in any
16
- * format. Audio is retured in chunks.
15
+ * Generate audio
17
16
  */
18
17
  generate(body: SpeechGenerateParams, options?: RequestOptions): APIPromise<Response> {
19
18
  return this._client.post('/v1/speech', {
@@ -64,28 +63,26 @@ export interface Transcription {
64
63
  /**
65
64
  * for audit purposes.
66
65
  */
67
- request_id: string;
68
-
69
- text: string;
66
+ request_id?: string;
70
67
 
71
68
  /**
72
- * sentence-level or word-level groupings of your transcript. Each sentence (or
73
- * word) will fall within a time range.
69
+ * Either `sentence-level` or `word-level` groupings of your transcript. Each
70
+ * sentence (or word) will fall within a time range.
74
71
  */
75
72
  segments?: Array<Segment> | null;
76
73
 
77
- /**
78
- * @deprecated sentence-level or word-level groupings of your transcript. Each
79
- * sentence (or word) will fall within a time range.
80
- */
81
- timestamps?: Array<Segment> | null;
74
+ text?: string;
82
75
  }
83
76
 
84
77
  export interface SpeechGenerateParams {
85
- language: 'yo' | 'en' | 'ha' | 'ig' | 'am' | 'pcm';
86
-
78
+ /**
79
+ * The text for which you want to generate audio.
80
+ */
87
81
  text: string;
88
82
 
83
+ /**
84
+ * The voice you want to be used for audio generation.
85
+ */
89
86
  voice:
90
87
  | 'sade'
91
88
  | 'segun'
@@ -101,38 +98,60 @@ export interface SpeechGenerateParams {
101
98
  | 'lucy'
102
99
  | 'henry'
103
100
  | 'kani'
101
+ | 'remi'
102
+ | 'kingsley'
104
103
  | 'ngozi'
105
104
  | 'amara'
106
105
  | 'obinna'
107
106
  | 'ebuka'
108
107
  | 'hana'
109
- | 'selam'
108
+ | 'haile'
110
109
  | 'tena'
111
- | 'tesfaye';
110
+ | 'tesfaye'
111
+ | 'ufoma'
112
+ | 'tega'
113
+ | 'justice'
114
+ | 'boma';
112
115
 
113
116
  /**
114
- * the audio format for the returned audio bytes.
117
+ * The audio format for the returned audio data, defaults to `wav`.
115
118
  */
116
119
  format?: 'mp3' | 'wav' | 'ogg_opus' | 'webm_opus' | 'mulaw' | 'alaw' | 'flac' | 'pcm_s16le';
117
120
 
118
- model?: string | null;
121
+ /**
122
+ * This is optional; an ISO 639 language code to be used for the generation.
123
+ */
124
+ language?: string;
125
+
126
+ /**
127
+ * The speed of the voice, defaults to `1.0`
128
+ */
129
+ speed?: number;
119
130
  }
120
131
 
121
132
  export interface SpeechTranscribeParams {
122
- language: 'yo' | 'en' | 'ha' | 'ig' | 'am' | 'pcm';
133
+ /**
134
+ * The audio file or content that you want to transcribe. This could be;
135
+ * `file bytes`, a `url to an audio file` (ensure the link does not require
136
+ * authentication to access the file) or a `file UUID`.
137
+ */
138
+ content: Uploadable | string;
123
139
 
124
- content?: Uploadable | string | null;
140
+ /**
141
+ * This is optional, an ISO-639 language code that corresponds to the language in
142
+ * the `content`.
143
+ */
144
+ language?: string | null;
125
145
 
146
+ /**
147
+ * @deprecated Select the model to be used to perform the transcription, this param
148
+ * has been deprecated.
149
+ */
126
150
  model?: 'mansa_v1' | 'legacy' | null;
127
151
 
128
152
  special_words?: string | null;
129
153
 
130
- timestamp?: 'sentence' | 'word' | 'none' | null;
131
-
132
- /**
133
- * @deprecated
134
- */
135
- url?: string | null;
154
+ timestamp?: 'sentence' | 'word' | null;
136
155
  }
137
156
 
138
157
  export declare namespace Speech {
@@ -6,7 +6,7 @@ import { RequestOptions } from '../internal/request-options';
6
6
 
7
7
  export class Text extends APIResource {
8
8
  /**
9
- * Add appopriate tone marks to text.
9
+ * Add appropriate tone marks to text.
10
10
  */
11
11
  toneMark(body: TextToneMarkParams, options?: RequestOptions): APIPromise<Diacritics> {
12
12
  return this._client.post('/v1/diacritics', { body, ...options });
@@ -34,17 +34,39 @@ export interface Translation {
34
34
  }
35
35
 
36
36
  export interface TextToneMarkParams {
37
- language: 'yo' | 'en' | 'ha' | 'ig' | 'am' | 'pcm';
37
+ /**
38
+ * Only Yoruba is supported at the moment.
39
+ */
40
+ language: string;
38
41
 
39
42
  text: string;
40
43
  }
41
44
 
42
45
  export interface TextTranslateParams {
43
- source: 'yo' | 'en' | 'ha' | 'ig' | 'am' | 'pcm';
44
-
45
- target: 'yo' | 'en' | 'ha' | 'ig' | 'am' | 'pcm';
46
+ /**
47
+ * An ISO 639 code of the language you want to translate to.
48
+ */
49
+ target: string;
46
50
 
51
+ /**
52
+ * The text to be translated.
53
+ */
47
54
  text: string;
55
+
56
+ /**
57
+ * Whether to be `formal` or `casual`.
58
+ */
59
+ formality?: 'casual' | 'formal';
60
+
61
+ /**
62
+ * An ISO 639 code of the language you're translating from
63
+ */
64
+ source?: string | null;
65
+
66
+ /**
67
+ * The tone of the translated text.
68
+ */
69
+ tone?: 'neutral' | 'warm' | 'professional' | 'narration';
48
70
  }
49
71
 
50
72
  export declare namespace Text {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.47.0'; // x-release-please-version
1
+ export const VERSION = '1.49.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.47.0";
1
+ export declare const VERSION = "1.49.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.47.0";
1
+ export declare const VERSION = "1.49.0";
2
2
  //# sourceMappingURL=version.d.ts.map
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 = '1.47.0'; // x-release-please-version
4
+ exports.VERSION = '1.49.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '1.47.0'; // x-release-please-version
1
+ export const VERSION = '1.49.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map