@maxim_mazurok/gapi.client.texttospeech-v1 0.0.20220808

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/index.d.ts ADDED
@@ -0,0 +1,210 @@
1
+ /* Type definitions for non-npm package Cloud Text-to-Speech API v1 0.0 */
2
+ // Project: https://cloud.google.com/text-to-speech/
3
+ // Definitions by: Maxim Mazurok <https://github.com/Maxim-Mazurok>
4
+ // Nick Amoscato <https://github.com/namoscato>
5
+ // Declan Vong <https://github.com/declanvong>
6
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7
+ // TypeScript Version: 2.8
8
+
9
+ // IMPORTANT
10
+ // This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
11
+ // In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
12
+ // Generated from: https://texttospeech.googleapis.com/$discovery/rest?version=v1
13
+ // Revision: 20220808
14
+
15
+ /// <reference types="gapi.client" />
16
+
17
+ declare namespace gapi.client {
18
+ /** Load Cloud Text-to-Speech API v1 */
19
+ function load(urlOrObject: "https://texttospeech.googleapis.com/$discovery/rest?version=v1"): Promise<void>;
20
+ /** @deprecated Please load APIs with discovery documents. */
21
+ function load(name: "texttospeech", version: "v1"): Promise<void>;
22
+ /** @deprecated Please load APIs with discovery documents. */
23
+ function load(name: "texttospeech", version: "v1", callback: () => any): void;
24
+
25
+ namespace texttospeech {
26
+ interface AudioConfig {
27
+ /** Required. The format of the audio byte stream. */
28
+ audioEncoding?: string;
29
+ /**
30
+ * Optional. Input only. An identifier which selects 'audio effects' profiles that are applied on (post synthesized) text to speech. Effects are applied on top of each other in the
31
+ * order they are given. See [audio profiles](https://cloud.google.com/text-to-speech/docs/audio-profiles) for current supported profile ids.
32
+ */
33
+ effectsProfileId?: string[];
34
+ /** Optional. Input only. Speaking pitch, in the range [-20.0, 20.0]. 20 means increase 20 semitones from the original pitch. -20 means decrease 20 semitones from the original pitch. */
35
+ pitch?: number;
36
+ /**
37
+ * Optional. The synthesis sample rate (in hertz) for this audio. When this is specified in SynthesizeSpeechRequest, if this is different from the voice's natural sample rate, then the
38
+ * synthesizer will honor this request by converting to the desired sample rate (which might result in worse audio quality), unless the specified sample rate is not supported for the
39
+ * encoding chosen, in which case it will fail the request and return google.rpc.Code.INVALID_ARGUMENT.
40
+ */
41
+ sampleRateHertz?: number;
42
+ /**
43
+ * Optional. Input only. Speaking rate/speed, in the range [0.25, 4.0]. 1.0 is the normal native speed supported by the specific voice. 2.0 is twice as fast, and 0.5 is half as fast.
44
+ * If unset(0.0), defaults to the native 1.0 speed. Any other values < 0.25 or > 4.0 will return an error.
45
+ */
46
+ speakingRate?: number;
47
+ /**
48
+ * Optional. Input only. Volume gain (in dB) of the normal native volume supported by the specific voice, in the range [-96.0, 16.0]. If unset, or set to a value of 0.0 (dB), will play
49
+ * at normal native signal amplitude. A value of -6.0 (dB) will play at approximately half the amplitude of the normal native signal amplitude. A value of +6.0 (dB) will play at
50
+ * approximately twice the amplitude of the normal native signal amplitude. Strongly recommend not to exceed +10 (dB) as there's usually no effective increase in loudness for any value
51
+ * greater than that.
52
+ */
53
+ volumeGainDb?: number;
54
+ }
55
+ interface CustomVoiceParams {
56
+ /** Required. The name of the AutoML model that synthesizes the custom voice. */
57
+ model?: string;
58
+ /** Optional. The usage of the synthesized audio to be reported. */
59
+ reportedUsage?: string;
60
+ }
61
+ interface ListVoicesResponse {
62
+ /** The list of voices. */
63
+ voices?: Voice[];
64
+ }
65
+ interface SynthesisInput {
66
+ /**
67
+ * The SSML document to be synthesized. The SSML document must be valid and well-formed. Otherwise the RPC will fail and return google.rpc.Code.INVALID_ARGUMENT. For more information,
68
+ * see [SSML](https://cloud.google.com/text-to-speech/docs/ssml).
69
+ */
70
+ ssml?: string;
71
+ /** The raw text to be synthesized. */
72
+ text?: string;
73
+ }
74
+ interface SynthesizeSpeechRequest {
75
+ /** Required. The configuration of the synthesized audio. */
76
+ audioConfig?: AudioConfig;
77
+ /** Required. The Synthesizer requires either plain text or SSML as input. */
78
+ input?: SynthesisInput;
79
+ /** Required. The desired voice of the synthesized audio. */
80
+ voice?: VoiceSelectionParams;
81
+ }
82
+ interface SynthesizeSpeechResponse {
83
+ /**
84
+ * The audio data bytes encoded as specified in the request, including the header for encodings that are wrapped in containers (e.g. MP3, OGG_OPUS). For LINEAR16 audio, we include the
85
+ * WAV header. Note: as with all bytes fields, protobuffers use a pure binary representation, whereas JSON representations use base64.
86
+ */
87
+ audioContent?: string;
88
+ }
89
+ interface Voice {
90
+ /** The languages that this voice supports, expressed as [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags (e.g. "en-US", "es-419", "cmn-tw"). */
91
+ languageCodes?: string[];
92
+ /** The name of this voice. Each distinct voice has a unique name. */
93
+ name?: string;
94
+ /** The natural sample rate (in hertz) for this voice. */
95
+ naturalSampleRateHertz?: number;
96
+ /** The gender of this voice. */
97
+ ssmlGender?: string;
98
+ }
99
+ interface VoiceSelectionParams {
100
+ /** The configuration for a custom voice. If [CustomVoiceParams.model] is set, the service will choose the custom voice matching the specified configuration. */
101
+ customVoice?: CustomVoiceParams;
102
+ /**
103
+ * Required. The language (and potentially also the region) of the voice expressed as a [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag, e.g. "en-US". This should
104
+ * not include a script tag (e.g. use "cmn-cn" rather than "cmn-Hant-cn"), because the script will be inferred from the input provided in the SynthesisInput. The TTS service will use
105
+ * this parameter to help choose an appropriate voice. Note that the TTS service may choose a voice with a slightly different language code than the one selected; it may substitute a
106
+ * different region (e.g. using en-US rather than en-CA if there isn't a Canadian voice available), or even a different language, e.g. using "nb" (Norwegian Bokmal) instead of "no"
107
+ * (Norwegian)".
108
+ */
109
+ languageCode?: string;
110
+ /** The name of the voice. If not set, the service will choose a voice based on the other parameters such as language_code and gender. */
111
+ name?: string;
112
+ /**
113
+ * The preferred gender of the voice. If not set, the service will choose a voice based on the other parameters such as language_code and name. Note that this is only a preference, not
114
+ * requirement; if a voice of the appropriate gender is not available, the synthesizer should substitute a voice with a different gender rather than failing the request.
115
+ */
116
+ ssmlGender?: string;
117
+ }
118
+ interface TextResource {
119
+ /** Synthesizes speech synchronously: receive results after all text input has been processed. */
120
+ synthesize(request: {
121
+ /** V1 error format. */
122
+ "$.xgafv"?: string;
123
+ /** OAuth access token. */
124
+ access_token?: string;
125
+ /** Data format for response. */
126
+ alt?: string;
127
+ /** JSONP */
128
+ callback?: string;
129
+ /** Selector specifying which fields to include in a partial response. */
130
+ fields?: string;
131
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
132
+ key?: string;
133
+ /** OAuth 2.0 token for the current user. */
134
+ oauth_token?: string;
135
+ /** Returns response with indentations and line breaks. */
136
+ prettyPrint?: boolean;
137
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
138
+ quotaUser?: string;
139
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
140
+ upload_protocol?: string;
141
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
142
+ uploadType?: string;
143
+ /** Request body */
144
+ resource: SynthesizeSpeechRequest;
145
+ }): Request<SynthesizeSpeechResponse>;
146
+ synthesize(request: {
147
+ /** V1 error format. */
148
+ "$.xgafv"?: string;
149
+ /** OAuth access token. */
150
+ access_token?: string;
151
+ /** Data format for response. */
152
+ alt?: string;
153
+ /** JSONP */
154
+ callback?: string;
155
+ /** Selector specifying which fields to include in a partial response. */
156
+ fields?: string;
157
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
158
+ key?: string;
159
+ /** OAuth 2.0 token for the current user. */
160
+ oauth_token?: string;
161
+ /** Returns response with indentations and line breaks. */
162
+ prettyPrint?: boolean;
163
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
164
+ quotaUser?: string;
165
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
166
+ upload_protocol?: string;
167
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
168
+ uploadType?: string;
169
+ },
170
+ body: SynthesizeSpeechRequest): Request<SynthesizeSpeechResponse>;
171
+ }
172
+ interface VoicesResource {
173
+ /** Returns a list of Voice supported for synthesis. */
174
+ list(request?: {
175
+ /** V1 error format. */
176
+ "$.xgafv"?: string;
177
+ /** OAuth access token. */
178
+ access_token?: string;
179
+ /** Data format for response. */
180
+ alt?: string;
181
+ /** JSONP */
182
+ callback?: string;
183
+ /** Selector specifying which fields to include in a partial response. */
184
+ fields?: string;
185
+ /** API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */
186
+ key?: string;
187
+ /**
188
+ * Optional. Recommended. [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. If not specified, the API will return all supported voices. If specified, the
189
+ * ListVoices call will only return voices that can be used to synthesize this language_code. For example, if you specify `"en-NZ"`, all `"en-NZ"` voices will be returned. If you
190
+ * specify `"no"`, both `"no-\*"` (Norwegian) and `"nb-\*"` (Norwegian Bokmal) voices will be returned.
191
+ */
192
+ languageCode?: string;
193
+ /** OAuth 2.0 token for the current user. */
194
+ oauth_token?: string;
195
+ /** Returns response with indentations and line breaks. */
196
+ prettyPrint?: boolean;
197
+ /** Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */
198
+ quotaUser?: string;
199
+ /** Upload protocol for media (e.g. "raw", "multipart"). */
200
+ upload_protocol?: string;
201
+ /** Legacy upload protocol for media (e.g. "media", "multipart"). */
202
+ uploadType?: string;
203
+ }): Request<ListVoicesResponse>;
204
+ }
205
+
206
+ const text: TextResource;
207
+
208
+ const voices: VoicesResource;
209
+ }
210
+ }
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@maxim_mazurok/gapi.client.texttospeech-v1",
3
+ "version": "0.0.20220808",
4
+ "description": "TypeScript typings for Cloud Text-to-Speech API v1",
5
+ "license": "MIT",
6
+ "author": {
7
+ "email": "maxim@mazurok.com",
8
+ "name": "Maxim Mazurok",
9
+ "url": "https://maxim.mazurok.com"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/Maxim-Mazurok/google-api-typings-generator.git"
14
+ },
15
+ "types": "index.d.ts",
16
+ "dependencies": {
17
+ "@types/gapi.client": "*",
18
+ "@types/gapi.client.discovery": "*"
19
+ }
20
+ }
package/readme.md ADDED
@@ -0,0 +1,78 @@
1
+ # TypeScript typings for Cloud Text-to-Speech API v1
2
+
3
+ Synthesizes natural-sounding speech by applying powerful neural network models.
4
+ For detailed description please check [documentation](https://cloud.google.com/text-to-speech/).
5
+
6
+ ## Installing
7
+
8
+ Install typings for Cloud Text-to-Speech API:
9
+
10
+ ```
11
+ npm install @types/gapi.client.texttospeech-v1 --save-dev
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ You need to initialize Google API client in your code:
17
+
18
+ ```typescript
19
+ gapi.load('client', () => {
20
+ // now we can use gapi.client
21
+ // ...
22
+ });
23
+ ```
24
+
25
+ Then load api client wrapper:
26
+
27
+ ```typescript
28
+ gapi.client.load('https://texttospeech.googleapis.com/$discovery/rest?version=v1', () => {
29
+ // now we can use:
30
+ // gapi.client.texttospeech
31
+ });
32
+ ```
33
+
34
+ ```typescript
35
+ // Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
36
+ gapi.client.load('texttospeech', 'v1', () => {
37
+ // now we can use:
38
+ // gapi.client.texttospeech
39
+ });
40
+ ```
41
+
42
+ Don't forget to authenticate your client before sending any request to resources:
43
+
44
+ ```typescript
45
+ // declare client_id registered in Google Developers Console
46
+ var client_id = '',
47
+ scope = [
48
+ // See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
49
+ 'https://www.googleapis.com/auth/cloud-platform',
50
+ ],
51
+ immediate = true;
52
+ // ...
53
+
54
+ gapi.auth.authorize(
55
+ { client_id: client_id, scope: scope, immediate: immediate },
56
+ authResult => {
57
+ if (authResult && !authResult.error) {
58
+ /* handle successful authorization */
59
+ } else {
60
+ /* handle authorization error */
61
+ }
62
+ });
63
+ ```
64
+
65
+ After that you can use Cloud Text-to-Speech API resources: <!-- TODO: make this work for multiple namespaces -->
66
+
67
+ ```typescript
68
+
69
+ /*
70
+ Synthesizes speech synchronously: receive results after all text input has been processed.
71
+ */
72
+ await gapi.client.texttospeech.text.synthesize({ });
73
+
74
+ /*
75
+ Returns a list of Voice supported for synthesis.
76
+ */
77
+ await gapi.client.texttospeech.voices.list({ });
78
+ ```
package/tests.ts ADDED
@@ -0,0 +1,64 @@
1
+ /* This is stub file for gapi.client.texttospeech-v1 definition tests */
2
+ // IMPORTANT
3
+ // This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator. Please do not edit it manually.
4
+ // In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator
5
+
6
+ // Revision: 20220808
7
+
8
+ gapi.load('client', async () => {
9
+ /** now we can use gapi.client */
10
+
11
+ await gapi.client.load('https://texttospeech.googleapis.com/$discovery/rest?version=v1');
12
+ /** now we can use gapi.client.texttospeech */
13
+
14
+ /** don't forget to authenticate your client before sending any request to resources: */
15
+ /** declare client_id registered in Google Developers Console */
16
+ const client_id = '<<PUT YOUR CLIENT ID HERE>>';
17
+ const scope = [
18
+ /** See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account. */
19
+ 'https://www.googleapis.com/auth/cloud-platform',
20
+ ];
21
+ const immediate = false;
22
+ gapi.auth.authorize({ client_id, scope, immediate }, authResult => {
23
+ if (authResult && !authResult.error) {
24
+ /** handle successful authorization */
25
+ run();
26
+ } else {
27
+ /** handle authorization error */
28
+ }
29
+ });
30
+
31
+ async function run() {
32
+ /** Synthesizes speech synchronously: receive results after all text input has been processed. */
33
+ await gapi.client.texttospeech.text.synthesize({
34
+ }, {
35
+ audioConfig: {
36
+ audioEncoding: "Test string",
37
+ effectsProfileId: [
38
+ "Test string"
39
+ ],
40
+ pitch: 42,
41
+ sampleRateHertz: 42,
42
+ speakingRate: 42,
43
+ volumeGainDb: 42,
44
+ },
45
+ input: {
46
+ ssml: "Test string",
47
+ text: "Test string",
48
+ },
49
+ voice: {
50
+ customVoice: {
51
+ model: "Test string",
52
+ reportedUsage: "Test string",
53
+ },
54
+ languageCode: "Test string",
55
+ name: "Test string",
56
+ ssmlGender: "Test string",
57
+ },
58
+ });
59
+ /** Returns a list of Voice supported for synthesis. */
60
+ await gapi.client.texttospeech.voices.list({
61
+ languageCode: "Test string",
62
+ });
63
+ }
64
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "lib": ["es6", "dom"],
5
+ "noImplicitAny": true,
6
+ "noImplicitThis": true,
7
+ "strictNullChecks": true,
8
+ "baseUrl": "../",
9
+ "typeRoots": [
10
+ "../"
11
+ ],
12
+ "types": [],
13
+ "noEmit": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "strictFunctionTypes": true
16
+ },
17
+ "files": ["index.d.ts", "tests.ts"]
18
+ }
package/tslint.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "dtslint/dtslint.json",
3
+ "rules": {
4
+ "no-redundant-jsdoc": false
5
+ }
6
+ }