| OLD | NEW |
| (Empty) | |
| 1 // This is a generated file (see the discoveryapis_generator project). |
| 2 |
| 3 library googleapis_beta.speech.v1beta1; |
| 4 |
| 5 import 'dart:core' as core; |
| 6 import 'dart:async' as async; |
| 7 import 'dart:convert' as convert; |
| 8 |
| 9 import 'package:_discoveryapis_commons/_discoveryapis_commons.dart' as commons; |
| 10 import 'package:http/http.dart' as http; |
| 11 |
| 12 export 'package:_discoveryapis_commons/_discoveryapis_commons.dart' show |
| 13 ApiRequestError, DetailedApiRequestError; |
| 14 |
| 15 const core.String USER_AGENT = 'dart-api-client speech/v1beta1'; |
| 16 |
| 17 /** Google Cloud Speech API. */ |
| 18 class SpeechApi { |
| 19 /** View and manage your data across Google Cloud Platform services */ |
| 20 static const CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platf
orm"; |
| 21 |
| 22 |
| 23 final commons.ApiRequester _requester; |
| 24 |
| 25 OperationsResourceApi get operations => new OperationsResourceApi(_requester); |
| 26 SpeechResourceApi get speech => new SpeechResourceApi(_requester); |
| 27 |
| 28 SpeechApi(http.Client client, {core.String rootUrl: "https://speech.googleapis
.com/", core.String servicePath: ""}) : |
| 29 _requester = new commons.ApiRequester(client, rootUrl, servicePath, USER_A
GENT); |
| 30 } |
| 31 |
| 32 |
| 33 class OperationsResourceApi { |
| 34 final commons.ApiRequester _requester; |
| 35 |
| 36 OperationsResourceApi(commons.ApiRequester client) : |
| 37 _requester = client; |
| 38 |
| 39 /** |
| 40 * Starts asynchronous cancellation on a long-running operation. The server |
| 41 * makes a best effort to cancel the operation, but success is not |
| 42 * guaranteed. If the server doesn't support this method, it returns |
| 43 * `google.rpc.Code.UNIMPLEMENTED`. Clients can use |
| 44 * Operations.GetOperation or |
| 45 * other methods to check whether the cancellation succeeded or whether the |
| 46 * operation completed despite cancellation. |
| 47 * |
| 48 * [request] - The metadata request object. |
| 49 * |
| 50 * Request parameters: |
| 51 * |
| 52 * [name] - The name of the operation resource to be cancelled. |
| 53 * Value must have pattern "^[^/]*$". |
| 54 * |
| 55 * Completes with a [Empty]. |
| 56 * |
| 57 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
| 58 * error. |
| 59 * |
| 60 * If the used [http.Client] completes with an error when making a REST call, |
| 61 * this method will complete with the same error. |
| 62 */ |
| 63 async.Future<Empty> cancel(CancelOperationRequest request, core.String name) { |
| 64 var _url = null; |
| 65 var _queryParams = new core.Map(); |
| 66 var _uploadMedia = null; |
| 67 var _uploadOptions = null; |
| 68 var _downloadOptions = commons.DownloadOptions.Metadata; |
| 69 var _body = null; |
| 70 |
| 71 if (request != null) { |
| 72 _body = convert.JSON.encode((request).toJson()); |
| 73 } |
| 74 if (name == null) { |
| 75 throw new core.ArgumentError("Parameter name is required."); |
| 76 } |
| 77 |
| 78 _url = 'v1beta1/operations/' + commons.Escaper.ecapeVariableReserved('$name'
) + ':cancel'; |
| 79 |
| 80 var _response = _requester.request(_url, |
| 81 "POST", |
| 82 body: _body, |
| 83 queryParams: _queryParams, |
| 84 uploadOptions: _uploadOptions, |
| 85 uploadMedia: _uploadMedia, |
| 86 downloadOptions: _downloadOptions); |
| 87 return _response.then((data) => new Empty.fromJson(data)); |
| 88 } |
| 89 |
| 90 /** |
| 91 * Deletes a long-running operation. This method indicates that the client is |
| 92 * no longer interested in the operation result. It does not cancel the |
| 93 * operation. If the server doesn't support this method, it returns |
| 94 * `google.rpc.Code.UNIMPLEMENTED`. |
| 95 * |
| 96 * Request parameters: |
| 97 * |
| 98 * [name] - The name of the operation resource to be deleted. |
| 99 * Value must have pattern "^[^/]*$". |
| 100 * |
| 101 * Completes with a [Empty]. |
| 102 * |
| 103 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
| 104 * error. |
| 105 * |
| 106 * If the used [http.Client] completes with an error when making a REST call, |
| 107 * this method will complete with the same error. |
| 108 */ |
| 109 async.Future<Empty> delete(core.String name) { |
| 110 var _url = null; |
| 111 var _queryParams = new core.Map(); |
| 112 var _uploadMedia = null; |
| 113 var _uploadOptions = null; |
| 114 var _downloadOptions = commons.DownloadOptions.Metadata; |
| 115 var _body = null; |
| 116 |
| 117 if (name == null) { |
| 118 throw new core.ArgumentError("Parameter name is required."); |
| 119 } |
| 120 |
| 121 _url = 'v1beta1/operations/' + commons.Escaper.ecapeVariableReserved('$name'
); |
| 122 |
| 123 var _response = _requester.request(_url, |
| 124 "DELETE", |
| 125 body: _body, |
| 126 queryParams: _queryParams, |
| 127 uploadOptions: _uploadOptions, |
| 128 uploadMedia: _uploadMedia, |
| 129 downloadOptions: _downloadOptions); |
| 130 return _response.then((data) => new Empty.fromJson(data)); |
| 131 } |
| 132 |
| 133 /** |
| 134 * Gets the latest state of a long-running operation. Clients can use this |
| 135 * method to poll the operation result at intervals as recommended by the API |
| 136 * service. |
| 137 * |
| 138 * Request parameters: |
| 139 * |
| 140 * [name] - The name of the operation resource. |
| 141 * Value must have pattern "^[^/]*$". |
| 142 * |
| 143 * Completes with a [Operation]. |
| 144 * |
| 145 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
| 146 * error. |
| 147 * |
| 148 * If the used [http.Client] completes with an error when making a REST call, |
| 149 * this method will complete with the same error. |
| 150 */ |
| 151 async.Future<Operation> get(core.String name) { |
| 152 var _url = null; |
| 153 var _queryParams = new core.Map(); |
| 154 var _uploadMedia = null; |
| 155 var _uploadOptions = null; |
| 156 var _downloadOptions = commons.DownloadOptions.Metadata; |
| 157 var _body = null; |
| 158 |
| 159 if (name == null) { |
| 160 throw new core.ArgumentError("Parameter name is required."); |
| 161 } |
| 162 |
| 163 _url = 'v1beta1/operations/' + commons.Escaper.ecapeVariableReserved('$name'
); |
| 164 |
| 165 var _response = _requester.request(_url, |
| 166 "GET", |
| 167 body: _body, |
| 168 queryParams: _queryParams, |
| 169 uploadOptions: _uploadOptions, |
| 170 uploadMedia: _uploadMedia, |
| 171 downloadOptions: _downloadOptions); |
| 172 return _response.then((data) => new Operation.fromJson(data)); |
| 173 } |
| 174 |
| 175 /** |
| 176 * Lists operations that match the specified filter in the request. If the |
| 177 * server doesn't support this method, it returns `UNIMPLEMENTED`. |
| 178 * |
| 179 * NOTE: the `name` binding below allows API services to override the binding |
| 180 * to use different resource name schemes, such as `users / * /operations`. |
| 181 * |
| 182 * Request parameters: |
| 183 * |
| 184 * [pageSize] - The standard list page size. |
| 185 * |
| 186 * [filter] - The standard list filter. |
| 187 * |
| 188 * [name] - The name of the operation collection. |
| 189 * |
| 190 * [pageToken] - The standard list page token. |
| 191 * |
| 192 * Completes with a [ListOperationsResponse]. |
| 193 * |
| 194 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
| 195 * error. |
| 196 * |
| 197 * If the used [http.Client] completes with an error when making a REST call, |
| 198 * this method will complete with the same error. |
| 199 */ |
| 200 async.Future<ListOperationsResponse> list({core.int pageSize, core.String filt
er, core.String name, core.String pageToken}) { |
| 201 var _url = null; |
| 202 var _queryParams = new core.Map(); |
| 203 var _uploadMedia = null; |
| 204 var _uploadOptions = null; |
| 205 var _downloadOptions = commons.DownloadOptions.Metadata; |
| 206 var _body = null; |
| 207 |
| 208 if (pageSize != null) { |
| 209 _queryParams["pageSize"] = ["${pageSize}"]; |
| 210 } |
| 211 if (filter != null) { |
| 212 _queryParams["filter"] = [filter]; |
| 213 } |
| 214 if (name != null) { |
| 215 _queryParams["name"] = [name]; |
| 216 } |
| 217 if (pageToken != null) { |
| 218 _queryParams["pageToken"] = [pageToken]; |
| 219 } |
| 220 |
| 221 _url = 'v1beta1/operations'; |
| 222 |
| 223 var _response = _requester.request(_url, |
| 224 "GET", |
| 225 body: _body, |
| 226 queryParams: _queryParams, |
| 227 uploadOptions: _uploadOptions, |
| 228 uploadMedia: _uploadMedia, |
| 229 downloadOptions: _downloadOptions); |
| 230 return _response.then((data) => new ListOperationsResponse.fromJson(data)); |
| 231 } |
| 232 |
| 233 } |
| 234 |
| 235 |
| 236 class SpeechResourceApi { |
| 237 final commons.ApiRequester _requester; |
| 238 |
| 239 SpeechResourceApi(commons.ApiRequester client) : |
| 240 _requester = client; |
| 241 |
| 242 /** |
| 243 * Perform asynchronous speech-recognition: receive results via the |
| 244 * google.longrunning.Operations interface. Returns either an |
| 245 * `Operation.error` or an `Operation.response` which contains |
| 246 * an `AsyncRecognizeResponse` message. |
| 247 * |
| 248 * [request] - The metadata request object. |
| 249 * |
| 250 * Request parameters: |
| 251 * |
| 252 * Completes with a [Operation]. |
| 253 * |
| 254 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
| 255 * error. |
| 256 * |
| 257 * If the used [http.Client] completes with an error when making a REST call, |
| 258 * this method will complete with the same error. |
| 259 */ |
| 260 async.Future<Operation> asyncrecognize(AsyncRecognizeRequest request) { |
| 261 var _url = null; |
| 262 var _queryParams = new core.Map(); |
| 263 var _uploadMedia = null; |
| 264 var _uploadOptions = null; |
| 265 var _downloadOptions = commons.DownloadOptions.Metadata; |
| 266 var _body = null; |
| 267 |
| 268 if (request != null) { |
| 269 _body = convert.JSON.encode((request).toJson()); |
| 270 } |
| 271 |
| 272 _url = 'v1beta1/speech:asyncrecognize'; |
| 273 |
| 274 var _response = _requester.request(_url, |
| 275 "POST", |
| 276 body: _body, |
| 277 queryParams: _queryParams, |
| 278 uploadOptions: _uploadOptions, |
| 279 uploadMedia: _uploadMedia, |
| 280 downloadOptions: _downloadOptions); |
| 281 return _response.then((data) => new Operation.fromJson(data)); |
| 282 } |
| 283 |
| 284 /** |
| 285 * Perform synchronous speech-recognition: receive results after all audio |
| 286 * has been sent and processed. |
| 287 * |
| 288 * [request] - The metadata request object. |
| 289 * |
| 290 * Request parameters: |
| 291 * |
| 292 * Completes with a [SyncRecognizeResponse]. |
| 293 * |
| 294 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
| 295 * error. |
| 296 * |
| 297 * If the used [http.Client] completes with an error when making a REST call, |
| 298 * this method will complete with the same error. |
| 299 */ |
| 300 async.Future<SyncRecognizeResponse> syncrecognize(SyncRecognizeRequest request
) { |
| 301 var _url = null; |
| 302 var _queryParams = new core.Map(); |
| 303 var _uploadMedia = null; |
| 304 var _uploadOptions = null; |
| 305 var _downloadOptions = commons.DownloadOptions.Metadata; |
| 306 var _body = null; |
| 307 |
| 308 if (request != null) { |
| 309 _body = convert.JSON.encode((request).toJson()); |
| 310 } |
| 311 |
| 312 _url = 'v1beta1/speech:syncrecognize'; |
| 313 |
| 314 var _response = _requester.request(_url, |
| 315 "POST", |
| 316 body: _body, |
| 317 queryParams: _queryParams, |
| 318 uploadOptions: _uploadOptions, |
| 319 uploadMedia: _uploadMedia, |
| 320 downloadOptions: _downloadOptions); |
| 321 return _response.then((data) => new SyncRecognizeResponse.fromJson(data)); |
| 322 } |
| 323 |
| 324 } |
| 325 |
| 326 |
| 327 |
| 328 /** |
| 329 * `AsyncRecognizeRequest` is the top-level message sent by the client for |
| 330 * the `AsyncRecognize` method. |
| 331 */ |
| 332 class AsyncRecognizeRequest { |
| 333 /** [Required] The audio data to be recognized. */ |
| 334 RecognitionAudio audio; |
| 335 /** |
| 336 * [Required] The `config` message provides information to the recognizer |
| 337 * that specifies how to process the request. |
| 338 */ |
| 339 RecognitionConfig config; |
| 340 |
| 341 AsyncRecognizeRequest(); |
| 342 |
| 343 AsyncRecognizeRequest.fromJson(core.Map _json) { |
| 344 if (_json.containsKey("audio")) { |
| 345 audio = new RecognitionAudio.fromJson(_json["audio"]); |
| 346 } |
| 347 if (_json.containsKey("config")) { |
| 348 config = new RecognitionConfig.fromJson(_json["config"]); |
| 349 } |
| 350 } |
| 351 |
| 352 core.Map toJson() { |
| 353 var _json = new core.Map(); |
| 354 if (audio != null) { |
| 355 _json["audio"] = (audio).toJson(); |
| 356 } |
| 357 if (config != null) { |
| 358 _json["config"] = (config).toJson(); |
| 359 } |
| 360 return _json; |
| 361 } |
| 362 } |
| 363 |
| 364 /** The request message for Operations.CancelOperation. */ |
| 365 class CancelOperationRequest { |
| 366 |
| 367 CancelOperationRequest(); |
| 368 |
| 369 CancelOperationRequest.fromJson(core.Map _json) { |
| 370 } |
| 371 |
| 372 core.Map toJson() { |
| 373 var _json = new core.Map(); |
| 374 return _json; |
| 375 } |
| 376 } |
| 377 |
| 378 /** |
| 379 * A generic empty message that you can re-use to avoid defining duplicated |
| 380 * empty messages in your APIs. A typical example is to use it as the request |
| 381 * or the response type of an API method. For instance: |
| 382 * |
| 383 * service Foo { |
| 384 * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); |
| 385 * } |
| 386 * |
| 387 * The JSON representation for `Empty` is empty JSON object `{}`. |
| 388 */ |
| 389 class Empty { |
| 390 |
| 391 Empty(); |
| 392 |
| 393 Empty.fromJson(core.Map _json) { |
| 394 } |
| 395 |
| 396 core.Map toJson() { |
| 397 var _json = new core.Map(); |
| 398 return _json; |
| 399 } |
| 400 } |
| 401 |
| 402 /** The response message for Operations.ListOperations. */ |
| 403 class ListOperationsResponse { |
| 404 /** The standard List next-page token. */ |
| 405 core.String nextPageToken; |
| 406 /** A list of operations that matches the specified filter in the request. */ |
| 407 core.List<Operation> operations; |
| 408 |
| 409 ListOperationsResponse(); |
| 410 |
| 411 ListOperationsResponse.fromJson(core.Map _json) { |
| 412 if (_json.containsKey("nextPageToken")) { |
| 413 nextPageToken = _json["nextPageToken"]; |
| 414 } |
| 415 if (_json.containsKey("operations")) { |
| 416 operations = _json["operations"].map((value) => new Operation.fromJson(val
ue)).toList(); |
| 417 } |
| 418 } |
| 419 |
| 420 core.Map toJson() { |
| 421 var _json = new core.Map(); |
| 422 if (nextPageToken != null) { |
| 423 _json["nextPageToken"] = nextPageToken; |
| 424 } |
| 425 if (operations != null) { |
| 426 _json["operations"] = operations.map((value) => (value).toJson()).toList()
; |
| 427 } |
| 428 return _json; |
| 429 } |
| 430 } |
| 431 |
| 432 /** |
| 433 * This resource represents a long-running operation that is the result of a |
| 434 * network API call. |
| 435 */ |
| 436 class Operation { |
| 437 /** |
| 438 * If the value is `false`, it means the operation is still in progress. |
| 439 * If true, the operation is completed, and either `error` or `response` is |
| 440 * available. |
| 441 */ |
| 442 core.bool done; |
| 443 /** The error result of the operation in case of failure. */ |
| 444 Status error; |
| 445 /** |
| 446 * Service-specific metadata associated with the operation. It typically |
| 447 * contains progress information and common metadata such as create time. |
| 448 * Some services might not provide such metadata. Any method that returns a |
| 449 * long-running operation should document the metadata type, if any. |
| 450 * |
| 451 * The values for Object must be JSON objects. It can consist of `num`, |
| 452 * `String`, `bool` and `null` as well as `Map` and `List` values. |
| 453 */ |
| 454 core.Map<core.String, core.Object> metadata; |
| 455 /** |
| 456 * The server-assigned name, which is only unique within the same service that |
| 457 * originally returns it. If you use the default HTTP mapping, the |
| 458 * `name` should have the format of `operations/some/unique/name`. |
| 459 */ |
| 460 core.String name; |
| 461 /** |
| 462 * The normal response of the operation in case of success. If the original |
| 463 * method returns no data on success, such as `Delete`, the response is |
| 464 * `google.protobuf.Empty`. If the original method is standard |
| 465 * `Get`/`Create`/`Update`, the response should be the resource. For other |
| 466 * methods, the response should have the type `XxxResponse`, where `Xxx` |
| 467 * is the original method name. For example, if the original method name |
| 468 * is `TakeSnapshot()`, the inferred response type is |
| 469 * `TakeSnapshotResponse`. |
| 470 * |
| 471 * The values for Object must be JSON objects. It can consist of `num`, |
| 472 * `String`, `bool` and `null` as well as `Map` and `List` values. |
| 473 */ |
| 474 core.Map<core.String, core.Object> response; |
| 475 |
| 476 Operation(); |
| 477 |
| 478 Operation.fromJson(core.Map _json) { |
| 479 if (_json.containsKey("done")) { |
| 480 done = _json["done"]; |
| 481 } |
| 482 if (_json.containsKey("error")) { |
| 483 error = new Status.fromJson(_json["error"]); |
| 484 } |
| 485 if (_json.containsKey("metadata")) { |
| 486 metadata = _json["metadata"]; |
| 487 } |
| 488 if (_json.containsKey("name")) { |
| 489 name = _json["name"]; |
| 490 } |
| 491 if (_json.containsKey("response")) { |
| 492 response = _json["response"]; |
| 493 } |
| 494 } |
| 495 |
| 496 core.Map toJson() { |
| 497 var _json = new core.Map(); |
| 498 if (done != null) { |
| 499 _json["done"] = done; |
| 500 } |
| 501 if (error != null) { |
| 502 _json["error"] = (error).toJson(); |
| 503 } |
| 504 if (metadata != null) { |
| 505 _json["metadata"] = metadata; |
| 506 } |
| 507 if (name != null) { |
| 508 _json["name"] = name; |
| 509 } |
| 510 if (response != null) { |
| 511 _json["response"] = response; |
| 512 } |
| 513 return _json; |
| 514 } |
| 515 } |
| 516 |
| 517 /** |
| 518 * Contains audio data in the encoding specified in the `RecognitionConfig`. |
| 519 * Either `content` or `uri` must be supplied. Supplying both or neither |
| 520 * returns google.rpc.Code.INVALID_ARGUMENT. |
| 521 */ |
| 522 class RecognitionAudio { |
| 523 /** |
| 524 * The audio data bytes encoded as specified in |
| 525 * `RecognitionConfig`. Note: as with all bytes fields, protobuffers use a |
| 526 * pure binary representation, whereas JSON representations use base64. |
| 527 */ |
| 528 core.String content; |
| 529 core.List<core.int> get contentAsBytes { |
| 530 return convert.BASE64.decode(content); |
| 531 } |
| 532 |
| 533 void set contentAsBytes(core.List<core.int> _bytes) { |
| 534 content = convert.BASE64.encode(_bytes).replaceAll("/", "_").replaceAll("+",
"-"); |
| 535 } |
| 536 /** |
| 537 * URI that points to a file that contains audio data bytes as specified in |
| 538 * `RecognitionConfig`. Currently, only Google Cloud Storage URIs are |
| 539 * supported, which must be specified in the following format: |
| 540 * `gs://bucket_name/object_name` (other URI formats return |
| 541 * google.rpc.Code.INVALID_ARGUMENT). For more information, see |
| 542 * [Request URIs](/storage/docs/reference-uris). |
| 543 */ |
| 544 core.String uri; |
| 545 |
| 546 RecognitionAudio(); |
| 547 |
| 548 RecognitionAudio.fromJson(core.Map _json) { |
| 549 if (_json.containsKey("content")) { |
| 550 content = _json["content"]; |
| 551 } |
| 552 if (_json.containsKey("uri")) { |
| 553 uri = _json["uri"]; |
| 554 } |
| 555 } |
| 556 |
| 557 core.Map toJson() { |
| 558 var _json = new core.Map(); |
| 559 if (content != null) { |
| 560 _json["content"] = content; |
| 561 } |
| 562 if (uri != null) { |
| 563 _json["uri"] = uri; |
| 564 } |
| 565 return _json; |
| 566 } |
| 567 } |
| 568 |
| 569 /** |
| 570 * The `RecognitionConfig` message provides information to the recognizer |
| 571 * that specifies how to process the request. |
| 572 */ |
| 573 class RecognitionConfig { |
| 574 /** |
| 575 * [Required] Encoding of audio data sent in all `RecognitionAudio` messages. |
| 576 * Possible string values are: |
| 577 * - "ENCODING_UNSPECIFIED" : Not specified. Will return result |
| 578 * google.rpc.Code.INVALID_ARGUMENT. |
| 579 * - "LINEAR16" : Uncompressed 16-bit signed little-endian samples. |
| 580 * This is the only encoding that may be used by `AsyncRecognize`. |
| 581 * - "FLAC" : This is the recommended encoding for `SyncRecognize` and |
| 582 * `StreamingRecognize` because it uses lossless compression; therefore |
| 583 * recognition accuracy is not compromised by a lossy codec. |
| 584 * |
| 585 * The stream FLAC (Free Lossless Audio Codec) encoding is specified at: |
| 586 * http://flac.sourceforge.net/documentation.html. |
| 587 * Only 16-bit samples are supported. |
| 588 * Not all fields in STREAMINFO are supported. |
| 589 * - "MULAW" : 8-bit samples that compand 14-bit audio samples using G.711 |
| 590 * PCMU/mu-law. |
| 591 * - "AMR" : Adaptive Multi-Rate Narrowband codec. `sample_rate` must be 8000 |
| 592 * Hz. |
| 593 * - "AMR_WB" : Adaptive Multi-Rate Wideband codec. `sample_rate` must be |
| 594 * 16000 Hz. |
| 595 */ |
| 596 core.String encoding; |
| 597 /** |
| 598 * [Optional] The language of the supplied audio as a BCP-47 language tag. |
| 599 * Example: "en-GB" https://www.rfc-editor.org/rfc/bcp/bcp47.txt |
| 600 * If omitted, defaults to "en-US". See |
| 601 * [Language Support](/speech/docs/best-practices#language_support) for |
| 602 * a list of the currently supported language codes. |
| 603 */ |
| 604 core.String languageCode; |
| 605 /** |
| 606 * [Optional] Maximum number of recognition hypotheses to be returned. |
| 607 * Specifically, the maximum number of `SpeechRecognitionAlternative` messages |
| 608 * within each `SpeechRecognitionResult`. |
| 609 * The server may return fewer than `max_alternatives`. |
| 610 * Valid values are `0`-`30`. A value of `0` or `1` will return a maximum of |
| 611 * `1`. If omitted, defaults to `1`. |
| 612 */ |
| 613 core.int maxAlternatives; |
| 614 /** |
| 615 * [Optional] If set to `true`, the server will attempt to filter out |
| 616 * profanities, replacing all but the initial character in each filtered word |
| 617 * with asterisks, e.g. "f***". If set to `false` or omitted, profanities |
| 618 * won't be filtered out. |
| 619 */ |
| 620 core.bool profanityFilter; |
| 621 /** |
| 622 * [Required] Sample rate in Hertz of the audio data sent in all |
| 623 * `RecognitionAudio` messages. Valid values are: 8000-48000. |
| 624 * 16000 is optimal. For best results, set the sampling rate of the audio |
| 625 * source to 16000 Hz. If that's not possible, use the native sample rate of |
| 626 * the audio source (instead of re-sampling). |
| 627 */ |
| 628 core.int sampleRate; |
| 629 /** |
| 630 * [Optional] A means to provide context to assist the speech recognition. |
| 631 */ |
| 632 SpeechContext speechContext; |
| 633 |
| 634 RecognitionConfig(); |
| 635 |
| 636 RecognitionConfig.fromJson(core.Map _json) { |
| 637 if (_json.containsKey("encoding")) { |
| 638 encoding = _json["encoding"]; |
| 639 } |
| 640 if (_json.containsKey("languageCode")) { |
| 641 languageCode = _json["languageCode"]; |
| 642 } |
| 643 if (_json.containsKey("maxAlternatives")) { |
| 644 maxAlternatives = _json["maxAlternatives"]; |
| 645 } |
| 646 if (_json.containsKey("profanityFilter")) { |
| 647 profanityFilter = _json["profanityFilter"]; |
| 648 } |
| 649 if (_json.containsKey("sampleRate")) { |
| 650 sampleRate = _json["sampleRate"]; |
| 651 } |
| 652 if (_json.containsKey("speechContext")) { |
| 653 speechContext = new SpeechContext.fromJson(_json["speechContext"]); |
| 654 } |
| 655 } |
| 656 |
| 657 core.Map toJson() { |
| 658 var _json = new core.Map(); |
| 659 if (encoding != null) { |
| 660 _json["encoding"] = encoding; |
| 661 } |
| 662 if (languageCode != null) { |
| 663 _json["languageCode"] = languageCode; |
| 664 } |
| 665 if (maxAlternatives != null) { |
| 666 _json["maxAlternatives"] = maxAlternatives; |
| 667 } |
| 668 if (profanityFilter != null) { |
| 669 _json["profanityFilter"] = profanityFilter; |
| 670 } |
| 671 if (sampleRate != null) { |
| 672 _json["sampleRate"] = sampleRate; |
| 673 } |
| 674 if (speechContext != null) { |
| 675 _json["speechContext"] = (speechContext).toJson(); |
| 676 } |
| 677 return _json; |
| 678 } |
| 679 } |
| 680 |
| 681 /** |
| 682 * Provides "hints" to the speech recognizer to favor specific words and phrases |
| 683 * in the results. |
| 684 */ |
| 685 class SpeechContext { |
| 686 /** |
| 687 * [Optional] A list of up to 50 phrases of up to 100 characters each to |
| 688 * provide words and phrases "hints" to the speech recognition so that it is |
| 689 * more likely to recognize them. |
| 690 */ |
| 691 core.List<core.String> phrases; |
| 692 |
| 693 SpeechContext(); |
| 694 |
| 695 SpeechContext.fromJson(core.Map _json) { |
| 696 if (_json.containsKey("phrases")) { |
| 697 phrases = _json["phrases"]; |
| 698 } |
| 699 } |
| 700 |
| 701 core.Map toJson() { |
| 702 var _json = new core.Map(); |
| 703 if (phrases != null) { |
| 704 _json["phrases"] = phrases; |
| 705 } |
| 706 return _json; |
| 707 } |
| 708 } |
| 709 |
| 710 /** Alternative hypotheses (a.k.a. n-best list). */ |
| 711 class SpeechRecognitionAlternative { |
| 712 /** |
| 713 * [Output-only] The confidence estimate between 0.0 and 1.0. A higher number |
| 714 * means the system is more confident that the recognition is correct. |
| 715 * This field is typically provided only for the top hypothesis, and only for |
| 716 * `is_final=true` results. |
| 717 * The default of 0.0 is a sentinel value indicating confidence was not set. |
| 718 */ |
| 719 core.double confidence; |
| 720 /** |
| 721 * [Output-only] Transcript text representing the words that the user spoke. |
| 722 */ |
| 723 core.String transcript; |
| 724 |
| 725 SpeechRecognitionAlternative(); |
| 726 |
| 727 SpeechRecognitionAlternative.fromJson(core.Map _json) { |
| 728 if (_json.containsKey("confidence")) { |
| 729 confidence = _json["confidence"]; |
| 730 } |
| 731 if (_json.containsKey("transcript")) { |
| 732 transcript = _json["transcript"]; |
| 733 } |
| 734 } |
| 735 |
| 736 core.Map toJson() { |
| 737 var _json = new core.Map(); |
| 738 if (confidence != null) { |
| 739 _json["confidence"] = confidence; |
| 740 } |
| 741 if (transcript != null) { |
| 742 _json["transcript"] = transcript; |
| 743 } |
| 744 return _json; |
| 745 } |
| 746 } |
| 747 |
| 748 /** A speech recognition result corresponding to a portion of the audio. */ |
| 749 class SpeechRecognitionResult { |
| 750 /** |
| 751 * [Output-only] May contain one or more recognition hypotheses (up to the |
| 752 * maximum specified in `max_alternatives`). |
| 753 */ |
| 754 core.List<SpeechRecognitionAlternative> alternatives; |
| 755 |
| 756 SpeechRecognitionResult(); |
| 757 |
| 758 SpeechRecognitionResult.fromJson(core.Map _json) { |
| 759 if (_json.containsKey("alternatives")) { |
| 760 alternatives = _json["alternatives"].map((value) => new SpeechRecognitionA
lternative.fromJson(value)).toList(); |
| 761 } |
| 762 } |
| 763 |
| 764 core.Map toJson() { |
| 765 var _json = new core.Map(); |
| 766 if (alternatives != null) { |
| 767 _json["alternatives"] = alternatives.map((value) => (value).toJson()).toLi
st(); |
| 768 } |
| 769 return _json; |
| 770 } |
| 771 } |
| 772 |
| 773 /** |
| 774 * The `Status` type defines a logical error model that is suitable for |
| 775 * different |
| 776 * programming environments, including REST APIs and RPC APIs. It is used by |
| 777 * [gRPC](https://github.com/grpc). The error model is designed to be: |
| 778 * |
| 779 * - Simple to use and understand for most users |
| 780 * - Flexible enough to meet unexpected needs |
| 781 * |
| 782 * # Overview |
| 783 * |
| 784 * The `Status` message contains three pieces of data: error code, error |
| 785 * message, |
| 786 * and error details. The error code should be an enum value of |
| 787 * google.rpc.Code, but it may accept additional error codes if needed. The |
| 788 * error message should be a developer-facing English message that helps |
| 789 * developers *understand* and *resolve* the error. If a localized user-facing |
| 790 * error message is needed, put the localized message in the error details or |
| 791 * localize it in the client. The optional error details may contain arbitrary |
| 792 * information about the error. There is a predefined set of error detail types |
| 793 * in the package `google.rpc` which can be used for common error conditions. |
| 794 * |
| 795 * # Language mapping |
| 796 * |
| 797 * The `Status` message is the logical representation of the error model, but it |
| 798 * is not necessarily the actual wire format. When the `Status` message is |
| 799 * exposed in different client libraries and different wire protocols, it can be |
| 800 * mapped differently. For example, it will likely be mapped to some exceptions |
| 801 * in Java, but more likely mapped to some error codes in C. |
| 802 * |
| 803 * # Other uses |
| 804 * |
| 805 * The error model and the `Status` message can be used in a variety of |
| 806 * environments, either with or without APIs, to provide a |
| 807 * consistent developer experience across different environments. |
| 808 * |
| 809 * Example uses of this error model include: |
| 810 * |
| 811 * - Partial errors. If a service needs to return partial errors to the client, |
| 812 * it may embed the `Status` in the normal response to indicate the partial |
| 813 * errors. |
| 814 * |
| 815 * - Workflow errors. A typical workflow has multiple steps. Each step may |
| 816 * have a `Status` message for error reporting purpose. |
| 817 * |
| 818 * - Batch operations. If a client uses batch request and batch response, the |
| 819 * `Status` message should be used directly inside batch response, one for |
| 820 * each error sub-response. |
| 821 * |
| 822 * - Asynchronous operations. If an API call embeds asynchronous operation |
| 823 * results in its response, the status of those operations should be |
| 824 * represented directly using the `Status` message. |
| 825 * |
| 826 * - Logging. If some API errors are stored in logs, the message `Status` could |
| 827 * be used directly after any stripping needed for security/privacy reasons. |
| 828 */ |
| 829 class Status { |
| 830 /** The status code, which should be an enum value of google.rpc.Code. */ |
| 831 core.int code; |
| 832 /** |
| 833 * A list of messages that carry the error details. There will be a |
| 834 * common set of message types for APIs to use. |
| 835 * |
| 836 * The values for Object must be JSON objects. It can consist of `num`, |
| 837 * `String`, `bool` and `null` as well as `Map` and `List` values. |
| 838 */ |
| 839 core.List<core.Map<core.String, core.Object>> details; |
| 840 /** |
| 841 * A developer-facing error message, which should be in English. Any |
| 842 * user-facing error message should be localized and sent in the |
| 843 * google.rpc.Status.details field, or localized by the client. |
| 844 */ |
| 845 core.String message; |
| 846 |
| 847 Status(); |
| 848 |
| 849 Status.fromJson(core.Map _json) { |
| 850 if (_json.containsKey("code")) { |
| 851 code = _json["code"]; |
| 852 } |
| 853 if (_json.containsKey("details")) { |
| 854 details = _json["details"]; |
| 855 } |
| 856 if (_json.containsKey("message")) { |
| 857 message = _json["message"]; |
| 858 } |
| 859 } |
| 860 |
| 861 core.Map toJson() { |
| 862 var _json = new core.Map(); |
| 863 if (code != null) { |
| 864 _json["code"] = code; |
| 865 } |
| 866 if (details != null) { |
| 867 _json["details"] = details; |
| 868 } |
| 869 if (message != null) { |
| 870 _json["message"] = message; |
| 871 } |
| 872 return _json; |
| 873 } |
| 874 } |
| 875 |
| 876 /** |
| 877 * `SyncRecognizeRequest` is the top-level message sent by the client for |
| 878 * the `SyncRecognize` method. |
| 879 */ |
| 880 class SyncRecognizeRequest { |
| 881 /** [Required] The audio data to be recognized. */ |
| 882 RecognitionAudio audio; |
| 883 /** |
| 884 * [Required] The `config` message provides information to the recognizer |
| 885 * that specifies how to process the request. |
| 886 */ |
| 887 RecognitionConfig config; |
| 888 |
| 889 SyncRecognizeRequest(); |
| 890 |
| 891 SyncRecognizeRequest.fromJson(core.Map _json) { |
| 892 if (_json.containsKey("audio")) { |
| 893 audio = new RecognitionAudio.fromJson(_json["audio"]); |
| 894 } |
| 895 if (_json.containsKey("config")) { |
| 896 config = new RecognitionConfig.fromJson(_json["config"]); |
| 897 } |
| 898 } |
| 899 |
| 900 core.Map toJson() { |
| 901 var _json = new core.Map(); |
| 902 if (audio != null) { |
| 903 _json["audio"] = (audio).toJson(); |
| 904 } |
| 905 if (config != null) { |
| 906 _json["config"] = (config).toJson(); |
| 907 } |
| 908 return _json; |
| 909 } |
| 910 } |
| 911 |
| 912 /** |
| 913 * `SyncRecognizeResponse` is the only message returned to the client by |
| 914 * `SyncRecognize`. It contains the result as zero or more sequential |
| 915 * `SpeechRecognitionResult` messages. |
| 916 */ |
| 917 class SyncRecognizeResponse { |
| 918 /** |
| 919 * [Output-only] Sequential list of transcription results corresponding to |
| 920 * sequential portions of audio. |
| 921 */ |
| 922 core.List<SpeechRecognitionResult> results; |
| 923 |
| 924 SyncRecognizeResponse(); |
| 925 |
| 926 SyncRecognizeResponse.fromJson(core.Map _json) { |
| 927 if (_json.containsKey("results")) { |
| 928 results = _json["results"].map((value) => new SpeechRecognitionResult.from
Json(value)).toList(); |
| 929 } |
| 930 } |
| 931 |
| 932 core.Map toJson() { |
| 933 var _json = new core.Map(); |
| 934 if (results != null) { |
| 935 _json["results"] = results.map((value) => (value).toJson()).toList(); |
| 936 } |
| 937 return _json; |
| 938 } |
| 939 } |
| OLD | NEW |