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