1 | import * as gax from 'google-gax';
|
2 | import { Callback, CallOptions, Descriptors, ClientOptions, LROperation } from 'google-gax';
|
3 | import * as protos from '../../protos/protos';
|
4 | /**
|
5 | * Service that implements Google Cloud Speech API.
|
6 | * @class
|
7 | * @memberof v1
|
8 | */
|
9 | export declare class SpeechClient {
|
10 | private _terminated;
|
11 | private _opts;
|
12 | private _providedCustomServicePath;
|
13 | private _gaxModule;
|
14 | private _gaxGrpc;
|
15 | private _protos;
|
16 | private _defaults;
|
17 | auth: gax.GoogleAuth;
|
18 | descriptors: Descriptors;
|
19 | warn: (code: string, message: string, warnType?: string) => void;
|
20 | innerApiCalls: {
|
21 | [name: string]: Function;
|
22 | };
|
23 | pathTemplates: {
|
24 | [name: string]: gax.PathTemplate;
|
25 | };
|
26 | operationsClient: gax.OperationsClient;
|
27 | speechStub?: Promise<{
|
28 | [name: string]: Function;
|
29 | }>;
|
30 | /**
|
31 | * Construct an instance of SpeechClient.
|
32 | *
|
33 | * @param {object} [options] - The configuration object.
|
34 | * The options accepted by the constructor are described in detail
|
35 | * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
|
36 | * The common options are:
|
37 | * @param {object} [options.credentials] - Credentials object.
|
38 | * @param {string} [options.credentials.client_email]
|
39 | * @param {string} [options.credentials.private_key]
|
40 | * @param {string} [options.email] - Account email address. Required when
|
41 | * using a .pem or .p12 keyFilename.
|
42 | * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
|
43 | * .p12 key downloaded from the Google Developers Console. If you provide
|
44 | * a path to a JSON file, the projectId option below is not necessary.
|
45 | * NOTE: .pem and .p12 require you to specify options.email as well.
|
46 | * @param {number} [options.port] - The port on which to connect to
|
47 | * the remote host.
|
48 | * @param {string} [options.projectId] - The project ID from the Google
|
49 | * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
|
50 | * the environment variable GCLOUD_PROJECT for your project ID. If your
|
51 | * app is running in an environment which supports
|
52 | * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
|
53 | * your project ID will be detected automatically.
|
54 | * @param {string} [options.apiEndpoint] - The domain name of the
|
55 | * API remote host.
|
56 | * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
|
57 | * Follows the structure of {@link gapicConfig}.
|
58 | * @param {boolean} [options.fallback] - Use HTTP fallback mode.
|
59 | * In fallback mode, a special browser-compatible transport implementation is used
|
60 | * instead of gRPC transport. In browser context (if the `window` object is defined)
|
61 | * the fallback mode is enabled automatically; set `options.fallback` to `false`
|
62 | * if you need to override this behavior.
|
63 | */
|
64 | constructor(opts?: ClientOptions);
|
65 | /**
|
66 | * Initialize the client.
|
67 | * Performs asynchronous operations (such as authentication) and prepares the client.
|
68 | * This function will be called automatically when any class method is called for the
|
69 | * first time, but if you need to initialize it before calling an actual method,
|
70 | * feel free to call initialize() directly.
|
71 | *
|
72 | * You can await on this method if you want to make sure the client is initialized.
|
73 | *
|
74 | * @returns {Promise} A promise that resolves to an authenticated service stub.
|
75 | */
|
76 | initialize(): Promise<{
|
77 | [name: string]: Function;
|
78 | }>;
|
79 | /**
|
80 | * The DNS address for this API service.
|
81 | * @returns {string} The DNS address for this service.
|
82 | */
|
83 | static get servicePath(): string;
|
84 | /**
|
85 | * The DNS address for this API service - same as servicePath(),
|
86 | * exists for compatibility reasons.
|
87 | * @returns {string} The DNS address for this service.
|
88 | */
|
89 | static get apiEndpoint(): string;
|
90 | /**
|
91 | * The port for this API service.
|
92 | * @returns {number} The default port for this service.
|
93 | */
|
94 | static get port(): number;
|
95 | /**
|
96 | * The scopes needed to make gRPC calls for every method defined
|
97 | * in this service.
|
98 | * @returns {string[]} List of default scopes.
|
99 | */
|
100 | static get scopes(): string[];
|
101 | getProjectId(): Promise<string>;
|
102 | getProjectId(callback: Callback<string, undefined, undefined>): void;
|
103 | /**
|
104 | * Performs synchronous speech recognition: receive results after all audio
|
105 | * has been sent and processed.
|
106 | *
|
107 | * @param {Object} request
|
108 | * The request object that will be sent.
|
109 | * @param {google.cloud.speech.v1.RecognitionConfig} request.config
|
110 | * Required. Provides information to the recognizer that specifies how to
|
111 | * process the request.
|
112 | * @param {google.cloud.speech.v1.RecognitionAudio} request.audio
|
113 | * Required. The audio data to be recognized.
|
114 | * @param {object} [options]
|
115 | * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
116 | * @returns {Promise} - The promise which resolves to an array.
|
117 | * The first element of the array is an object representing [RecognizeResponse]{@link google.cloud.speech.v1.RecognizeResponse}.
|
118 | * Please see the
|
119 | * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
|
120 | * for more details and examples.
|
121 | * @example <caption>include:samples/generated/v1/speech.recognize.js</caption>
|
122 | * region_tag:speech_v1_generated_Speech_Recognize_async
|
123 | */
|
124 | recognize(request?: protos.google.cloud.speech.v1.IRecognizeRequest, options?: CallOptions): Promise<[protos.google.cloud.speech.v1.IRecognizeResponse, protos.google.cloud.speech.v1.IRecognizeRequest | undefined, {} | undefined]>;
|
125 | recognize(request: protos.google.cloud.speech.v1.IRecognizeRequest, options: CallOptions, callback: Callback<protos.google.cloud.speech.v1.IRecognizeResponse, protos.google.cloud.speech.v1.IRecognizeRequest | null | undefined, {} | null | undefined>): void;
|
126 | recognize(request: protos.google.cloud.speech.v1.IRecognizeRequest, callback: Callback<protos.google.cloud.speech.v1.IRecognizeResponse, protos.google.cloud.speech.v1.IRecognizeRequest | null | undefined, {} | null | undefined>): void;
|
127 | /**
|
128 | * Performs bidirectional streaming speech recognition: receive results while
|
129 | * sending audio. This method is only available via the gRPC API (not REST).
|
130 | *
|
131 | * @param {object} [options]
|
132 | * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
133 | * @returns {Stream}
|
134 | * An object stream which is both readable and writable. It accepts objects
|
135 | * representing [StreamingRecognizeRequest]{@link google.cloud.speech.v1.StreamingRecognizeRequest} for write() method, and
|
136 | * will emit objects representing [StreamingRecognizeResponse]{@link google.cloud.speech.v1.StreamingRecognizeResponse} on 'data' event asynchronously.
|
137 | * Please see the
|
138 | * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming)
|
139 | * for more details and examples.
|
140 | * @example <caption>include:samples/generated/v1/speech.streaming_recognize.js</caption>
|
141 | * region_tag:speech_v1_generated_Speech_StreamingRecognize_async
|
142 | */
|
143 | _streamingRecognize(options?: CallOptions): gax.CancellableStream;
|
144 | /**
|
145 | * Performs asynchronous speech recognition: receive results via the
|
146 | * google.longrunning.Operations interface. Returns either an
|
147 | * `Operation.error` or an `Operation.response` which contains
|
148 | * a `LongRunningRecognizeResponse` message.
|
149 | * For more information on asynchronous speech recognition, see the
|
150 | * [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).
|
151 | *
|
152 | * @param {Object} request
|
153 | * The request object that will be sent.
|
154 | * @param {google.cloud.speech.v1.RecognitionConfig} request.config
|
155 | * Required. Provides information to the recognizer that specifies how to
|
156 | * process the request.
|
157 | * @param {google.cloud.speech.v1.RecognitionAudio} request.audio
|
158 | * Required. The audio data to be recognized.
|
159 | * @param {google.cloud.speech.v1.TranscriptOutputConfig} [request.outputConfig]
|
160 | * Optional. Specifies an optional destination for the recognition results.
|
161 | * @param {object} [options]
|
162 | * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
163 | * @returns {Promise} - The promise which resolves to an array.
|
164 | * The first element of the array is an object representing
|
165 | * a long running operation. Its `promise()` method returns a promise
|
166 | * you can `await` for.
|
167 | * Please see the
|
168 | * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations)
|
169 | * for more details and examples.
|
170 | * @example <caption>include:samples/generated/v1/speech.long_running_recognize.js</caption>
|
171 | * region_tag:speech_v1_generated_Speech_LongRunningRecognize_async
|
172 | */
|
173 | longRunningRecognize(request?: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, options?: CallOptions): Promise<[LROperation<protos.google.cloud.speech.v1.ILongRunningRecognizeResponse, protos.google.cloud.speech.v1.ILongRunningRecognizeMetadata>, protos.google.longrunning.IOperation | undefined, {} | undefined]>;
|
174 | longRunningRecognize(request: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.speech.v1.ILongRunningRecognizeResponse, protos.google.cloud.speech.v1.ILongRunningRecognizeMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
|
175 | longRunningRecognize(request: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, callback: Callback<LROperation<protos.google.cloud.speech.v1.ILongRunningRecognizeResponse, protos.google.cloud.speech.v1.ILongRunningRecognizeMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
|
176 | /**
|
177 | * Check the status of the long running operation returned by `longRunningRecognize()`.
|
178 | * @param {String} name
|
179 | * The operation name that will be passed.
|
180 | * @returns {Promise} - The promise which resolves to an object.
|
181 | * The decoded operation object has result and metadata field to get information from.
|
182 | * Please see the
|
183 | * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations)
|
184 | * for more details and examples.
|
185 | * @example <caption>include:samples/generated/v1/speech.long_running_recognize.js</caption>
|
186 | * region_tag:speech_v1_generated_Speech_LongRunningRecognize_async
|
187 | */
|
188 | checkLongRunningRecognizeProgress(name: string): Promise<LROperation<protos.google.cloud.speech.v1.LongRunningRecognizeResponse, protos.google.cloud.speech.v1.LongRunningRecognizeMetadata>>;
|
189 | /**
|
190 | * Return a fully-qualified customClass resource name string.
|
191 | *
|
192 | * @param {string} project
|
193 | * @param {string} location
|
194 | * @param {string} custom_class
|
195 | * @returns {string} Resource name string.
|
196 | */
|
197 | customClassPath(project: string, location: string, customClass: string): string;
|
198 | /**
|
199 | * Parse the project from CustomClass resource.
|
200 | *
|
201 | * @param {string} customClassName
|
202 | * A fully-qualified path representing CustomClass resource.
|
203 | * @returns {string} A string representing the project.
|
204 | */
|
205 | matchProjectFromCustomClassName(customClassName: string): string | number;
|
206 | /**
|
207 | * Parse the location from CustomClass resource.
|
208 | *
|
209 | * @param {string} customClassName
|
210 | * A fully-qualified path representing CustomClass resource.
|
211 | * @returns {string} A string representing the location.
|
212 | */
|
213 | matchLocationFromCustomClassName(customClassName: string): string | number;
|
214 | /**
|
215 | * Parse the custom_class from CustomClass resource.
|
216 | *
|
217 | * @param {string} customClassName
|
218 | * A fully-qualified path representing CustomClass resource.
|
219 | * @returns {string} A string representing the custom_class.
|
220 | */
|
221 | matchCustomClassFromCustomClassName(customClassName: string): string | number;
|
222 | /**
|
223 | * Return a fully-qualified phraseSet resource name string.
|
224 | *
|
225 | * @param {string} project
|
226 | * @param {string} location
|
227 | * @param {string} phrase_set
|
228 | * @returns {string} Resource name string.
|
229 | */
|
230 | phraseSetPath(project: string, location: string, phraseSet: string): string;
|
231 | /**
|
232 | * Parse the project from PhraseSet resource.
|
233 | *
|
234 | * @param {string} phraseSetName
|
235 | * A fully-qualified path representing PhraseSet resource.
|
236 | * @returns {string} A string representing the project.
|
237 | */
|
238 | matchProjectFromPhraseSetName(phraseSetName: string): string | number;
|
239 | /**
|
240 | * Parse the location from PhraseSet resource.
|
241 | *
|
242 | * @param {string} phraseSetName
|
243 | * A fully-qualified path representing PhraseSet resource.
|
244 | * @returns {string} A string representing the location.
|
245 | */
|
246 | matchLocationFromPhraseSetName(phraseSetName: string): string | number;
|
247 | /**
|
248 | * Parse the phrase_set from PhraseSet resource.
|
249 | *
|
250 | * @param {string} phraseSetName
|
251 | * A fully-qualified path representing PhraseSet resource.
|
252 | * @returns {string} A string representing the phrase_set.
|
253 | */
|
254 | matchPhraseSetFromPhraseSetName(phraseSetName: string): string | number;
|
255 | /**
|
256 | * Terminate the gRPC channel and close the client.
|
257 | *
|
258 | * The client will no longer be usable and all future behavior is undefined.
|
259 | * @returns {Promise} A promise that resolves when the client is closed.
|
260 | */
|
261 | close(): Promise<void>;
|
262 | }
|
263 | import { ImprovedStreamingClient } from '../helpers';
|
264 | export interface SpeechClient extends ImprovedStreamingClient {
|
265 | }
|