1// Copyright 2020 Google LLC. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5// Code generated file. DO NOT EDIT. 6 7// Package speech provides access to the Cloud Speech-to-Text API. 8// 9// This package is DEPRECATED. Use package cloud.google.com/go/speech/apiv1 instead. 10// 11// For product documentation, see: https://cloud.google.com/speech-to-text/docs/quickstart-protocol 12// 13// Creating a client 14// 15// Usage example: 16// 17// import "google.golang.org/api/speech/v1" 18// ... 19// ctx := context.Background() 20// speechService, err := speech.NewService(ctx) 21// 22// In this example, Google Application Default Credentials are used for authentication. 23// 24// For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials. 25// 26// Other authentication options 27// 28// To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey: 29// 30// speechService, err := speech.NewService(ctx, option.WithAPIKey("AIza...")) 31// 32// To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource: 33// 34// config := &oauth2.Config{...} 35// // ... 36// token, err := config.Exchange(ctx, ...) 37// speechService, err := speech.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) 38// 39// See https://godoc.org/google.golang.org/api/option/ for details on options. 40package speech // import "google.golang.org/api/speech/v1" 41 42import ( 43 "bytes" 44 "context" 45 "encoding/json" 46 "errors" 47 "fmt" 48 "io" 49 "net/http" 50 "net/url" 51 "strconv" 52 "strings" 53 54 googleapi "google.golang.org/api/googleapi" 55 gensupport "google.golang.org/api/internal/gensupport" 56 option "google.golang.org/api/option" 57 internaloption "google.golang.org/api/option/internaloption" 58 htransport "google.golang.org/api/transport/http" 59) 60 61// Always reference these packages, just in case the auto-generated code 62// below doesn't. 63var _ = bytes.NewBuffer 64var _ = strconv.Itoa 65var _ = fmt.Sprintf 66var _ = json.NewDecoder 67var _ = io.Copy 68var _ = url.Parse 69var _ = gensupport.MarshalJSON 70var _ = googleapi.Version 71var _ = errors.New 72var _ = strings.Replace 73var _ = context.Canceled 74var _ = internaloption.WithDefaultEndpoint 75 76const apiId = "speech:v1" 77const apiName = "speech" 78const apiVersion = "v1" 79const basePath = "https://speech.googleapis.com/" 80const mtlsBasePath = "https://speech.mtls.googleapis.com/" 81 82// OAuth2 scopes used by this API. 83const ( 84 // View and manage your data across Google Cloud Platform services 85 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform" 86) 87 88// NewService creates a new Service. 89func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 90 scopesOption := option.WithScopes( 91 "https://www.googleapis.com/auth/cloud-platform", 92 ) 93 // NOTE: prepend, so we don't override user-specified scopes. 94 opts = append([]option.ClientOption{scopesOption}, opts...) 95 opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) 96 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) 97 client, endpoint, err := htransport.NewClient(ctx, opts...) 98 if err != nil { 99 return nil, err 100 } 101 s, err := New(client) 102 if err != nil { 103 return nil, err 104 } 105 if endpoint != "" { 106 s.BasePath = endpoint 107 } 108 return s, nil 109} 110 111// New creates a new Service. It uses the provided http.Client for requests. 112// 113// Deprecated: please use NewService instead. 114// To provide a custom HTTP client, use option.WithHTTPClient. 115// If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. 116func New(client *http.Client) (*Service, error) { 117 if client == nil { 118 return nil, errors.New("client is nil") 119 } 120 s := &Service{client: client, BasePath: basePath} 121 s.Operations = NewOperationsService(s) 122 s.Projects = NewProjectsService(s) 123 s.Speech = NewSpeechService(s) 124 return s, nil 125} 126 127type Service struct { 128 client *http.Client 129 BasePath string // API endpoint base URL 130 UserAgent string // optional additional User-Agent fragment 131 132 Operations *OperationsService 133 134 Projects *ProjectsService 135 136 Speech *SpeechService 137} 138 139func (s *Service) userAgent() string { 140 if s.UserAgent == "" { 141 return googleapi.UserAgent 142 } 143 return googleapi.UserAgent + " " + s.UserAgent 144} 145 146func NewOperationsService(s *Service) *OperationsService { 147 rs := &OperationsService{s: s} 148 return rs 149} 150 151type OperationsService struct { 152 s *Service 153} 154 155func NewProjectsService(s *Service) *ProjectsService { 156 rs := &ProjectsService{s: s} 157 rs.Locations = NewProjectsLocationsService(s) 158 return rs 159} 160 161type ProjectsService struct { 162 s *Service 163 164 Locations *ProjectsLocationsService 165} 166 167func NewProjectsLocationsService(s *Service) *ProjectsLocationsService { 168 rs := &ProjectsLocationsService{s: s} 169 rs.Operations = NewProjectsLocationsOperationsService(s) 170 return rs 171} 172 173type ProjectsLocationsService struct { 174 s *Service 175 176 Operations *ProjectsLocationsOperationsService 177} 178 179func NewProjectsLocationsOperationsService(s *Service) *ProjectsLocationsOperationsService { 180 rs := &ProjectsLocationsOperationsService{s: s} 181 return rs 182} 183 184type ProjectsLocationsOperationsService struct { 185 s *Service 186} 187 188func NewSpeechService(s *Service) *SpeechService { 189 rs := &SpeechService{s: s} 190 return rs 191} 192 193type SpeechService struct { 194 s *Service 195} 196 197// ListOperationsResponse: The response message for 198// Operations.ListOperations. 199type ListOperationsResponse struct { 200 // NextPageToken: The standard List next-page token. 201 NextPageToken string `json:"nextPageToken,omitempty"` 202 203 // Operations: A list of operations that matches the specified filter in 204 // the request. 205 Operations []*Operation `json:"operations,omitempty"` 206 207 // ServerResponse contains the HTTP response code and headers from the 208 // server. 209 googleapi.ServerResponse `json:"-"` 210 211 // ForceSendFields is a list of field names (e.g. "NextPageToken") to 212 // unconditionally include in API requests. By default, fields with 213 // empty values are omitted from API requests. However, any non-pointer, 214 // non-interface field appearing in ForceSendFields will be sent to the 215 // server regardless of whether the field is empty or not. This may be 216 // used to include empty fields in Patch requests. 217 ForceSendFields []string `json:"-"` 218 219 // NullFields is a list of field names (e.g. "NextPageToken") to include 220 // in API requests with the JSON null value. By default, fields with 221 // empty values are omitted from API requests. However, any field with 222 // an empty value appearing in NullFields will be sent to the server as 223 // null. It is an error if a field in this list has a non-empty value. 224 // This may be used to include null fields in Patch requests. 225 NullFields []string `json:"-"` 226} 227 228func (s *ListOperationsResponse) MarshalJSON() ([]byte, error) { 229 type NoMethod ListOperationsResponse 230 raw := NoMethod(*s) 231 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 232} 233 234// LongRunningRecognizeMetadata: Describes the progress of a 235// long-running `LongRunningRecognize` call. It is 236// included in the `metadata` field of the `Operation` returned by 237// the 238// `GetOperation` call of the `google::longrunning::Operations` service. 239type LongRunningRecognizeMetadata struct { 240 // LastUpdateTime: Time of the most recent processing update. 241 LastUpdateTime string `json:"lastUpdateTime,omitempty"` 242 243 // ProgressPercent: Approximate percentage of audio processed thus far. 244 // Guaranteed to be 100 245 // when the audio is fully processed and the results are available. 246 ProgressPercent int64 `json:"progressPercent,omitempty"` 247 248 // StartTime: Time when the request was received. 249 StartTime string `json:"startTime,omitempty"` 250 251 // Uri: Output only. The URI of the audio file being transcribed. Empty 252 // if the audio was sent 253 // as byte content. 254 Uri string `json:"uri,omitempty"` 255 256 // ForceSendFields is a list of field names (e.g. "LastUpdateTime") to 257 // unconditionally include in API requests. By default, fields with 258 // empty values are omitted from API requests. However, any non-pointer, 259 // non-interface field appearing in ForceSendFields will be sent to the 260 // server regardless of whether the field is empty or not. This may be 261 // used to include empty fields in Patch requests. 262 ForceSendFields []string `json:"-"` 263 264 // NullFields is a list of field names (e.g. "LastUpdateTime") to 265 // include in API requests with the JSON null value. By default, fields 266 // with empty values are omitted from API requests. However, any field 267 // with an empty value appearing in NullFields will be sent to the 268 // server as null. It is an error if a field in this list has a 269 // non-empty value. This may be used to include null fields in Patch 270 // requests. 271 NullFields []string `json:"-"` 272} 273 274func (s *LongRunningRecognizeMetadata) MarshalJSON() ([]byte, error) { 275 type NoMethod LongRunningRecognizeMetadata 276 raw := NoMethod(*s) 277 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 278} 279 280// LongRunningRecognizeRequest: The top-level message sent by the client 281// for the `LongRunningRecognize` 282// method. 283type LongRunningRecognizeRequest struct { 284 // Audio: Required. The audio data to be recognized. 285 Audio *RecognitionAudio `json:"audio,omitempty"` 286 287 // Config: Required. Provides information to the recognizer that 288 // specifies how to 289 // process the request. 290 Config *RecognitionConfig `json:"config,omitempty"` 291 292 // ForceSendFields is a list of field names (e.g. "Audio") to 293 // unconditionally include in API requests. By default, fields with 294 // empty values are omitted from API requests. However, any non-pointer, 295 // non-interface field appearing in ForceSendFields will be sent to the 296 // server regardless of whether the field is empty or not. This may be 297 // used to include empty fields in Patch requests. 298 ForceSendFields []string `json:"-"` 299 300 // NullFields is a list of field names (e.g. "Audio") to include in API 301 // requests with the JSON null value. By default, fields with empty 302 // values are omitted from API requests. However, any field with an 303 // empty value appearing in NullFields will be sent to the server as 304 // null. It is an error if a field in this list has a non-empty value. 305 // This may be used to include null fields in Patch requests. 306 NullFields []string `json:"-"` 307} 308 309func (s *LongRunningRecognizeRequest) MarshalJSON() ([]byte, error) { 310 type NoMethod LongRunningRecognizeRequest 311 raw := NoMethod(*s) 312 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 313} 314 315// LongRunningRecognizeResponse: The only message returned to the client 316// by the `LongRunningRecognize` method. 317// It contains the result as zero or more sequential 318// `SpeechRecognitionResult` 319// messages. It is included in the `result.response` field of the 320// `Operation` 321// returned by the `GetOperation` call of the 322// `google::longrunning::Operations` 323// service. 324type LongRunningRecognizeResponse struct { 325 // Results: Sequential list of transcription results corresponding 326 // to 327 // sequential portions of audio. 328 Results []*SpeechRecognitionResult `json:"results,omitempty"` 329 330 // ForceSendFields is a list of field names (e.g. "Results") to 331 // unconditionally include in API requests. By default, fields with 332 // empty values are omitted from API requests. However, any non-pointer, 333 // non-interface field appearing in ForceSendFields will be sent to the 334 // server regardless of whether the field is empty or not. This may be 335 // used to include empty fields in Patch requests. 336 ForceSendFields []string `json:"-"` 337 338 // NullFields is a list of field names (e.g. "Results") to include in 339 // API requests with the JSON null value. By default, fields with empty 340 // values are omitted from API requests. However, any field with an 341 // empty value appearing in NullFields will be sent to the server as 342 // null. It is an error if a field in this list has a non-empty value. 343 // This may be used to include null fields in Patch requests. 344 NullFields []string `json:"-"` 345} 346 347func (s *LongRunningRecognizeResponse) MarshalJSON() ([]byte, error) { 348 type NoMethod LongRunningRecognizeResponse 349 raw := NoMethod(*s) 350 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 351} 352 353// Operation: This resource represents a long-running operation that is 354// the result of a 355// network API call. 356type Operation struct { 357 // Done: If the value is `false`, it means the operation is still in 358 // progress. 359 // If `true`, the operation is completed, and either `error` or 360 // `response` is 361 // available. 362 Done bool `json:"done,omitempty"` 363 364 // Error: The error result of the operation in case of failure or 365 // cancellation. 366 Error *Status `json:"error,omitempty"` 367 368 // Metadata: Service-specific metadata associated with the operation. 369 // It typically 370 // contains progress information and common metadata such as create 371 // time. 372 // Some services might not provide such metadata. Any method that 373 // returns a 374 // long-running operation should document the metadata type, if any. 375 Metadata googleapi.RawMessage `json:"metadata,omitempty"` 376 377 // Name: The server-assigned name, which is only unique within the same 378 // service that 379 // originally returns it. If you use the default HTTP mapping, 380 // the 381 // `name` should be a resource name ending with 382 // `operations/{unique_id}`. 383 Name string `json:"name,omitempty"` 384 385 // Response: The normal response of the operation in case of success. 386 // If the original 387 // method returns no data on success, such as `Delete`, the response 388 // is 389 // `google.protobuf.Empty`. If the original method is 390 // standard 391 // `Get`/`Create`/`Update`, the response should be the resource. For 392 // other 393 // methods, the response should have the type `XxxResponse`, where 394 // `Xxx` 395 // is the original method name. For example, if the original method 396 // name 397 // is `TakeSnapshot()`, the inferred response type 398 // is 399 // `TakeSnapshotResponse`. 400 Response googleapi.RawMessage `json:"response,omitempty"` 401 402 // ServerResponse contains the HTTP response code and headers from the 403 // server. 404 googleapi.ServerResponse `json:"-"` 405 406 // ForceSendFields is a list of field names (e.g. "Done") to 407 // unconditionally include in API requests. By default, fields with 408 // empty values are omitted from API requests. However, any non-pointer, 409 // non-interface field appearing in ForceSendFields will be sent to the 410 // server regardless of whether the field is empty or not. This may be 411 // used to include empty fields in Patch requests. 412 ForceSendFields []string `json:"-"` 413 414 // NullFields is a list of field names (e.g. "Done") to include in API 415 // requests with the JSON null value. By default, fields with empty 416 // values are omitted from API requests. However, any field with an 417 // empty value appearing in NullFields will be sent to the server as 418 // null. It is an error if a field in this list has a non-empty value. 419 // This may be used to include null fields in Patch requests. 420 NullFields []string `json:"-"` 421} 422 423func (s *Operation) MarshalJSON() ([]byte, error) { 424 type NoMethod Operation 425 raw := NoMethod(*s) 426 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 427} 428 429// RecognitionAudio: Contains audio data in the encoding specified in 430// the `RecognitionConfig`. 431// Either `content` or `uri` must be supplied. Supplying both or 432// neither 433// returns google.rpc.Code.INVALID_ARGUMENT. See 434// [content 435// limits](https://cloud.google.com/speech-to-text/quotas#content). 436type RecognitionAudio struct { 437 // Content: The audio data bytes encoded as specified 438 // in 439 // `RecognitionConfig`. Note: as with all bytes fields, proto buffers 440 // use a 441 // pure binary representation, whereas JSON representations use base64. 442 Content string `json:"content,omitempty"` 443 444 // Uri: URI that points to a file that contains audio data bytes as 445 // specified in 446 // `RecognitionConfig`. The file must not be compressed (for example, 447 // gzip). 448 // Currently, only Google Cloud Storage URIs are 449 // supported, which must be specified in the following 450 // format: 451 // `gs://bucket_name/object_name` (other URI formats 452 // return 453 // google.rpc.Code.INVALID_ARGUMENT). For more information, see 454 // [Request URIs](https://cloud.google.com/storage/docs/reference-uris). 455 Uri string `json:"uri,omitempty"` 456 457 // ForceSendFields is a list of field names (e.g. "Content") to 458 // unconditionally include in API requests. By default, fields with 459 // empty values are omitted from API requests. However, any non-pointer, 460 // non-interface field appearing in ForceSendFields will be sent to the 461 // server regardless of whether the field is empty or not. This may be 462 // used to include empty fields in Patch requests. 463 ForceSendFields []string `json:"-"` 464 465 // NullFields is a list of field names (e.g. "Content") to include in 466 // API requests with the JSON null value. By default, fields with empty 467 // values are omitted from API requests. However, any field with an 468 // empty value appearing in NullFields will be sent to the server as 469 // null. It is an error if a field in this list has a non-empty value. 470 // This may be used to include null fields in Patch requests. 471 NullFields []string `json:"-"` 472} 473 474func (s *RecognitionAudio) MarshalJSON() ([]byte, error) { 475 type NoMethod RecognitionAudio 476 raw := NoMethod(*s) 477 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 478} 479 480// RecognitionConfig: Provides information to the recognizer that 481// specifies how to process the 482// request. 483type RecognitionConfig struct { 484 // AudioChannelCount: The number of channels in the input audio 485 // data. 486 // ONLY set this for MULTI-CHANNEL recognition. 487 // Valid values for LINEAR16 and FLAC are `1`-`8`. 488 // Valid values for OGG_OPUS are '1'-'254'. 489 // Valid value for MULAW, AMR, AMR_WB and SPEEX_WITH_HEADER_BYTE is only 490 // `1`. 491 // If `0` or omitted, defaults to one channel (mono). 492 // Note: We only recognize the first channel by default. 493 // To perform independent recognition on each channel 494 // set 495 // `enable_separate_recognition_per_channel` to 'true'. 496 AudioChannelCount int64 `json:"audioChannelCount,omitempty"` 497 498 // DiarizationConfig: Config to enable speaker diarization and set 499 // additional 500 // parameters to make diarization better suited for your 501 // application. 502 // Note: When this is enabled, we send all the words from the beginning 503 // of the 504 // audio for the top alternative in every consecutive STREAMING 505 // responses. 506 // This is done in order to improve our speaker tags as our models learn 507 // to 508 // identify the speakers in the conversation over time. 509 // For non-streaming requests, the diarization results will be provided 510 // only 511 // in the top alternative of the FINAL SpeechRecognitionResult. 512 DiarizationConfig *SpeakerDiarizationConfig `json:"diarizationConfig,omitempty"` 513 514 // EnableAutomaticPunctuation: If 'true', adds punctuation to 515 // recognition result hypotheses. 516 // This feature is only available in select languages. Setting this 517 // for 518 // requests in other languages has no effect at all. 519 // The default 'false' value does not add punctuation to result 520 // hypotheses. 521 EnableAutomaticPunctuation bool `json:"enableAutomaticPunctuation,omitempty"` 522 523 // EnableSeparateRecognitionPerChannel: This needs to be set to `true` 524 // explicitly and `audio_channel_count` > 1 525 // to get each channel recognized separately. The recognition result 526 // will 527 // contain a `channel_tag` field to state which channel that result 528 // belongs 529 // to. If this is not true, we will only recognize the first channel. 530 // The 531 // request is billed cumulatively for all channels 532 // recognized: 533 // `audio_channel_count` multiplied by the length of the audio. 534 EnableSeparateRecognitionPerChannel bool `json:"enableSeparateRecognitionPerChannel,omitempty"` 535 536 // EnableWordTimeOffsets: If `true`, the top result includes a list of 537 // words and 538 // the start and end time offsets (timestamps) for those words. 539 // If 540 // `false`, no word-level time offset information is returned. The 541 // default is 542 // `false`. 543 EnableWordTimeOffsets bool `json:"enableWordTimeOffsets,omitempty"` 544 545 // Encoding: Encoding of audio data sent in all `RecognitionAudio` 546 // messages. 547 // This field is optional for `FLAC` and `WAV` audio files and 548 // required 549 // for all other audio formats. For details, see AudioEncoding. 550 // 551 // Possible values: 552 // "ENCODING_UNSPECIFIED" - Not specified. 553 // "LINEAR16" - Uncompressed 16-bit signed little-endian samples 554 // (Linear PCM). 555 // "FLAC" - `FLAC` (Free Lossless Audio 556 // Codec) is the recommended encoding because it is 557 // lossless--therefore recognition is not compromised--and 558 // requires only about half the bandwidth of `LINEAR16`. `FLAC` 559 // stream 560 // encoding supports 16-bit and 24-bit samples, however, not all fields 561 // in 562 // `STREAMINFO` are supported. 563 // "MULAW" - 8-bit samples that compand 14-bit audio samples using 564 // G.711 PCMU/mu-law. 565 // "AMR" - Adaptive Multi-Rate Narrowband codec. `sample_rate_hertz` 566 // must be 8000. 567 // "AMR_WB" - Adaptive Multi-Rate Wideband codec. `sample_rate_hertz` 568 // must be 16000. 569 // "OGG_OPUS" - Opus encoded audio frames in Ogg 570 // container 571 // ([OggOpus](https://wiki.xiph.org/OggOpus)). 572 // `sample_rate_her 573 // tz` must be one of 8000, 12000, 16000, 24000, or 48000. 574 // "SPEEX_WITH_HEADER_BYTE" - Although the use of lossy encodings is 575 // not recommended, if a very low 576 // bitrate encoding is required, `OGG_OPUS` is highly preferred 577 // over 578 // Speex encoding. The [Speex](https://speex.org/) encoding supported 579 // by 580 // Cloud Speech API has a header byte in each block, as in MIME 581 // type 582 // `audio/x-speex-with-header-byte`. 583 // It is a variant of the RTP Speex encoding defined in 584 // [RFC 5574](https://tools.ietf.org/html/rfc5574). 585 // The stream is a sequence of blocks, one block per RTP packet. Each 586 // block 587 // starts with a byte containing the length of the block, in bytes, 588 // followed 589 // by one or more frames of Speex data, padded to an integral number 590 // of 591 // bytes (octets) as specified in RFC 5574. In other words, each RTP 592 // header 593 // is replaced with a single byte containing the block length. Only 594 // Speex 595 // wideband is supported. `sample_rate_hertz` must be 16000. 596 Encoding string `json:"encoding,omitempty"` 597 598 // LanguageCode: Required. The language of the supplied audio as 599 // a 600 // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language 601 // tag. 602 // Example: "en-US". 603 // See 604 // [Language 605 // Support](https://cloud.google.com/speech-to-text/docs/langua 606 // ges) for a list 607 // of the currently supported language codes. 608 LanguageCode string `json:"languageCode,omitempty"` 609 610 // MaxAlternatives: Maximum number of recognition hypotheses to be 611 // returned. 612 // Specifically, the maximum number of `SpeechRecognitionAlternative` 613 // messages 614 // within each `SpeechRecognitionResult`. 615 // The server may return fewer than `max_alternatives`. 616 // Valid values are `0`-`30`. A value of `0` or `1` will return a 617 // maximum of 618 // one. If omitted, will return a maximum of one. 619 MaxAlternatives int64 `json:"maxAlternatives,omitempty"` 620 621 // Metadata: Metadata regarding this request. 622 Metadata *RecognitionMetadata `json:"metadata,omitempty"` 623 624 // Model: Which model to select for the given request. Select the 625 // model 626 // best suited to your domain to get best results. If a model is 627 // not 628 // explicitly specified, then we auto-select a model based on the 629 // parameters 630 // in the RecognitionConfig. 631 // <table> 632 // <tr> 633 // <td><b>Model</b></td> 634 // <td><b>Description</b></td> 635 // </tr> 636 // <tr> 637 // <td><code>command_and_search</code></td> 638 // <td>Best for short queries such as voice commands or voice 639 // search.</td> 640 // </tr> 641 // <tr> 642 // <td><code>phone_call</code></td> 643 // <td>Best for audio that originated from a phone call (typically 644 // recorded at an 8khz sampling rate).</td> 645 // </tr> 646 // <tr> 647 // <td><code>video</code></td> 648 // <td>Best for audio that originated from from video or includes 649 // multiple 650 // speakers. Ideally the audio is recorded at a 16khz or 651 // greater 652 // sampling rate. This is a premium model that costs more than 653 // the 654 // standard rate.</td> 655 // </tr> 656 // <tr> 657 // <td><code>default</code></td> 658 // <td>Best for audio that is not one of the specific audio models. 659 // For example, long-form audio. Ideally the audio is 660 // high-fidelity, 661 // recorded at a 16khz or greater sampling rate.</td> 662 // </tr> 663 // </table> 664 Model string `json:"model,omitempty"` 665 666 // ProfanityFilter: If set to `true`, the server will attempt to filter 667 // out 668 // profanities, replacing all but the initial character in each filtered 669 // word 670 // with asterisks, e.g. "f***". If set to `false` or omitted, 671 // profanities 672 // won't be filtered out. 673 ProfanityFilter bool `json:"profanityFilter,omitempty"` 674 675 // SampleRateHertz: Sample rate in Hertz of the audio data sent in 676 // all 677 // `RecognitionAudio` messages. Valid values are: 8000-48000. 678 // 16000 is optimal. For best results, set the sampling rate of the 679 // audio 680 // source to 16000 Hz. If that's not possible, use the native sample 681 // rate of 682 // the audio source (instead of re-sampling). 683 // This field is optional for FLAC and WAV audio files, but is 684 // required for all other audio formats. For details, see AudioEncoding. 685 SampleRateHertz int64 `json:"sampleRateHertz,omitempty"` 686 687 // SpeechContexts: Array of SpeechContext. 688 // A means to provide context to assist the speech recognition. For 689 // more 690 // information, 691 // see 692 // [speech 693 // adaptation](https://cloud.google.com/speech-to-text/docs/c 694 // ontext-strength). 695 SpeechContexts []*SpeechContext `json:"speechContexts,omitempty"` 696 697 // UseEnhanced: Set to true to use an enhanced model for speech 698 // recognition. 699 // If `use_enhanced` is set to true and the `model` field is not set, 700 // then 701 // an appropriate enhanced model is chosen if an enhanced model exists 702 // for 703 // the audio. 704 // 705 // If `use_enhanced` is true and an enhanced version of the specified 706 // model 707 // does not exist, then the speech is recognized using the standard 708 // version 709 // of the specified model. 710 UseEnhanced bool `json:"useEnhanced,omitempty"` 711 712 // ForceSendFields is a list of field names (e.g. "AudioChannelCount") 713 // to unconditionally include in API requests. By default, fields with 714 // empty values are omitted from API requests. However, any non-pointer, 715 // non-interface field appearing in ForceSendFields will be sent to the 716 // server regardless of whether the field is empty or not. This may be 717 // used to include empty fields in Patch requests. 718 ForceSendFields []string `json:"-"` 719 720 // NullFields is a list of field names (e.g. "AudioChannelCount") to 721 // include in API requests with the JSON null value. By default, fields 722 // with empty values are omitted from API requests. However, any field 723 // with an empty value appearing in NullFields will be sent to the 724 // server as null. It is an error if a field in this list has a 725 // non-empty value. This may be used to include null fields in Patch 726 // requests. 727 NullFields []string `json:"-"` 728} 729 730func (s *RecognitionConfig) MarshalJSON() ([]byte, error) { 731 type NoMethod RecognitionConfig 732 raw := NoMethod(*s) 733 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 734} 735 736// RecognitionMetadata: Description of audio data to be recognized. 737type RecognitionMetadata struct { 738 // AudioTopic: Description of the content. Eg. "Recordings of federal 739 // supreme court 740 // hearings from 2012". 741 AudioTopic string `json:"audioTopic,omitempty"` 742 743 // IndustryNaicsCodeOfAudio: The industry vertical to which this speech 744 // recognition request most 745 // closely applies. This is most indicative of the topics contained 746 // in the audio. Use the 6-digit NAICS code to identify the 747 // industry 748 // vertical - see https://www.naics.com/search/. 749 IndustryNaicsCodeOfAudio int64 `json:"industryNaicsCodeOfAudio,omitempty"` 750 751 // InteractionType: The use case most closely describing the audio 752 // content to be recognized. 753 // 754 // Possible values: 755 // "INTERACTION_TYPE_UNSPECIFIED" - Use case is either unknown or is 756 // something other than one of the other 757 // values below. 758 // "DISCUSSION" - Multiple people in a conversation or discussion. For 759 // example in a 760 // meeting with two or more people actively participating. Typically 761 // all the primary people speaking would be in the same room (if 762 // not, 763 // see PHONE_CALL) 764 // "PRESENTATION" - One or more persons lecturing or presenting to 765 // others, mostly 766 // uninterrupted. 767 // "PHONE_CALL" - A phone-call or video-conference in which two or 768 // more people, who are 769 // not in the same room, are actively participating. 770 // "VOICEMAIL" - A recorded message intended for another person to 771 // listen to. 772 // "PROFESSIONALLY_PRODUCED" - Professionally produced audio (eg. TV 773 // Show, Podcast). 774 // "VOICE_SEARCH" - Transcribe spoken questions and queries into text. 775 // "VOICE_COMMAND" - Transcribe voice commands, such as for 776 // controlling a device. 777 // "DICTATION" - Transcribe speech to text to create a written 778 // document, such as a 779 // text-message, email or report. 780 InteractionType string `json:"interactionType,omitempty"` 781 782 // MicrophoneDistance: The audio type that most closely describes the 783 // audio being recognized. 784 // 785 // Possible values: 786 // "MICROPHONE_DISTANCE_UNSPECIFIED" - Audio type is not known. 787 // "NEARFIELD" - The audio was captured from a closely placed 788 // microphone. Eg. phone, 789 // dictaphone, or handheld microphone. Generally if there speaker is 790 // within 791 // 1 meter of the microphone. 792 // "MIDFIELD" - The speaker if within 3 meters of the microphone. 793 // "FARFIELD" - The speaker is more than 3 meters away from the 794 // microphone. 795 MicrophoneDistance string `json:"microphoneDistance,omitempty"` 796 797 // OriginalMediaType: The original media the speech was recorded on. 798 // 799 // Possible values: 800 // "ORIGINAL_MEDIA_TYPE_UNSPECIFIED" - Unknown original media type. 801 // "AUDIO" - The speech data is an audio recording. 802 // "VIDEO" - The speech data originally recorded on a video. 803 OriginalMediaType string `json:"originalMediaType,omitempty"` 804 805 // OriginalMimeType: Mime type of the original audio file. For example 806 // `audio/m4a`, 807 // `audio/x-alaw-basic`, `audio/mp3`, `audio/3gpp`. 808 // A list of possible audio mime types is maintained 809 // at 810 // http://www.iana.org/assignments/media-types/media-types.xhtml#audio 811 OriginalMimeType string `json:"originalMimeType,omitempty"` 812 813 // RecordingDeviceName: The device used to make the recording. Examples 814 // 'Nexus 5X' or 815 // 'Polycom SoundStation IP 6000' or 'POTS' or 'VoIP' or 816 // 'Cardioid Microphone'. 817 RecordingDeviceName string `json:"recordingDeviceName,omitempty"` 818 819 // RecordingDeviceType: The type of device the speech was recorded with. 820 // 821 // Possible values: 822 // "RECORDING_DEVICE_TYPE_UNSPECIFIED" - The recording device is 823 // unknown. 824 // "SMARTPHONE" - Speech was recorded on a smartphone. 825 // "PC" - Speech was recorded using a personal computer or tablet. 826 // "PHONE_LINE" - Speech was recorded over a phone line. 827 // "VEHICLE" - Speech was recorded in a vehicle. 828 // "OTHER_OUTDOOR_DEVICE" - Speech was recorded outdoors. 829 // "OTHER_INDOOR_DEVICE" - Speech was recorded indoors. 830 RecordingDeviceType string `json:"recordingDeviceType,omitempty"` 831 832 // ForceSendFields is a list of field names (e.g. "AudioTopic") to 833 // unconditionally include in API requests. By default, fields with 834 // empty values are omitted from API requests. However, any non-pointer, 835 // non-interface field appearing in ForceSendFields will be sent to the 836 // server regardless of whether the field is empty or not. This may be 837 // used to include empty fields in Patch requests. 838 ForceSendFields []string `json:"-"` 839 840 // NullFields is a list of field names (e.g. "AudioTopic") to include in 841 // API requests with the JSON null value. By default, fields with empty 842 // values are omitted from API requests. However, any field with an 843 // empty value appearing in NullFields will be sent to the server as 844 // null. It is an error if a field in this list has a non-empty value. 845 // This may be used to include null fields in Patch requests. 846 NullFields []string `json:"-"` 847} 848 849func (s *RecognitionMetadata) MarshalJSON() ([]byte, error) { 850 type NoMethod RecognitionMetadata 851 raw := NoMethod(*s) 852 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 853} 854 855// RecognizeRequest: The top-level message sent by the client for the 856// `Recognize` method. 857type RecognizeRequest struct { 858 // Audio: Required. The audio data to be recognized. 859 Audio *RecognitionAudio `json:"audio,omitempty"` 860 861 // Config: Required. Provides information to the recognizer that 862 // specifies how to 863 // process the request. 864 Config *RecognitionConfig `json:"config,omitempty"` 865 866 // ForceSendFields is a list of field names (e.g. "Audio") to 867 // unconditionally include in API requests. By default, fields with 868 // empty values are omitted from API requests. However, any non-pointer, 869 // non-interface field appearing in ForceSendFields will be sent to the 870 // server regardless of whether the field is empty or not. This may be 871 // used to include empty fields in Patch requests. 872 ForceSendFields []string `json:"-"` 873 874 // NullFields is a list of field names (e.g. "Audio") to include in API 875 // requests with the JSON null value. By default, fields with empty 876 // values are omitted from API requests. However, any field with an 877 // empty value appearing in NullFields will be sent to the server as 878 // null. It is an error if a field in this list has a non-empty value. 879 // This may be used to include null fields in Patch requests. 880 NullFields []string `json:"-"` 881} 882 883func (s *RecognizeRequest) MarshalJSON() ([]byte, error) { 884 type NoMethod RecognizeRequest 885 raw := NoMethod(*s) 886 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 887} 888 889// RecognizeResponse: The only message returned to the client by the 890// `Recognize` method. It 891// contains the result as zero or more sequential 892// `SpeechRecognitionResult` 893// messages. 894type RecognizeResponse struct { 895 // Results: Sequential list of transcription results corresponding 896 // to 897 // sequential portions of audio. 898 Results []*SpeechRecognitionResult `json:"results,omitempty"` 899 900 // ServerResponse contains the HTTP response code and headers from the 901 // server. 902 googleapi.ServerResponse `json:"-"` 903 904 // ForceSendFields is a list of field names (e.g. "Results") to 905 // unconditionally include in API requests. By default, fields with 906 // empty values are omitted from API requests. However, any non-pointer, 907 // non-interface field appearing in ForceSendFields will be sent to the 908 // server regardless of whether the field is empty or not. This may be 909 // used to include empty fields in Patch requests. 910 ForceSendFields []string `json:"-"` 911 912 // NullFields is a list of field names (e.g. "Results") to include in 913 // API requests with the JSON null value. By default, fields with empty 914 // values are omitted from API requests. However, any field with an 915 // empty value appearing in NullFields will be sent to the server as 916 // null. It is an error if a field in this list has a non-empty value. 917 // This may be used to include null fields in Patch requests. 918 NullFields []string `json:"-"` 919} 920 921func (s *RecognizeResponse) MarshalJSON() ([]byte, error) { 922 type NoMethod RecognizeResponse 923 raw := NoMethod(*s) 924 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 925} 926 927// SpeakerDiarizationConfig: Config to enable speaker diarization. 928type SpeakerDiarizationConfig struct { 929 // EnableSpeakerDiarization: If 'true', enables speaker detection for 930 // each recognized word in 931 // the top alternative of the recognition result using a speaker_tag 932 // provided 933 // in the WordInfo. 934 EnableSpeakerDiarization bool `json:"enableSpeakerDiarization,omitempty"` 935 936 // MaxSpeakerCount: Maximum number of speakers in the conversation. This 937 // range gives you more 938 // flexibility by allowing the system to automatically determine the 939 // correct 940 // number of speakers. If not set, the default value is 6. 941 MaxSpeakerCount int64 `json:"maxSpeakerCount,omitempty"` 942 943 // MinSpeakerCount: Minimum number of speakers in the conversation. This 944 // range gives you more 945 // flexibility by allowing the system to automatically determine the 946 // correct 947 // number of speakers. If not set, the default value is 2. 948 MinSpeakerCount int64 `json:"minSpeakerCount,omitempty"` 949 950 // SpeakerTag: Output only. Unused. 951 SpeakerTag int64 `json:"speakerTag,omitempty"` 952 953 // ForceSendFields is a list of field names (e.g. 954 // "EnableSpeakerDiarization") to unconditionally include in API 955 // requests. By default, fields with empty values are omitted from API 956 // requests. However, any non-pointer, non-interface field appearing in 957 // ForceSendFields will be sent to the server regardless of whether the 958 // field is empty or not. This may be used to include empty fields in 959 // Patch requests. 960 ForceSendFields []string `json:"-"` 961 962 // NullFields is a list of field names (e.g. "EnableSpeakerDiarization") 963 // to include in API requests with the JSON null value. By default, 964 // fields with empty values are omitted from API requests. However, any 965 // field with an empty value appearing in NullFields will be sent to the 966 // server as null. It is an error if a field in this list has a 967 // non-empty value. This may be used to include null fields in Patch 968 // requests. 969 NullFields []string `json:"-"` 970} 971 972func (s *SpeakerDiarizationConfig) MarshalJSON() ([]byte, error) { 973 type NoMethod SpeakerDiarizationConfig 974 raw := NoMethod(*s) 975 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 976} 977 978// SpeechContext: Provides "hints" to the speech recognizer to favor 979// specific words and phrases 980// in the results. 981type SpeechContext struct { 982 // Phrases: A list of strings containing words and phrases "hints" so 983 // that 984 // the speech recognition is more likely to recognize them. This can be 985 // used 986 // to improve the accuracy for specific words and phrases, for example, 987 // if 988 // specific commands are typically spoken by the user. This can also be 989 // used 990 // to add additional words to the vocabulary of the recognizer. 991 // See 992 // [usage 993 // limits](https://cloud.google.com/speech-to-text/quotas#content). 994 // 995 // List 996 // items can also be set to classes for groups of words that 997 // represent 998 // common concepts that occur in natural language. For example, rather 999 // than 1000 // providing phrase hints for every month of the year, using the $MONTH 1001 // class 1002 // improves the likelihood of correctly transcribing audio that 1003 // includes 1004 // months. 1005 Phrases []string `json:"phrases,omitempty"` 1006 1007 // ForceSendFields is a list of field names (e.g. "Phrases") to 1008 // unconditionally include in API requests. By default, fields with 1009 // empty values are omitted from API requests. However, any non-pointer, 1010 // non-interface field appearing in ForceSendFields will be sent to the 1011 // server regardless of whether the field is empty or not. This may be 1012 // used to include empty fields in Patch requests. 1013 ForceSendFields []string `json:"-"` 1014 1015 // NullFields is a list of field names (e.g. "Phrases") to include in 1016 // API requests with the JSON null value. By default, fields with empty 1017 // values are omitted from API requests. However, any field with an 1018 // empty value appearing in NullFields will be sent to the server as 1019 // null. It is an error if a field in this list has a non-empty value. 1020 // This may be used to include null fields in Patch requests. 1021 NullFields []string `json:"-"` 1022} 1023 1024func (s *SpeechContext) MarshalJSON() ([]byte, error) { 1025 type NoMethod SpeechContext 1026 raw := NoMethod(*s) 1027 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 1028} 1029 1030// SpeechRecognitionAlternative: Alternative hypotheses (a.k.a. n-best 1031// list). 1032type SpeechRecognitionAlternative struct { 1033 // Confidence: The confidence estimate between 0.0 and 1.0. A higher 1034 // number 1035 // indicates an estimated greater likelihood that the recognized words 1036 // are 1037 // correct. This field is set only for the top alternative of a 1038 // non-streaming 1039 // result or, of a streaming result where `is_final=true`. 1040 // This field is not guaranteed to be accurate and users should not rely 1041 // on it 1042 // to be always provided. 1043 // The default of 0.0 is a sentinel value indicating `confidence` was 1044 // not set. 1045 Confidence float64 `json:"confidence,omitempty"` 1046 1047 // Transcript: Transcript text representing the words that the user 1048 // spoke. 1049 Transcript string `json:"transcript,omitempty"` 1050 1051 // Words: A list of word-specific information for each recognized 1052 // word. 1053 // Note: When `enable_speaker_diarization` is true, you will see all the 1054 // words 1055 // from the beginning of the audio. 1056 Words []*WordInfo `json:"words,omitempty"` 1057 1058 // ForceSendFields is a list of field names (e.g. "Confidence") to 1059 // unconditionally include in API requests. By default, fields with 1060 // empty values are omitted from API requests. However, any non-pointer, 1061 // non-interface field appearing in ForceSendFields will be sent to the 1062 // server regardless of whether the field is empty or not. This may be 1063 // used to include empty fields in Patch requests. 1064 ForceSendFields []string `json:"-"` 1065 1066 // NullFields is a list of field names (e.g. "Confidence") to include in 1067 // API requests with the JSON null value. By default, fields with empty 1068 // values are omitted from API requests. However, any field with an 1069 // empty value appearing in NullFields will be sent to the server as 1070 // null. It is an error if a field in this list has a non-empty value. 1071 // This may be used to include null fields in Patch requests. 1072 NullFields []string `json:"-"` 1073} 1074 1075func (s *SpeechRecognitionAlternative) MarshalJSON() ([]byte, error) { 1076 type NoMethod SpeechRecognitionAlternative 1077 raw := NoMethod(*s) 1078 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 1079} 1080 1081func (s *SpeechRecognitionAlternative) UnmarshalJSON(data []byte) error { 1082 type NoMethod SpeechRecognitionAlternative 1083 var s1 struct { 1084 Confidence gensupport.JSONFloat64 `json:"confidence"` 1085 *NoMethod 1086 } 1087 s1.NoMethod = (*NoMethod)(s) 1088 if err := json.Unmarshal(data, &s1); err != nil { 1089 return err 1090 } 1091 s.Confidence = float64(s1.Confidence) 1092 return nil 1093} 1094 1095// SpeechRecognitionResult: A speech recognition result corresponding to 1096// a portion of the audio. 1097type SpeechRecognitionResult struct { 1098 // Alternatives: May contain one or more recognition hypotheses (up to 1099 // the 1100 // maximum specified in `max_alternatives`). 1101 // These alternatives are ordered in terms of accuracy, with the top 1102 // (first) 1103 // alternative being the most probable, as ranked by the recognizer. 1104 Alternatives []*SpeechRecognitionAlternative `json:"alternatives,omitempty"` 1105 1106 // ChannelTag: For multi-channel audio, this is the channel number 1107 // corresponding to the 1108 // recognized result for the audio from that channel. 1109 // For audio_channel_count = N, its output values can range from '1' to 1110 // 'N'. 1111 ChannelTag int64 `json:"channelTag,omitempty"` 1112 1113 // ForceSendFields is a list of field names (e.g. "Alternatives") to 1114 // unconditionally include in API requests. By default, fields with 1115 // empty values are omitted from API requests. However, any non-pointer, 1116 // non-interface field appearing in ForceSendFields will be sent to the 1117 // server regardless of whether the field is empty or not. This may be 1118 // used to include empty fields in Patch requests. 1119 ForceSendFields []string `json:"-"` 1120 1121 // NullFields is a list of field names (e.g. "Alternatives") to include 1122 // in API requests with the JSON null value. By default, fields with 1123 // empty values are omitted from API requests. However, any field with 1124 // an empty value appearing in NullFields will be sent to the server as 1125 // null. It is an error if a field in this list has a non-empty value. 1126 // This may be used to include null fields in Patch requests. 1127 NullFields []string `json:"-"` 1128} 1129 1130func (s *SpeechRecognitionResult) MarshalJSON() ([]byte, error) { 1131 type NoMethod SpeechRecognitionResult 1132 raw := NoMethod(*s) 1133 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 1134} 1135 1136// Status: The `Status` type defines a logical error model that is 1137// suitable for 1138// different programming environments, including REST APIs and RPC APIs. 1139// It is 1140// used by [gRPC](https://github.com/grpc). Each `Status` message 1141// contains 1142// three pieces of data: error code, error message, and error 1143// details. 1144// 1145// You can find out more about this error model and how to work with it 1146// in the 1147// [API Design Guide](https://cloud.google.com/apis/design/errors). 1148type Status struct { 1149 // Code: The status code, which should be an enum value of 1150 // google.rpc.Code. 1151 Code int64 `json:"code,omitempty"` 1152 1153 // Details: A list of messages that carry the error details. There is a 1154 // common set of 1155 // message types for APIs to use. 1156 Details []googleapi.RawMessage `json:"details,omitempty"` 1157 1158 // Message: A developer-facing error message, which should be in 1159 // English. Any 1160 // user-facing error message should be localized and sent in 1161 // the 1162 // google.rpc.Status.details field, or localized by the client. 1163 Message string `json:"message,omitempty"` 1164 1165 // ForceSendFields is a list of field names (e.g. "Code") to 1166 // unconditionally include in API requests. By default, fields with 1167 // empty values are omitted from API requests. However, any non-pointer, 1168 // non-interface field appearing in ForceSendFields will be sent to the 1169 // server regardless of whether the field is empty or not. This may be 1170 // used to include empty fields in Patch requests. 1171 ForceSendFields []string `json:"-"` 1172 1173 // NullFields is a list of field names (e.g. "Code") to include in API 1174 // requests with the JSON null value. By default, fields with empty 1175 // values are omitted from API requests. However, any field with an 1176 // empty value appearing in NullFields will be sent to the server as 1177 // null. It is an error if a field in this list has a non-empty value. 1178 // This may be used to include null fields in Patch requests. 1179 NullFields []string `json:"-"` 1180} 1181 1182func (s *Status) MarshalJSON() ([]byte, error) { 1183 type NoMethod Status 1184 raw := NoMethod(*s) 1185 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 1186} 1187 1188// WordInfo: Word-specific information for recognized words. 1189type WordInfo struct { 1190 // EndTime: Time offset relative to the beginning of the audio, 1191 // and corresponding to the end of the spoken word. 1192 // This field is only set if `enable_word_time_offsets=true` and only 1193 // in the top hypothesis. 1194 // This is an experimental feature and the accuracy of the time offset 1195 // can 1196 // vary. 1197 EndTime string `json:"endTime,omitempty"` 1198 1199 // SpeakerTag: Output only. A distinct integer value is assigned for 1200 // every speaker within 1201 // the audio. This field specifies which one of those speakers was 1202 // detected to 1203 // have spoken this word. Value ranges from '1' to 1204 // diarization_speaker_count. 1205 // speaker_tag is set if enable_speaker_diarization = 'true' and only in 1206 // the 1207 // top alternative. 1208 SpeakerTag int64 `json:"speakerTag,omitempty"` 1209 1210 // StartTime: Time offset relative to the beginning of the audio, 1211 // and corresponding to the start of the spoken word. 1212 // This field is only set if `enable_word_time_offsets=true` and only 1213 // in the top hypothesis. 1214 // This is an experimental feature and the accuracy of the time offset 1215 // can 1216 // vary. 1217 StartTime string `json:"startTime,omitempty"` 1218 1219 // Word: The word corresponding to this set of information. 1220 Word string `json:"word,omitempty"` 1221 1222 // ForceSendFields is a list of field names (e.g. "EndTime") to 1223 // unconditionally include in API requests. By default, fields with 1224 // empty values are omitted from API requests. However, any non-pointer, 1225 // non-interface field appearing in ForceSendFields will be sent to the 1226 // server regardless of whether the field is empty or not. This may be 1227 // used to include empty fields in Patch requests. 1228 ForceSendFields []string `json:"-"` 1229 1230 // NullFields is a list of field names (e.g. "EndTime") to include in 1231 // API requests with the JSON null value. By default, fields with empty 1232 // values are omitted from API requests. However, any field with an 1233 // empty value appearing in NullFields will be sent to the server as 1234 // null. It is an error if a field in this list has a non-empty value. 1235 // This may be used to include null fields in Patch requests. 1236 NullFields []string `json:"-"` 1237} 1238 1239func (s *WordInfo) MarshalJSON() ([]byte, error) { 1240 type NoMethod WordInfo 1241 raw := NoMethod(*s) 1242 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 1243} 1244 1245// method id "speech.operations.get": 1246 1247type OperationsGetCall struct { 1248 s *Service 1249 name string 1250 urlParams_ gensupport.URLParams 1251 ifNoneMatch_ string 1252 ctx_ context.Context 1253 header_ http.Header 1254} 1255 1256// Get: Gets the latest state of a long-running operation. Clients can 1257// use this 1258// method to poll the operation result at intervals as recommended by 1259// the API 1260// service. 1261func (r *OperationsService) Get(name string) *OperationsGetCall { 1262 c := &OperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1263 c.name = name 1264 return c 1265} 1266 1267// Fields allows partial responses to be retrieved. See 1268// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1269// for more information. 1270func (c *OperationsGetCall) Fields(s ...googleapi.Field) *OperationsGetCall { 1271 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1272 return c 1273} 1274 1275// IfNoneMatch sets the optional parameter which makes the operation 1276// fail if the object's ETag matches the given value. This is useful for 1277// getting updates only after the object has changed since the last 1278// request. Use googleapi.IsNotModified to check whether the response 1279// error from Do is the result of In-None-Match. 1280func (c *OperationsGetCall) IfNoneMatch(entityTag string) *OperationsGetCall { 1281 c.ifNoneMatch_ = entityTag 1282 return c 1283} 1284 1285// Context sets the context to be used in this call's Do method. Any 1286// pending HTTP request will be aborted if the provided context is 1287// canceled. 1288func (c *OperationsGetCall) Context(ctx context.Context) *OperationsGetCall { 1289 c.ctx_ = ctx 1290 return c 1291} 1292 1293// Header returns an http.Header that can be modified by the caller to 1294// add HTTP headers to the request. 1295func (c *OperationsGetCall) Header() http.Header { 1296 if c.header_ == nil { 1297 c.header_ = make(http.Header) 1298 } 1299 return c.header_ 1300} 1301 1302func (c *OperationsGetCall) doRequest(alt string) (*http.Response, error) { 1303 reqHeaders := make(http.Header) 1304 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") 1305 for k, v := range c.header_ { 1306 reqHeaders[k] = v 1307 } 1308 reqHeaders.Set("User-Agent", c.s.userAgent()) 1309 if c.ifNoneMatch_ != "" { 1310 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1311 } 1312 var body io.Reader = nil 1313 c.urlParams_.Set("alt", alt) 1314 c.urlParams_.Set("prettyPrint", "false") 1315 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/operations/{+name}") 1316 urls += "?" + c.urlParams_.Encode() 1317 req, err := http.NewRequest("GET", urls, body) 1318 if err != nil { 1319 return nil, err 1320 } 1321 req.Header = reqHeaders 1322 googleapi.Expand(req.URL, map[string]string{ 1323 "name": c.name, 1324 }) 1325 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1326} 1327 1328// Do executes the "speech.operations.get" call. 1329// Exactly one of *Operation or error will be non-nil. Any non-2xx 1330// status code is an error. Response headers are in either 1331// *Operation.ServerResponse.Header or (if a response was returned at 1332// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 1333// to check whether the returned error was because 1334// http.StatusNotModified was returned. 1335func (c *OperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) { 1336 gensupport.SetOptions(c.urlParams_, opts...) 1337 res, err := c.doRequest("json") 1338 if res != nil && res.StatusCode == http.StatusNotModified { 1339 if res.Body != nil { 1340 res.Body.Close() 1341 } 1342 return nil, &googleapi.Error{ 1343 Code: res.StatusCode, 1344 Header: res.Header, 1345 } 1346 } 1347 if err != nil { 1348 return nil, err 1349 } 1350 defer googleapi.CloseBody(res) 1351 if err := googleapi.CheckResponse(res); err != nil { 1352 return nil, err 1353 } 1354 ret := &Operation{ 1355 ServerResponse: googleapi.ServerResponse{ 1356 Header: res.Header, 1357 HTTPStatusCode: res.StatusCode, 1358 }, 1359 } 1360 target := &ret 1361 if err := gensupport.DecodeResponse(target, res); err != nil { 1362 return nil, err 1363 } 1364 return ret, nil 1365 // { 1366 // "description": "Gets the latest state of a long-running operation. Clients can use this\nmethod to poll the operation result at intervals as recommended by the API\nservice.", 1367 // "flatPath": "v1/operations/{operationsId}", 1368 // "httpMethod": "GET", 1369 // "id": "speech.operations.get", 1370 // "parameterOrder": [ 1371 // "name" 1372 // ], 1373 // "parameters": { 1374 // "name": { 1375 // "description": "The name of the operation resource.", 1376 // "location": "path", 1377 // "pattern": "^.*$", 1378 // "required": true, 1379 // "type": "string" 1380 // } 1381 // }, 1382 // "path": "v1/operations/{+name}", 1383 // "response": { 1384 // "$ref": "Operation" 1385 // }, 1386 // "scopes": [ 1387 // "https://www.googleapis.com/auth/cloud-platform" 1388 // ] 1389 // } 1390 1391} 1392 1393// method id "speech.operations.list": 1394 1395type OperationsListCall struct { 1396 s *Service 1397 urlParams_ gensupport.URLParams 1398 ifNoneMatch_ string 1399 ctx_ context.Context 1400 header_ http.Header 1401} 1402 1403// List: Lists operations that match the specified filter in the 1404// request. If the 1405// server doesn't support this method, it returns 1406// `UNIMPLEMENTED`. 1407// 1408// NOTE: the `name` binding allows API services to override the 1409// binding 1410// to use different resource name schemes, such as `users/*/operations`. 1411// To 1412// override the binding, API services can add a binding such 1413// as 1414// "/v1/{name=users/*}/operations" to their service configuration. 1415// For backwards compatibility, the default name includes the 1416// operations 1417// collection id, however overriding users must ensure the name 1418// binding 1419// is the parent resource, without the operations collection id. 1420func (r *OperationsService) List() *OperationsListCall { 1421 c := &OperationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1422 return c 1423} 1424 1425// Filter sets the optional parameter "filter": The standard list 1426// filter. 1427func (c *OperationsListCall) Filter(filter string) *OperationsListCall { 1428 c.urlParams_.Set("filter", filter) 1429 return c 1430} 1431 1432// Name sets the optional parameter "name": The name of the operation's 1433// parent resource. 1434func (c *OperationsListCall) Name(name string) *OperationsListCall { 1435 c.urlParams_.Set("name", name) 1436 return c 1437} 1438 1439// PageSize sets the optional parameter "pageSize": The standard list 1440// page size. 1441func (c *OperationsListCall) PageSize(pageSize int64) *OperationsListCall { 1442 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) 1443 return c 1444} 1445 1446// PageToken sets the optional parameter "pageToken": The standard list 1447// page token. 1448func (c *OperationsListCall) PageToken(pageToken string) *OperationsListCall { 1449 c.urlParams_.Set("pageToken", pageToken) 1450 return c 1451} 1452 1453// Fields allows partial responses to be retrieved. See 1454// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1455// for more information. 1456func (c *OperationsListCall) Fields(s ...googleapi.Field) *OperationsListCall { 1457 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1458 return c 1459} 1460 1461// IfNoneMatch sets the optional parameter which makes the operation 1462// fail if the object's ETag matches the given value. This is useful for 1463// getting updates only after the object has changed since the last 1464// request. Use googleapi.IsNotModified to check whether the response 1465// error from Do is the result of In-None-Match. 1466func (c *OperationsListCall) IfNoneMatch(entityTag string) *OperationsListCall { 1467 c.ifNoneMatch_ = entityTag 1468 return c 1469} 1470 1471// Context sets the context to be used in this call's Do method. Any 1472// pending HTTP request will be aborted if the provided context is 1473// canceled. 1474func (c *OperationsListCall) Context(ctx context.Context) *OperationsListCall { 1475 c.ctx_ = ctx 1476 return c 1477} 1478 1479// Header returns an http.Header that can be modified by the caller to 1480// add HTTP headers to the request. 1481func (c *OperationsListCall) Header() http.Header { 1482 if c.header_ == nil { 1483 c.header_ = make(http.Header) 1484 } 1485 return c.header_ 1486} 1487 1488func (c *OperationsListCall) doRequest(alt string) (*http.Response, error) { 1489 reqHeaders := make(http.Header) 1490 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") 1491 for k, v := range c.header_ { 1492 reqHeaders[k] = v 1493 } 1494 reqHeaders.Set("User-Agent", c.s.userAgent()) 1495 if c.ifNoneMatch_ != "" { 1496 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1497 } 1498 var body io.Reader = nil 1499 c.urlParams_.Set("alt", alt) 1500 c.urlParams_.Set("prettyPrint", "false") 1501 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/operations") 1502 urls += "?" + c.urlParams_.Encode() 1503 req, err := http.NewRequest("GET", urls, body) 1504 if err != nil { 1505 return nil, err 1506 } 1507 req.Header = reqHeaders 1508 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1509} 1510 1511// Do executes the "speech.operations.list" call. 1512// Exactly one of *ListOperationsResponse or error will be non-nil. Any 1513// non-2xx status code is an error. Response headers are in either 1514// *ListOperationsResponse.ServerResponse.Header or (if a response was 1515// returned at all) in error.(*googleapi.Error).Header. Use 1516// googleapi.IsNotModified to check whether the returned error was 1517// because http.StatusNotModified was returned. 1518func (c *OperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsResponse, error) { 1519 gensupport.SetOptions(c.urlParams_, opts...) 1520 res, err := c.doRequest("json") 1521 if res != nil && res.StatusCode == http.StatusNotModified { 1522 if res.Body != nil { 1523 res.Body.Close() 1524 } 1525 return nil, &googleapi.Error{ 1526 Code: res.StatusCode, 1527 Header: res.Header, 1528 } 1529 } 1530 if err != nil { 1531 return nil, err 1532 } 1533 defer googleapi.CloseBody(res) 1534 if err := googleapi.CheckResponse(res); err != nil { 1535 return nil, err 1536 } 1537 ret := &ListOperationsResponse{ 1538 ServerResponse: googleapi.ServerResponse{ 1539 Header: res.Header, 1540 HTTPStatusCode: res.StatusCode, 1541 }, 1542 } 1543 target := &ret 1544 if err := gensupport.DecodeResponse(target, res); err != nil { 1545 return nil, err 1546 } 1547 return ret, nil 1548 // { 1549 // "description": "Lists operations that match the specified filter in the request. If the\nserver doesn't support this method, it returns `UNIMPLEMENTED`.\n\nNOTE: the `name` binding allows API services to override the binding\nto use different resource name schemes, such as `users/*/operations`. To\noverride the binding, API services can add a binding such as\n`\"/v1/{name=users/*}/operations\"` to their service configuration.\nFor backwards compatibility, the default name includes the operations\ncollection id, however overriding users must ensure the name binding\nis the parent resource, without the operations collection id.", 1550 // "flatPath": "v1/operations", 1551 // "httpMethod": "GET", 1552 // "id": "speech.operations.list", 1553 // "parameterOrder": [], 1554 // "parameters": { 1555 // "filter": { 1556 // "description": "The standard list filter.", 1557 // "location": "query", 1558 // "type": "string" 1559 // }, 1560 // "name": { 1561 // "description": "The name of the operation's parent resource.", 1562 // "location": "query", 1563 // "type": "string" 1564 // }, 1565 // "pageSize": { 1566 // "description": "The standard list page size.", 1567 // "format": "int32", 1568 // "location": "query", 1569 // "type": "integer" 1570 // }, 1571 // "pageToken": { 1572 // "description": "The standard list page token.", 1573 // "location": "query", 1574 // "type": "string" 1575 // } 1576 // }, 1577 // "path": "v1/operations", 1578 // "response": { 1579 // "$ref": "ListOperationsResponse" 1580 // }, 1581 // "scopes": [ 1582 // "https://www.googleapis.com/auth/cloud-platform" 1583 // ] 1584 // } 1585 1586} 1587 1588// Pages invokes f for each page of results. 1589// A non-nil error returned from f will halt the iteration. 1590// The provided context supersedes any context provided to the Context method. 1591func (c *OperationsListCall) Pages(ctx context.Context, f func(*ListOperationsResponse) error) error { 1592 c.ctx_ = ctx 1593 defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point 1594 for { 1595 x, err := c.Do() 1596 if err != nil { 1597 return err 1598 } 1599 if err := f(x); err != nil { 1600 return err 1601 } 1602 if x.NextPageToken == "" { 1603 return nil 1604 } 1605 c.PageToken(x.NextPageToken) 1606 } 1607} 1608 1609// method id "speech.projects.locations.operations.get": 1610 1611type ProjectsLocationsOperationsGetCall struct { 1612 s *Service 1613 name string 1614 urlParams_ gensupport.URLParams 1615 ifNoneMatch_ string 1616 ctx_ context.Context 1617 header_ http.Header 1618} 1619 1620// Get: Gets the latest state of a long-running operation. Clients can 1621// use this 1622// method to poll the operation result at intervals as recommended by 1623// the API 1624// service. 1625func (r *ProjectsLocationsOperationsService) Get(name string) *ProjectsLocationsOperationsGetCall { 1626 c := &ProjectsLocationsOperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1627 c.name = name 1628 return c 1629} 1630 1631// Fields allows partial responses to be retrieved. See 1632// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1633// for more information. 1634func (c *ProjectsLocationsOperationsGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsOperationsGetCall { 1635 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1636 return c 1637} 1638 1639// IfNoneMatch sets the optional parameter which makes the operation 1640// fail if the object's ETag matches the given value. This is useful for 1641// getting updates only after the object has changed since the last 1642// request. Use googleapi.IsNotModified to check whether the response 1643// error from Do is the result of In-None-Match. 1644func (c *ProjectsLocationsOperationsGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsOperationsGetCall { 1645 c.ifNoneMatch_ = entityTag 1646 return c 1647} 1648 1649// Context sets the context to be used in this call's Do method. Any 1650// pending HTTP request will be aborted if the provided context is 1651// canceled. 1652func (c *ProjectsLocationsOperationsGetCall) Context(ctx context.Context) *ProjectsLocationsOperationsGetCall { 1653 c.ctx_ = ctx 1654 return c 1655} 1656 1657// Header returns an http.Header that can be modified by the caller to 1658// add HTTP headers to the request. 1659func (c *ProjectsLocationsOperationsGetCall) Header() http.Header { 1660 if c.header_ == nil { 1661 c.header_ = make(http.Header) 1662 } 1663 return c.header_ 1664} 1665 1666func (c *ProjectsLocationsOperationsGetCall) doRequest(alt string) (*http.Response, error) { 1667 reqHeaders := make(http.Header) 1668 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") 1669 for k, v := range c.header_ { 1670 reqHeaders[k] = v 1671 } 1672 reqHeaders.Set("User-Agent", c.s.userAgent()) 1673 if c.ifNoneMatch_ != "" { 1674 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1675 } 1676 var body io.Reader = nil 1677 c.urlParams_.Set("alt", alt) 1678 c.urlParams_.Set("prettyPrint", "false") 1679 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") 1680 urls += "?" + c.urlParams_.Encode() 1681 req, err := http.NewRequest("GET", urls, body) 1682 if err != nil { 1683 return nil, err 1684 } 1685 req.Header = reqHeaders 1686 googleapi.Expand(req.URL, map[string]string{ 1687 "name": c.name, 1688 }) 1689 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1690} 1691 1692// Do executes the "speech.projects.locations.operations.get" call. 1693// Exactly one of *Operation or error will be non-nil. Any non-2xx 1694// status code is an error. Response headers are in either 1695// *Operation.ServerResponse.Header or (if a response was returned at 1696// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 1697// to check whether the returned error was because 1698// http.StatusNotModified was returned. 1699func (c *ProjectsLocationsOperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) { 1700 gensupport.SetOptions(c.urlParams_, opts...) 1701 res, err := c.doRequest("json") 1702 if res != nil && res.StatusCode == http.StatusNotModified { 1703 if res.Body != nil { 1704 res.Body.Close() 1705 } 1706 return nil, &googleapi.Error{ 1707 Code: res.StatusCode, 1708 Header: res.Header, 1709 } 1710 } 1711 if err != nil { 1712 return nil, err 1713 } 1714 defer googleapi.CloseBody(res) 1715 if err := googleapi.CheckResponse(res); err != nil { 1716 return nil, err 1717 } 1718 ret := &Operation{ 1719 ServerResponse: googleapi.ServerResponse{ 1720 Header: res.Header, 1721 HTTPStatusCode: res.StatusCode, 1722 }, 1723 } 1724 target := &ret 1725 if err := gensupport.DecodeResponse(target, res); err != nil { 1726 return nil, err 1727 } 1728 return ret, nil 1729 // { 1730 // "description": "Gets the latest state of a long-running operation. Clients can use this\nmethod to poll the operation result at intervals as recommended by the API\nservice.", 1731 // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/operations/{operationsId}", 1732 // "httpMethod": "GET", 1733 // "id": "speech.projects.locations.operations.get", 1734 // "parameterOrder": [ 1735 // "name" 1736 // ], 1737 // "parameters": { 1738 // "name": { 1739 // "description": "The name of the operation resource.", 1740 // "location": "path", 1741 // "pattern": "^projects/[^/]+/locations/[^/]+/operations/[^/]+$", 1742 // "required": true, 1743 // "type": "string" 1744 // } 1745 // }, 1746 // "path": "v1/{+name}", 1747 // "response": { 1748 // "$ref": "Operation" 1749 // }, 1750 // "scopes": [ 1751 // "https://www.googleapis.com/auth/cloud-platform" 1752 // ] 1753 // } 1754 1755} 1756 1757// method id "speech.projects.locations.operations.list": 1758 1759type ProjectsLocationsOperationsListCall struct { 1760 s *Service 1761 name string 1762 urlParams_ gensupport.URLParams 1763 ifNoneMatch_ string 1764 ctx_ context.Context 1765 header_ http.Header 1766} 1767 1768// List: Lists operations that match the specified filter in the 1769// request. If the 1770// server doesn't support this method, it returns 1771// `UNIMPLEMENTED`. 1772// 1773// NOTE: the `name` binding allows API services to override the 1774// binding 1775// to use different resource name schemes, such as `users/*/operations`. 1776// To 1777// override the binding, API services can add a binding such 1778// as 1779// "/v1/{name=users/*}/operations" to their service configuration. 1780// For backwards compatibility, the default name includes the 1781// operations 1782// collection id, however overriding users must ensure the name 1783// binding 1784// is the parent resource, without the operations collection id. 1785func (r *ProjectsLocationsOperationsService) List(name string) *ProjectsLocationsOperationsListCall { 1786 c := &ProjectsLocationsOperationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1787 c.name = name 1788 return c 1789} 1790 1791// Filter sets the optional parameter "filter": The standard list 1792// filter. 1793func (c *ProjectsLocationsOperationsListCall) Filter(filter string) *ProjectsLocationsOperationsListCall { 1794 c.urlParams_.Set("filter", filter) 1795 return c 1796} 1797 1798// PageSize sets the optional parameter "pageSize": The standard list 1799// page size. 1800func (c *ProjectsLocationsOperationsListCall) PageSize(pageSize int64) *ProjectsLocationsOperationsListCall { 1801 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) 1802 return c 1803} 1804 1805// PageToken sets the optional parameter "pageToken": The standard list 1806// page token. 1807func (c *ProjectsLocationsOperationsListCall) PageToken(pageToken string) *ProjectsLocationsOperationsListCall { 1808 c.urlParams_.Set("pageToken", pageToken) 1809 return c 1810} 1811 1812// Fields allows partial responses to be retrieved. See 1813// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1814// for more information. 1815func (c *ProjectsLocationsOperationsListCall) Fields(s ...googleapi.Field) *ProjectsLocationsOperationsListCall { 1816 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1817 return c 1818} 1819 1820// IfNoneMatch sets the optional parameter which makes the operation 1821// fail if the object's ETag matches the given value. This is useful for 1822// getting updates only after the object has changed since the last 1823// request. Use googleapi.IsNotModified to check whether the response 1824// error from Do is the result of In-None-Match. 1825func (c *ProjectsLocationsOperationsListCall) IfNoneMatch(entityTag string) *ProjectsLocationsOperationsListCall { 1826 c.ifNoneMatch_ = entityTag 1827 return c 1828} 1829 1830// Context sets the context to be used in this call's Do method. Any 1831// pending HTTP request will be aborted if the provided context is 1832// canceled. 1833func (c *ProjectsLocationsOperationsListCall) Context(ctx context.Context) *ProjectsLocationsOperationsListCall { 1834 c.ctx_ = ctx 1835 return c 1836} 1837 1838// Header returns an http.Header that can be modified by the caller to 1839// add HTTP headers to the request. 1840func (c *ProjectsLocationsOperationsListCall) Header() http.Header { 1841 if c.header_ == nil { 1842 c.header_ = make(http.Header) 1843 } 1844 return c.header_ 1845} 1846 1847func (c *ProjectsLocationsOperationsListCall) doRequest(alt string) (*http.Response, error) { 1848 reqHeaders := make(http.Header) 1849 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") 1850 for k, v := range c.header_ { 1851 reqHeaders[k] = v 1852 } 1853 reqHeaders.Set("User-Agent", c.s.userAgent()) 1854 if c.ifNoneMatch_ != "" { 1855 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1856 } 1857 var body io.Reader = nil 1858 c.urlParams_.Set("alt", alt) 1859 c.urlParams_.Set("prettyPrint", "false") 1860 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}/operations") 1861 urls += "?" + c.urlParams_.Encode() 1862 req, err := http.NewRequest("GET", urls, body) 1863 if err != nil { 1864 return nil, err 1865 } 1866 req.Header = reqHeaders 1867 googleapi.Expand(req.URL, map[string]string{ 1868 "name": c.name, 1869 }) 1870 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1871} 1872 1873// Do executes the "speech.projects.locations.operations.list" call. 1874// Exactly one of *ListOperationsResponse or error will be non-nil. Any 1875// non-2xx status code is an error. Response headers are in either 1876// *ListOperationsResponse.ServerResponse.Header or (if a response was 1877// returned at all) in error.(*googleapi.Error).Header. Use 1878// googleapi.IsNotModified to check whether the returned error was 1879// because http.StatusNotModified was returned. 1880func (c *ProjectsLocationsOperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsResponse, error) { 1881 gensupport.SetOptions(c.urlParams_, opts...) 1882 res, err := c.doRequest("json") 1883 if res != nil && res.StatusCode == http.StatusNotModified { 1884 if res.Body != nil { 1885 res.Body.Close() 1886 } 1887 return nil, &googleapi.Error{ 1888 Code: res.StatusCode, 1889 Header: res.Header, 1890 } 1891 } 1892 if err != nil { 1893 return nil, err 1894 } 1895 defer googleapi.CloseBody(res) 1896 if err := googleapi.CheckResponse(res); err != nil { 1897 return nil, err 1898 } 1899 ret := &ListOperationsResponse{ 1900 ServerResponse: googleapi.ServerResponse{ 1901 Header: res.Header, 1902 HTTPStatusCode: res.StatusCode, 1903 }, 1904 } 1905 target := &ret 1906 if err := gensupport.DecodeResponse(target, res); err != nil { 1907 return nil, err 1908 } 1909 return ret, nil 1910 // { 1911 // "description": "Lists operations that match the specified filter in the request. If the\nserver doesn't support this method, it returns `UNIMPLEMENTED`.\n\nNOTE: the `name` binding allows API services to override the binding\nto use different resource name schemes, such as `users/*/operations`. To\noverride the binding, API services can add a binding such as\n`\"/v1/{name=users/*}/operations\"` to their service configuration.\nFor backwards compatibility, the default name includes the operations\ncollection id, however overriding users must ensure the name binding\nis the parent resource, without the operations collection id.", 1912 // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/operations", 1913 // "httpMethod": "GET", 1914 // "id": "speech.projects.locations.operations.list", 1915 // "parameterOrder": [ 1916 // "name" 1917 // ], 1918 // "parameters": { 1919 // "filter": { 1920 // "description": "The standard list filter.", 1921 // "location": "query", 1922 // "type": "string" 1923 // }, 1924 // "name": { 1925 // "description": "The name of the operation's parent resource.", 1926 // "location": "path", 1927 // "pattern": "^projects/[^/]+/locations/[^/]+$", 1928 // "required": true, 1929 // "type": "string" 1930 // }, 1931 // "pageSize": { 1932 // "description": "The standard list page size.", 1933 // "format": "int32", 1934 // "location": "query", 1935 // "type": "integer" 1936 // }, 1937 // "pageToken": { 1938 // "description": "The standard list page token.", 1939 // "location": "query", 1940 // "type": "string" 1941 // } 1942 // }, 1943 // "path": "v1/{+name}/operations", 1944 // "response": { 1945 // "$ref": "ListOperationsResponse" 1946 // }, 1947 // "scopes": [ 1948 // "https://www.googleapis.com/auth/cloud-platform" 1949 // ] 1950 // } 1951 1952} 1953 1954// Pages invokes f for each page of results. 1955// A non-nil error returned from f will halt the iteration. 1956// The provided context supersedes any context provided to the Context method. 1957func (c *ProjectsLocationsOperationsListCall) Pages(ctx context.Context, f func(*ListOperationsResponse) error) error { 1958 c.ctx_ = ctx 1959 defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point 1960 for { 1961 x, err := c.Do() 1962 if err != nil { 1963 return err 1964 } 1965 if err := f(x); err != nil { 1966 return err 1967 } 1968 if x.NextPageToken == "" { 1969 return nil 1970 } 1971 c.PageToken(x.NextPageToken) 1972 } 1973} 1974 1975// method id "speech.speech.longrunningrecognize": 1976 1977type SpeechLongrunningrecognizeCall struct { 1978 s *Service 1979 longrunningrecognizerequest *LongRunningRecognizeRequest 1980 urlParams_ gensupport.URLParams 1981 ctx_ context.Context 1982 header_ http.Header 1983} 1984 1985// Longrunningrecognize: Performs asynchronous speech recognition: 1986// receive results via the 1987// google.longrunning.Operations interface. Returns either 1988// an 1989// `Operation.error` or an `Operation.response` which contains 1990// a `LongRunningRecognizeResponse` message. 1991// For more information on asynchronous speech recognition, see 1992// the 1993// [how-to](https://cloud.google.com/speech-to-text/docs/async-recogn 1994// ize). 1995func (r *SpeechService) Longrunningrecognize(longrunningrecognizerequest *LongRunningRecognizeRequest) *SpeechLongrunningrecognizeCall { 1996 c := &SpeechLongrunningrecognizeCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1997 c.longrunningrecognizerequest = longrunningrecognizerequest 1998 return c 1999} 2000 2001// Fields allows partial responses to be retrieved. See 2002// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 2003// for more information. 2004func (c *SpeechLongrunningrecognizeCall) Fields(s ...googleapi.Field) *SpeechLongrunningrecognizeCall { 2005 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 2006 return c 2007} 2008 2009// Context sets the context to be used in this call's Do method. Any 2010// pending HTTP request will be aborted if the provided context is 2011// canceled. 2012func (c *SpeechLongrunningrecognizeCall) Context(ctx context.Context) *SpeechLongrunningrecognizeCall { 2013 c.ctx_ = ctx 2014 return c 2015} 2016 2017// Header returns an http.Header that can be modified by the caller to 2018// add HTTP headers to the request. 2019func (c *SpeechLongrunningrecognizeCall) Header() http.Header { 2020 if c.header_ == nil { 2021 c.header_ = make(http.Header) 2022 } 2023 return c.header_ 2024} 2025 2026func (c *SpeechLongrunningrecognizeCall) doRequest(alt string) (*http.Response, error) { 2027 reqHeaders := make(http.Header) 2028 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") 2029 for k, v := range c.header_ { 2030 reqHeaders[k] = v 2031 } 2032 reqHeaders.Set("User-Agent", c.s.userAgent()) 2033 var body io.Reader = nil 2034 body, err := googleapi.WithoutDataWrapper.JSONReader(c.longrunningrecognizerequest) 2035 if err != nil { 2036 return nil, err 2037 } 2038 reqHeaders.Set("Content-Type", "application/json") 2039 c.urlParams_.Set("alt", alt) 2040 c.urlParams_.Set("prettyPrint", "false") 2041 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/speech:longrunningrecognize") 2042 urls += "?" + c.urlParams_.Encode() 2043 req, err := http.NewRequest("POST", urls, body) 2044 if err != nil { 2045 return nil, err 2046 } 2047 req.Header = reqHeaders 2048 return gensupport.SendRequest(c.ctx_, c.s.client, req) 2049} 2050 2051// Do executes the "speech.speech.longrunningrecognize" call. 2052// Exactly one of *Operation or error will be non-nil. Any non-2xx 2053// status code is an error. Response headers are in either 2054// *Operation.ServerResponse.Header or (if a response was returned at 2055// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 2056// to check whether the returned error was because 2057// http.StatusNotModified was returned. 2058func (c *SpeechLongrunningrecognizeCall) Do(opts ...googleapi.CallOption) (*Operation, error) { 2059 gensupport.SetOptions(c.urlParams_, opts...) 2060 res, err := c.doRequest("json") 2061 if res != nil && res.StatusCode == http.StatusNotModified { 2062 if res.Body != nil { 2063 res.Body.Close() 2064 } 2065 return nil, &googleapi.Error{ 2066 Code: res.StatusCode, 2067 Header: res.Header, 2068 } 2069 } 2070 if err != nil { 2071 return nil, err 2072 } 2073 defer googleapi.CloseBody(res) 2074 if err := googleapi.CheckResponse(res); err != nil { 2075 return nil, err 2076 } 2077 ret := &Operation{ 2078 ServerResponse: googleapi.ServerResponse{ 2079 Header: res.Header, 2080 HTTPStatusCode: res.StatusCode, 2081 }, 2082 } 2083 target := &ret 2084 if err := gensupport.DecodeResponse(target, res); err != nil { 2085 return nil, err 2086 } 2087 return ret, nil 2088 // { 2089 // "description": "Performs asynchronous speech recognition: receive results via the\ngoogle.longrunning.Operations interface. Returns either an\n`Operation.error` or an `Operation.response` which contains\na `LongRunningRecognizeResponse` message.\nFor more information on asynchronous speech recognition, see the\n[how-to](https://cloud.google.com/speech-to-text/docs/async-recognize).", 2090 // "flatPath": "v1/speech:longrunningrecognize", 2091 // "httpMethod": "POST", 2092 // "id": "speech.speech.longrunningrecognize", 2093 // "parameterOrder": [], 2094 // "parameters": {}, 2095 // "path": "v1/speech:longrunningrecognize", 2096 // "request": { 2097 // "$ref": "LongRunningRecognizeRequest" 2098 // }, 2099 // "response": { 2100 // "$ref": "Operation" 2101 // }, 2102 // "scopes": [ 2103 // "https://www.googleapis.com/auth/cloud-platform" 2104 // ] 2105 // } 2106 2107} 2108 2109// method id "speech.speech.recognize": 2110 2111type SpeechRecognizeCall struct { 2112 s *Service 2113 recognizerequest *RecognizeRequest 2114 urlParams_ gensupport.URLParams 2115 ctx_ context.Context 2116 header_ http.Header 2117} 2118 2119// Recognize: Performs synchronous speech recognition: receive results 2120// after all audio 2121// has been sent and processed. 2122func (r *SpeechService) Recognize(recognizerequest *RecognizeRequest) *SpeechRecognizeCall { 2123 c := &SpeechRecognizeCall{s: r.s, urlParams_: make(gensupport.URLParams)} 2124 c.recognizerequest = recognizerequest 2125 return c 2126} 2127 2128// Fields allows partial responses to be retrieved. See 2129// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 2130// for more information. 2131func (c *SpeechRecognizeCall) Fields(s ...googleapi.Field) *SpeechRecognizeCall { 2132 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 2133 return c 2134} 2135 2136// Context sets the context to be used in this call's Do method. Any 2137// pending HTTP request will be aborted if the provided context is 2138// canceled. 2139func (c *SpeechRecognizeCall) Context(ctx context.Context) *SpeechRecognizeCall { 2140 c.ctx_ = ctx 2141 return c 2142} 2143 2144// Header returns an http.Header that can be modified by the caller to 2145// add HTTP headers to the request. 2146func (c *SpeechRecognizeCall) Header() http.Header { 2147 if c.header_ == nil { 2148 c.header_ = make(http.Header) 2149 } 2150 return c.header_ 2151} 2152 2153func (c *SpeechRecognizeCall) doRequest(alt string) (*http.Response, error) { 2154 reqHeaders := make(http.Header) 2155 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200707") 2156 for k, v := range c.header_ { 2157 reqHeaders[k] = v 2158 } 2159 reqHeaders.Set("User-Agent", c.s.userAgent()) 2160 var body io.Reader = nil 2161 body, err := googleapi.WithoutDataWrapper.JSONReader(c.recognizerequest) 2162 if err != nil { 2163 return nil, err 2164 } 2165 reqHeaders.Set("Content-Type", "application/json") 2166 c.urlParams_.Set("alt", alt) 2167 c.urlParams_.Set("prettyPrint", "false") 2168 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/speech:recognize") 2169 urls += "?" + c.urlParams_.Encode() 2170 req, err := http.NewRequest("POST", urls, body) 2171 if err != nil { 2172 return nil, err 2173 } 2174 req.Header = reqHeaders 2175 return gensupport.SendRequest(c.ctx_, c.s.client, req) 2176} 2177 2178// Do executes the "speech.speech.recognize" call. 2179// Exactly one of *RecognizeResponse or error will be non-nil. Any 2180// non-2xx status code is an error. Response headers are in either 2181// *RecognizeResponse.ServerResponse.Header or (if a response was 2182// returned at all) in error.(*googleapi.Error).Header. Use 2183// googleapi.IsNotModified to check whether the returned error was 2184// because http.StatusNotModified was returned. 2185func (c *SpeechRecognizeCall) Do(opts ...googleapi.CallOption) (*RecognizeResponse, error) { 2186 gensupport.SetOptions(c.urlParams_, opts...) 2187 res, err := c.doRequest("json") 2188 if res != nil && res.StatusCode == http.StatusNotModified { 2189 if res.Body != nil { 2190 res.Body.Close() 2191 } 2192 return nil, &googleapi.Error{ 2193 Code: res.StatusCode, 2194 Header: res.Header, 2195 } 2196 } 2197 if err != nil { 2198 return nil, err 2199 } 2200 defer googleapi.CloseBody(res) 2201 if err := googleapi.CheckResponse(res); err != nil { 2202 return nil, err 2203 } 2204 ret := &RecognizeResponse{ 2205 ServerResponse: googleapi.ServerResponse{ 2206 Header: res.Header, 2207 HTTPStatusCode: res.StatusCode, 2208 }, 2209 } 2210 target := &ret 2211 if err := gensupport.DecodeResponse(target, res); err != nil { 2212 return nil, err 2213 } 2214 return ret, nil 2215 // { 2216 // "description": "Performs synchronous speech recognition: receive results after all audio\nhas been sent and processed.", 2217 // "flatPath": "v1/speech:recognize", 2218 // "httpMethod": "POST", 2219 // "id": "speech.speech.recognize", 2220 // "parameterOrder": [], 2221 // "parameters": {}, 2222 // "path": "v1/speech:recognize", 2223 // "request": { 2224 // "$ref": "RecognizeRequest" 2225 // }, 2226 // "response": { 2227 // "$ref": "RecognizeResponse" 2228 // }, 2229 // "scopes": [ 2230 // "https://www.googleapis.com/auth/cloud-platform" 2231 // ] 2232 // } 2233 2234} 2235