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 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/v1beta1" 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/v1beta1" 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 htransport "google.golang.org/api/transport/http" 58) 59 60// Always reference these packages, just in case the auto-generated code 61// below doesn't. 62var _ = bytes.NewBuffer 63var _ = strconv.Itoa 64var _ = fmt.Sprintf 65var _ = json.NewDecoder 66var _ = io.Copy 67var _ = url.Parse 68var _ = gensupport.MarshalJSON 69var _ = googleapi.Version 70var _ = errors.New 71var _ = strings.Replace 72var _ = context.Canceled 73 74const apiId = "speech:v1beta1" 75const apiName = "speech" 76const apiVersion = "v1beta1" 77const basePath = "https://speech.googleapis.com/" 78 79// OAuth2 scopes used by this API. 80const ( 81 // View and manage your data across Google Cloud Platform services 82 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform" 83) 84 85// NewService creates a new Service. 86func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 87 scopesOption := option.WithScopes( 88 "https://www.googleapis.com/auth/cloud-platform", 89 ) 90 // NOTE: prepend, so we don't override user-specified scopes. 91 opts = append([]option.ClientOption{scopesOption}, opts...) 92 client, endpoint, err := htransport.NewClient(ctx, opts...) 93 if err != nil { 94 return nil, err 95 } 96 s, err := New(client) 97 if err != nil { 98 return nil, err 99 } 100 if endpoint != "" { 101 s.BasePath = endpoint 102 } 103 return s, nil 104} 105 106// New creates a new Service. It uses the provided http.Client for requests. 107// 108// Deprecated: please use NewService instead. 109// To provide a custom HTTP client, use option.WithHTTPClient. 110// If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. 111func New(client *http.Client) (*Service, error) { 112 if client == nil { 113 return nil, errors.New("client is nil") 114 } 115 s := &Service{client: client, BasePath: basePath} 116 s.Operations = NewOperationsService(s) 117 s.Speech = NewSpeechService(s) 118 return s, nil 119} 120 121type Service struct { 122 client *http.Client 123 BasePath string // API endpoint base URL 124 UserAgent string // optional additional User-Agent fragment 125 126 Operations *OperationsService 127 128 Speech *SpeechService 129} 130 131func (s *Service) userAgent() string { 132 if s.UserAgent == "" { 133 return googleapi.UserAgent 134 } 135 return googleapi.UserAgent + " " + s.UserAgent 136} 137 138func NewOperationsService(s *Service) *OperationsService { 139 rs := &OperationsService{s: s} 140 return rs 141} 142 143type OperationsService struct { 144 s *Service 145} 146 147func NewSpeechService(s *Service) *SpeechService { 148 rs := &SpeechService{s: s} 149 return rs 150} 151 152type SpeechService struct { 153 s *Service 154} 155 156// AsyncRecognizeRequest: The top-level message sent by the client for 157// the `AsyncRecognize` method. 158type AsyncRecognizeRequest struct { 159 // Audio: *Required* The audio data to be recognized. 160 Audio *RecognitionAudio `json:"audio,omitempty"` 161 162 // Config: *Required* Provides information to the recognizer that 163 // specifies how to 164 // process the request. 165 Config *RecognitionConfig `json:"config,omitempty"` 166 167 // ForceSendFields is a list of field names (e.g. "Audio") to 168 // unconditionally include in API requests. By default, fields with 169 // empty values are omitted from API requests. However, any non-pointer, 170 // non-interface field appearing in ForceSendFields will be sent to the 171 // server regardless of whether the field is empty or not. This may be 172 // used to include empty fields in Patch requests. 173 ForceSendFields []string `json:"-"` 174 175 // NullFields is a list of field names (e.g. "Audio") to include in API 176 // requests with the JSON null value. By default, fields with empty 177 // values are omitted from API requests. However, any field with an 178 // empty value appearing in NullFields will be sent to the server as 179 // null. It is an error if a field in this list has a non-empty value. 180 // This may be used to include null fields in Patch requests. 181 NullFields []string `json:"-"` 182} 183 184func (s *AsyncRecognizeRequest) MarshalJSON() ([]byte, error) { 185 type NoMethod AsyncRecognizeRequest 186 raw := NoMethod(*s) 187 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 188} 189 190// ListOperationsResponse: The response message for 191// Operations.ListOperations. 192type ListOperationsResponse struct { 193 // NextPageToken: The standard List next-page token. 194 NextPageToken string `json:"nextPageToken,omitempty"` 195 196 // Operations: A list of operations that matches the specified filter in 197 // the request. 198 Operations []*Operation `json:"operations,omitempty"` 199 200 // ServerResponse contains the HTTP response code and headers from the 201 // server. 202 googleapi.ServerResponse `json:"-"` 203 204 // ForceSendFields is a list of field names (e.g. "NextPageToken") to 205 // unconditionally include in API requests. By default, fields with 206 // empty values are omitted from API requests. However, any non-pointer, 207 // non-interface field appearing in ForceSendFields will be sent to the 208 // server regardless of whether the field is empty or not. This may be 209 // used to include empty fields in Patch requests. 210 ForceSendFields []string `json:"-"` 211 212 // NullFields is a list of field names (e.g. "NextPageToken") to include 213 // in API requests with the JSON null value. By default, fields with 214 // empty values are omitted from API requests. However, any field with 215 // an empty value appearing in NullFields will be sent to the server as 216 // null. It is an error if a field in this list has a non-empty value. 217 // This may be used to include null fields in Patch requests. 218 NullFields []string `json:"-"` 219} 220 221func (s *ListOperationsResponse) MarshalJSON() ([]byte, error) { 222 type NoMethod ListOperationsResponse 223 raw := NoMethod(*s) 224 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 225} 226 227// Operation: This resource represents a long-running operation that is 228// the result of a 229// network API call. 230type Operation struct { 231 // Done: If the value is `false`, it means the operation is still in 232 // progress. 233 // If `true`, the operation is completed, and either `error` or 234 // `response` is 235 // available. 236 Done bool `json:"done,omitempty"` 237 238 // Error: The error result of the operation in case of failure or 239 // cancellation. 240 Error *Status `json:"error,omitempty"` 241 242 // Metadata: Service-specific metadata associated with the operation. 243 // It typically 244 // contains progress information and common metadata such as create 245 // time. 246 // Some services might not provide such metadata. Any method that 247 // returns a 248 // long-running operation should document the metadata type, if any. 249 Metadata googleapi.RawMessage `json:"metadata,omitempty"` 250 251 // Name: The server-assigned name, which is only unique within the same 252 // service that 253 // originally returns it. If you use the default HTTP mapping, 254 // the 255 // `name` should have the format of `operations/some/unique/name`. 256 Name string `json:"name,omitempty"` 257 258 // Response: The normal response of the operation in case of success. 259 // If the original 260 // method returns no data on success, such as `Delete`, the response 261 // is 262 // `google.protobuf.Empty`. If the original method is 263 // standard 264 // `Get`/`Create`/`Update`, the response should be the resource. For 265 // other 266 // methods, the response should have the type `XxxResponse`, where 267 // `Xxx` 268 // is the original method name. For example, if the original method 269 // name 270 // is `TakeSnapshot()`, the inferred response type 271 // is 272 // `TakeSnapshotResponse`. 273 Response googleapi.RawMessage `json:"response,omitempty"` 274 275 // ServerResponse contains the HTTP response code and headers from the 276 // server. 277 googleapi.ServerResponse `json:"-"` 278 279 // ForceSendFields is a list of field names (e.g. "Done") to 280 // unconditionally include in API requests. By default, fields with 281 // empty values are omitted from API requests. However, any non-pointer, 282 // non-interface field appearing in ForceSendFields will be sent to the 283 // server regardless of whether the field is empty or not. This may be 284 // used to include empty fields in Patch requests. 285 ForceSendFields []string `json:"-"` 286 287 // NullFields is a list of field names (e.g. "Done") to include in API 288 // requests with the JSON null value. By default, fields with empty 289 // values are omitted from API requests. However, any field with an 290 // empty value appearing in NullFields will be sent to the server as 291 // null. It is an error if a field in this list has a non-empty value. 292 // This may be used to include null fields in Patch requests. 293 NullFields []string `json:"-"` 294} 295 296func (s *Operation) MarshalJSON() ([]byte, error) { 297 type NoMethod Operation 298 raw := NoMethod(*s) 299 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 300} 301 302// RecognitionAudio: Contains audio data in the encoding specified in 303// the `RecognitionConfig`. 304// Either `content` or `uri` must be supplied. Supplying both or 305// neither 306// returns google.rpc.Code.INVALID_ARGUMENT. See 307// [audio limits](https://cloud.google.com/speech/limits#content). 308type RecognitionAudio struct { 309 // Content: The audio data bytes encoded as specified 310 // in 311 // `RecognitionConfig`. Note: as with all bytes fields, protobuffers use 312 // a 313 // pure binary representation, whereas JSON representations use base64. 314 Content string `json:"content,omitempty"` 315 316 // Uri: URI that points to a file that contains audio data bytes as 317 // specified in 318 // `RecognitionConfig`. Currently, only Google Cloud Storage URIs 319 // are 320 // supported, which must be specified in the following 321 // format: 322 // `gs://bucket_name/object_name` (other URI formats 323 // return 324 // google.rpc.Code.INVALID_ARGUMENT). For more information, see 325 // [Request URIs](https://cloud.google.com/storage/docs/reference-uris). 326 Uri string `json:"uri,omitempty"` 327 328 // ForceSendFields is a list of field names (e.g. "Content") to 329 // unconditionally include in API requests. By default, fields with 330 // empty values are omitted from API requests. However, any non-pointer, 331 // non-interface field appearing in ForceSendFields will be sent to the 332 // server regardless of whether the field is empty or not. This may be 333 // used to include empty fields in Patch requests. 334 ForceSendFields []string `json:"-"` 335 336 // NullFields is a list of field names (e.g. "Content") to include in 337 // API requests with the JSON null value. By default, fields with empty 338 // values are omitted from API requests. However, any field with an 339 // empty value appearing in NullFields will be sent to the server as 340 // null. It is an error if a field in this list has a non-empty value. 341 // This may be used to include null fields in Patch requests. 342 NullFields []string `json:"-"` 343} 344 345func (s *RecognitionAudio) MarshalJSON() ([]byte, error) { 346 type NoMethod RecognitionAudio 347 raw := NoMethod(*s) 348 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 349} 350 351// RecognitionConfig: Provides information to the recognizer that 352// specifies how to process the 353// request. 354type RecognitionConfig struct { 355 // Encoding: *Required* Encoding of audio data sent in all 356 // `RecognitionAudio` messages. 357 // 358 // Possible values: 359 // "ENCODING_UNSPECIFIED" - Not specified. Will return result 360 // google.rpc.Code.INVALID_ARGUMENT. 361 // "LINEAR16" - Uncompressed 16-bit signed little-endian samples 362 // (Linear PCM). 363 // This is the only encoding that may be used by `AsyncRecognize`. 364 // "FLAC" - This is the recommended encoding for `SyncRecognize` 365 // and 366 // `StreamingRecognize` because it uses lossless compression; 367 // therefore 368 // recognition accuracy is not compromised by a lossy codec. 369 // 370 // The stream FLAC (Free Lossless Audio Codec) encoding is specified 371 // at: 372 // http://flac.sourceforge.net/documentation.html. 373 // 16-bit and 24-bit samples are supported. 374 // Not all fields in STREAMINFO are supported. 375 // "MULAW" - 8-bit samples that compand 14-bit audio samples using 376 // G.711 PCMU/mu-law. 377 // "AMR" - Adaptive Multi-Rate Narrowband codec. `sample_rate` must be 378 // 8000 Hz. 379 // "AMR_WB" - Adaptive Multi-Rate Wideband codec. `sample_rate` must 380 // be 16000 Hz. 381 Encoding string `json:"encoding,omitempty"` 382 383 // LanguageCode: *Optional* The language of the supplied audio as a 384 // BCP-47 language tag. 385 // Example: "en-GB" https://www.rfc-editor.org/rfc/bcp/bcp47.txt 386 // If omitted, defaults to "en-US". See 387 // [Language 388 // Support](https://cloud.google.com/speech/docs/languages) 389 // for a list of the currently supported language codes. 390 LanguageCode string `json:"languageCode,omitempty"` 391 392 // MaxAlternatives: *Optional* Maximum number of recognition hypotheses 393 // to be returned. 394 // Specifically, the maximum number of `SpeechRecognitionAlternative` 395 // messages 396 // within each `SpeechRecognitionResult`. 397 // The server may return fewer than `max_alternatives`. 398 // Valid values are `0`-`30`. A value of `0` or `1` will return a 399 // maximum of 400 // one. If omitted, will return a maximum of one. 401 MaxAlternatives int64 `json:"maxAlternatives,omitempty"` 402 403 // ProfanityFilter: *Optional* If set to `true`, the server will attempt 404 // to filter out 405 // profanities, replacing all but the initial character in each filtered 406 // word 407 // with asterisks, e.g. "f***". If set to `false` or omitted, 408 // profanities 409 // won't be filtered out. 410 ProfanityFilter bool `json:"profanityFilter,omitempty"` 411 412 // SampleRate: *Required* Sample rate in Hertz of the audio data sent in 413 // all 414 // `RecognitionAudio` messages. Valid values are: 8000-48000. 415 // 16000 is optimal. For best results, set the sampling rate of the 416 // audio 417 // source to 16000 Hz. If that's not possible, use the native sample 418 // rate of 419 // the audio source (instead of re-sampling). 420 SampleRate int64 `json:"sampleRate,omitempty"` 421 422 // SpeechContext: *Optional* A means to provide context to assist the 423 // speech recognition. 424 SpeechContext *SpeechContext `json:"speechContext,omitempty"` 425 426 // ForceSendFields is a list of field names (e.g. "Encoding") to 427 // unconditionally include in API requests. By default, fields with 428 // empty values are omitted from API requests. However, any non-pointer, 429 // non-interface field appearing in ForceSendFields will be sent to the 430 // server regardless of whether the field is empty or not. This may be 431 // used to include empty fields in Patch requests. 432 ForceSendFields []string `json:"-"` 433 434 // NullFields is a list of field names (e.g. "Encoding") to include in 435 // API requests with the JSON null value. By default, fields with empty 436 // values are omitted from API requests. However, any field with an 437 // empty value appearing in NullFields will be sent to the server as 438 // null. It is an error if a field in this list has a non-empty value. 439 // This may be used to include null fields in Patch requests. 440 NullFields []string `json:"-"` 441} 442 443func (s *RecognitionConfig) MarshalJSON() ([]byte, error) { 444 type NoMethod RecognitionConfig 445 raw := NoMethod(*s) 446 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 447} 448 449// SpeechContext: Provides "hints" to the speech recognizer to favor 450// specific words and phrases 451// in the results. 452type SpeechContext struct { 453 // Phrases: *Optional* A list of strings containing words and phrases 454 // "hints" so that 455 // the speech recognition is more likely to recognize them. This can be 456 // used 457 // to improve the accuracy for specific words and phrases, for example, 458 // if 459 // specific commands are typically spoken by the user. This can also be 460 // used 461 // to add additional words to the vocabulary of the recognizer. 462 // See 463 // [usage limits](https://cloud.google.com/speech/limits#content). 464 Phrases []string `json:"phrases,omitempty"` 465 466 // ForceSendFields is a list of field names (e.g. "Phrases") to 467 // unconditionally include in API requests. By default, fields with 468 // empty values are omitted from API requests. However, any non-pointer, 469 // non-interface field appearing in ForceSendFields will be sent to the 470 // server regardless of whether the field is empty or not. This may be 471 // used to include empty fields in Patch requests. 472 ForceSendFields []string `json:"-"` 473 474 // NullFields is a list of field names (e.g. "Phrases") to include in 475 // API requests with the JSON null value. By default, fields with empty 476 // values are omitted from API requests. However, any field with an 477 // empty value appearing in NullFields will be sent to the server as 478 // null. It is an error if a field in this list has a non-empty value. 479 // This may be used to include null fields in Patch requests. 480 NullFields []string `json:"-"` 481} 482 483func (s *SpeechContext) MarshalJSON() ([]byte, error) { 484 type NoMethod SpeechContext 485 raw := NoMethod(*s) 486 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 487} 488 489// SpeechRecognitionAlternative: Alternative hypotheses (a.k.a. n-best 490// list). 491type SpeechRecognitionAlternative struct { 492 // Confidence: *Output-only* The confidence estimate between 0.0 and 493 // 1.0. A higher number 494 // indicates an estimated greater likelihood that the recognized words 495 // are 496 // correct. This field is typically provided only for the top 497 // hypothesis, and 498 // only for `is_final=true` results. Clients should not rely on 499 // the 500 // `confidence` field as it is not guaranteed to be accurate, or even 501 // set, in 502 // any of the results. 503 // The default of 0.0 is a sentinel value indicating `confidence` was 504 // not set. 505 Confidence float64 `json:"confidence,omitempty"` 506 507 // Transcript: *Output-only* Transcript text representing the words that 508 // the user spoke. 509 Transcript string `json:"transcript,omitempty"` 510 511 // ForceSendFields is a list of field names (e.g. "Confidence") to 512 // unconditionally include in API requests. By default, fields with 513 // empty values are omitted from API requests. However, any non-pointer, 514 // non-interface field appearing in ForceSendFields will be sent to the 515 // server regardless of whether the field is empty or not. This may be 516 // used to include empty fields in Patch requests. 517 ForceSendFields []string `json:"-"` 518 519 // NullFields is a list of field names (e.g. "Confidence") to include in 520 // API requests with the JSON null value. By default, fields with empty 521 // values are omitted from API requests. However, any field with an 522 // empty value appearing in NullFields will be sent to the server as 523 // null. It is an error if a field in this list has a non-empty value. 524 // This may be used to include null fields in Patch requests. 525 NullFields []string `json:"-"` 526} 527 528func (s *SpeechRecognitionAlternative) MarshalJSON() ([]byte, error) { 529 type NoMethod SpeechRecognitionAlternative 530 raw := NoMethod(*s) 531 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 532} 533 534func (s *SpeechRecognitionAlternative) UnmarshalJSON(data []byte) error { 535 type NoMethod SpeechRecognitionAlternative 536 var s1 struct { 537 Confidence gensupport.JSONFloat64 `json:"confidence"` 538 *NoMethod 539 } 540 s1.NoMethod = (*NoMethod)(s) 541 if err := json.Unmarshal(data, &s1); err != nil { 542 return err 543 } 544 s.Confidence = float64(s1.Confidence) 545 return nil 546} 547 548// SpeechRecognitionResult: A speech recognition result corresponding to 549// a portion of the audio. 550type SpeechRecognitionResult struct { 551 // Alternatives: *Output-only* May contain one or more recognition 552 // hypotheses (up to the 553 // maximum specified in `max_alternatives`). 554 Alternatives []*SpeechRecognitionAlternative `json:"alternatives,omitempty"` 555 556 // ForceSendFields is a list of field names (e.g. "Alternatives") to 557 // unconditionally include in API requests. By default, fields with 558 // empty values are omitted from API requests. However, any non-pointer, 559 // non-interface field appearing in ForceSendFields will be sent to the 560 // server regardless of whether the field is empty or not. This may be 561 // used to include empty fields in Patch requests. 562 ForceSendFields []string `json:"-"` 563 564 // NullFields is a list of field names (e.g. "Alternatives") to include 565 // in API requests with the JSON null value. By default, fields with 566 // empty values are omitted from API requests. However, any field with 567 // an empty value appearing in NullFields will be sent to the server as 568 // null. It is an error if a field in this list has a non-empty value. 569 // This may be used to include null fields in Patch requests. 570 NullFields []string `json:"-"` 571} 572 573func (s *SpeechRecognitionResult) MarshalJSON() ([]byte, error) { 574 type NoMethod SpeechRecognitionResult 575 raw := NoMethod(*s) 576 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 577} 578 579// Status: The `Status` type defines a logical error model that is 580// suitable for different 581// programming environments, including REST APIs and RPC APIs. It is 582// used by 583// [gRPC](https://github.com/grpc). The error model is designed to 584// be: 585// 586// - Simple to use and understand for most users 587// - Flexible enough to meet unexpected needs 588// 589// # Overview 590// 591// The `Status` message contains three pieces of data: error code, error 592// message, 593// and error details. The error code should be an enum value 594// of 595// google.rpc.Code, but it may accept additional error codes if needed. 596// The 597// error message should be a developer-facing English message that 598// helps 599// developers *understand* and *resolve* the error. If a localized 600// user-facing 601// error message is needed, put the localized message in the error 602// details or 603// localize it in the client. The optional error details may contain 604// arbitrary 605// information about the error. There is a predefined set of error 606// detail types 607// in the package `google.rpc` that can be used for common error 608// conditions. 609// 610// # Language mapping 611// 612// The `Status` message is the logical representation of the error 613// model, but it 614// is not necessarily the actual wire format. When the `Status` message 615// is 616// exposed in different client libraries and different wire protocols, 617// it can be 618// mapped differently. For example, it will likely be mapped to some 619// exceptions 620// in Java, but more likely mapped to some error codes in C. 621// 622// # Other uses 623// 624// The error model and the `Status` message can be used in a variety 625// of 626// environments, either with or without APIs, to provide a 627// consistent developer experience across different 628// environments. 629// 630// Example uses of this error model include: 631// 632// - Partial errors. If a service needs to return partial errors to the 633// client, 634// it may embed the `Status` in the normal response to indicate the 635// partial 636// errors. 637// 638// - Workflow errors. A typical workflow has multiple steps. Each step 639// may 640// have a `Status` message for error reporting. 641// 642// - Batch operations. If a client uses batch request and batch 643// response, the 644// `Status` message should be used directly inside batch response, 645// one for 646// each error sub-response. 647// 648// - Asynchronous operations. If an API call embeds asynchronous 649// operation 650// results in its response, the status of those operations should 651// be 652// represented directly using the `Status` message. 653// 654// - Logging. If some API errors are stored in logs, the message 655// `Status` could 656// be used directly after any stripping needed for security/privacy 657// reasons. 658type Status struct { 659 // Code: The status code, which should be an enum value of 660 // google.rpc.Code. 661 Code int64 `json:"code,omitempty"` 662 663 // Details: A list of messages that carry the error details. There is a 664 // common set of 665 // message types for APIs to use. 666 Details []googleapi.RawMessage `json:"details,omitempty"` 667 668 // Message: A developer-facing error message, which should be in 669 // English. Any 670 // user-facing error message should be localized and sent in 671 // the 672 // google.rpc.Status.details field, or localized by the client. 673 Message string `json:"message,omitempty"` 674 675 // ForceSendFields is a list of field names (e.g. "Code") to 676 // unconditionally include in API requests. By default, fields with 677 // empty values are omitted from API requests. However, any non-pointer, 678 // non-interface field appearing in ForceSendFields will be sent to the 679 // server regardless of whether the field is empty or not. This may be 680 // used to include empty fields in Patch requests. 681 ForceSendFields []string `json:"-"` 682 683 // NullFields is a list of field names (e.g. "Code") to include in API 684 // requests with the JSON null value. By default, fields with empty 685 // values are omitted from API requests. However, any field with an 686 // empty value appearing in NullFields will be sent to the server as 687 // null. It is an error if a field in this list has a non-empty value. 688 // This may be used to include null fields in Patch requests. 689 NullFields []string `json:"-"` 690} 691 692func (s *Status) MarshalJSON() ([]byte, error) { 693 type NoMethod Status 694 raw := NoMethod(*s) 695 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 696} 697 698// SyncRecognizeRequest: The top-level message sent by the client for 699// the `SyncRecognize` method. 700type SyncRecognizeRequest struct { 701 // Audio: *Required* The audio data to be recognized. 702 Audio *RecognitionAudio `json:"audio,omitempty"` 703 704 // Config: *Required* Provides information to the recognizer that 705 // specifies how to 706 // process the request. 707 Config *RecognitionConfig `json:"config,omitempty"` 708 709 // ForceSendFields is a list of field names (e.g. "Audio") to 710 // unconditionally include in API requests. By default, fields with 711 // empty values are omitted from API requests. However, any non-pointer, 712 // non-interface field appearing in ForceSendFields will be sent to the 713 // server regardless of whether the field is empty or not. This may be 714 // used to include empty fields in Patch requests. 715 ForceSendFields []string `json:"-"` 716 717 // NullFields is a list of field names (e.g. "Audio") to include in API 718 // requests with the JSON null value. By default, fields with empty 719 // values are omitted from API requests. However, any field with an 720 // empty value appearing in NullFields will be sent to the server as 721 // null. It is an error if a field in this list has a non-empty value. 722 // This may be used to include null fields in Patch requests. 723 NullFields []string `json:"-"` 724} 725 726func (s *SyncRecognizeRequest) MarshalJSON() ([]byte, error) { 727 type NoMethod SyncRecognizeRequest 728 raw := NoMethod(*s) 729 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 730} 731 732// SyncRecognizeResponse: The only message returned to the client by 733// `SyncRecognize`. method. It 734// contains the result as zero or more sequential 735// `SpeechRecognitionResult` 736// messages. 737type SyncRecognizeResponse struct { 738 // Results: *Output-only* Sequential list of transcription results 739 // corresponding to 740 // sequential portions of audio. 741 Results []*SpeechRecognitionResult `json:"results,omitempty"` 742 743 // ServerResponse contains the HTTP response code and headers from the 744 // server. 745 googleapi.ServerResponse `json:"-"` 746 747 // ForceSendFields is a list of field names (e.g. "Results") to 748 // unconditionally include in API requests. By default, fields with 749 // empty values are omitted from API requests. However, any non-pointer, 750 // non-interface field appearing in ForceSendFields will be sent to the 751 // server regardless of whether the field is empty or not. This may be 752 // used to include empty fields in Patch requests. 753 ForceSendFields []string `json:"-"` 754 755 // NullFields is a list of field names (e.g. "Results") to include in 756 // API requests with the JSON null value. By default, fields with empty 757 // values are omitted from API requests. However, any field with an 758 // empty value appearing in NullFields will be sent to the server as 759 // null. It is an error if a field in this list has a non-empty value. 760 // This may be used to include null fields in Patch requests. 761 NullFields []string `json:"-"` 762} 763 764func (s *SyncRecognizeResponse) MarshalJSON() ([]byte, error) { 765 type NoMethod SyncRecognizeResponse 766 raw := NoMethod(*s) 767 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 768} 769 770// method id "speech.operations.get": 771 772type OperationsGetCall struct { 773 s *Service 774 name string 775 urlParams_ gensupport.URLParams 776 ifNoneMatch_ string 777 ctx_ context.Context 778 header_ http.Header 779} 780 781// Get: Gets the latest state of a long-running operation. Clients can 782// use this 783// method to poll the operation result at intervals as recommended by 784// the API 785// service. 786func (r *OperationsService) Get(name string) *OperationsGetCall { 787 c := &OperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 788 c.name = name 789 return c 790} 791 792// Fields allows partial responses to be retrieved. See 793// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 794// for more information. 795func (c *OperationsGetCall) Fields(s ...googleapi.Field) *OperationsGetCall { 796 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 797 return c 798} 799 800// IfNoneMatch sets the optional parameter which makes the operation 801// fail if the object's ETag matches the given value. This is useful for 802// getting updates only after the object has changed since the last 803// request. Use googleapi.IsNotModified to check whether the response 804// error from Do is the result of In-None-Match. 805func (c *OperationsGetCall) IfNoneMatch(entityTag string) *OperationsGetCall { 806 c.ifNoneMatch_ = entityTag 807 return c 808} 809 810// Context sets the context to be used in this call's Do method. Any 811// pending HTTP request will be aborted if the provided context is 812// canceled. 813func (c *OperationsGetCall) Context(ctx context.Context) *OperationsGetCall { 814 c.ctx_ = ctx 815 return c 816} 817 818// Header returns an http.Header that can be modified by the caller to 819// add HTTP headers to the request. 820func (c *OperationsGetCall) Header() http.Header { 821 if c.header_ == nil { 822 c.header_ = make(http.Header) 823 } 824 return c.header_ 825} 826 827func (c *OperationsGetCall) doRequest(alt string) (*http.Response, error) { 828 reqHeaders := make(http.Header) 829 reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203") 830 for k, v := range c.header_ { 831 reqHeaders[k] = v 832 } 833 reqHeaders.Set("User-Agent", c.s.userAgent()) 834 if c.ifNoneMatch_ != "" { 835 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 836 } 837 var body io.Reader = nil 838 c.urlParams_.Set("alt", alt) 839 c.urlParams_.Set("prettyPrint", "false") 840 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/operations/{+name}") 841 urls += "?" + c.urlParams_.Encode() 842 req, err := http.NewRequest("GET", urls, body) 843 if err != nil { 844 return nil, err 845 } 846 req.Header = reqHeaders 847 googleapi.Expand(req.URL, map[string]string{ 848 "name": c.name, 849 }) 850 return gensupport.SendRequest(c.ctx_, c.s.client, req) 851} 852 853// Do executes the "speech.operations.get" call. 854// Exactly one of *Operation or error will be non-nil. Any non-2xx 855// status code is an error. Response headers are in either 856// *Operation.ServerResponse.Header or (if a response was returned at 857// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 858// to check whether the returned error was because 859// http.StatusNotModified was returned. 860func (c *OperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) { 861 gensupport.SetOptions(c.urlParams_, opts...) 862 res, err := c.doRequest("json") 863 if res != nil && res.StatusCode == http.StatusNotModified { 864 if res.Body != nil { 865 res.Body.Close() 866 } 867 return nil, &googleapi.Error{ 868 Code: res.StatusCode, 869 Header: res.Header, 870 } 871 } 872 if err != nil { 873 return nil, err 874 } 875 defer googleapi.CloseBody(res) 876 if err := googleapi.CheckResponse(res); err != nil { 877 return nil, err 878 } 879 ret := &Operation{ 880 ServerResponse: googleapi.ServerResponse{ 881 Header: res.Header, 882 HTTPStatusCode: res.StatusCode, 883 }, 884 } 885 target := &ret 886 if err := gensupport.DecodeResponse(target, res); err != nil { 887 return nil, err 888 } 889 return ret, nil 890 // { 891 // "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.", 892 // "flatPath": "v1beta1/operations/{operationsId}", 893 // "httpMethod": "GET", 894 // "id": "speech.operations.get", 895 // "parameterOrder": [ 896 // "name" 897 // ], 898 // "parameters": { 899 // "name": { 900 // "description": "The name of the operation resource.", 901 // "location": "path", 902 // "pattern": "^[^/]+$", 903 // "required": true, 904 // "type": "string" 905 // } 906 // }, 907 // "path": "v1beta1/operations/{+name}", 908 // "response": { 909 // "$ref": "Operation" 910 // }, 911 // "scopes": [ 912 // "https://www.googleapis.com/auth/cloud-platform" 913 // ] 914 // } 915 916} 917 918// method id "speech.operations.list": 919 920type OperationsListCall struct { 921 s *Service 922 urlParams_ gensupport.URLParams 923 ifNoneMatch_ string 924 ctx_ context.Context 925 header_ http.Header 926} 927 928// List: Lists operations that match the specified filter in the 929// request. If the 930// server doesn't support this method, it returns 931// `UNIMPLEMENTED`. 932// 933// NOTE: the `name` binding allows API services to override the 934// binding 935// to use different resource name schemes, such as `users/*/operations`. 936// To 937// override the binding, API services can add a binding such 938// as 939// "/v1/{name=users/*}/operations" to their service configuration. 940// For backwards compatibility, the default name includes the 941// operations 942// collection id, however overriding users must ensure the name 943// binding 944// is the parent resource, without the operations collection id. 945func (r *OperationsService) List() *OperationsListCall { 946 c := &OperationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)} 947 return c 948} 949 950// Filter sets the optional parameter "filter": The standard list 951// filter. 952func (c *OperationsListCall) Filter(filter string) *OperationsListCall { 953 c.urlParams_.Set("filter", filter) 954 return c 955} 956 957// Name sets the optional parameter "name": The name of the operation's 958// parent resource. 959func (c *OperationsListCall) Name(name string) *OperationsListCall { 960 c.urlParams_.Set("name", name) 961 return c 962} 963 964// PageSize sets the optional parameter "pageSize": The standard list 965// page size. 966func (c *OperationsListCall) PageSize(pageSize int64) *OperationsListCall { 967 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) 968 return c 969} 970 971// PageToken sets the optional parameter "pageToken": The standard list 972// page token. 973func (c *OperationsListCall) PageToken(pageToken string) *OperationsListCall { 974 c.urlParams_.Set("pageToken", pageToken) 975 return c 976} 977 978// Fields allows partial responses to be retrieved. See 979// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 980// for more information. 981func (c *OperationsListCall) Fields(s ...googleapi.Field) *OperationsListCall { 982 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 983 return c 984} 985 986// IfNoneMatch sets the optional parameter which makes the operation 987// fail if the object's ETag matches the given value. This is useful for 988// getting updates only after the object has changed since the last 989// request. Use googleapi.IsNotModified to check whether the response 990// error from Do is the result of In-None-Match. 991func (c *OperationsListCall) IfNoneMatch(entityTag string) *OperationsListCall { 992 c.ifNoneMatch_ = entityTag 993 return c 994} 995 996// Context sets the context to be used in this call's Do method. Any 997// pending HTTP request will be aborted if the provided context is 998// canceled. 999func (c *OperationsListCall) Context(ctx context.Context) *OperationsListCall { 1000 c.ctx_ = ctx 1001 return c 1002} 1003 1004// Header returns an http.Header that can be modified by the caller to 1005// add HTTP headers to the request. 1006func (c *OperationsListCall) Header() http.Header { 1007 if c.header_ == nil { 1008 c.header_ = make(http.Header) 1009 } 1010 return c.header_ 1011} 1012 1013func (c *OperationsListCall) doRequest(alt string) (*http.Response, error) { 1014 reqHeaders := make(http.Header) 1015 reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203") 1016 for k, v := range c.header_ { 1017 reqHeaders[k] = v 1018 } 1019 reqHeaders.Set("User-Agent", c.s.userAgent()) 1020 if c.ifNoneMatch_ != "" { 1021 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1022 } 1023 var body io.Reader = nil 1024 c.urlParams_.Set("alt", alt) 1025 c.urlParams_.Set("prettyPrint", "false") 1026 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/operations") 1027 urls += "?" + c.urlParams_.Encode() 1028 req, err := http.NewRequest("GET", urls, body) 1029 if err != nil { 1030 return nil, err 1031 } 1032 req.Header = reqHeaders 1033 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1034} 1035 1036// Do executes the "speech.operations.list" call. 1037// Exactly one of *ListOperationsResponse or error will be non-nil. Any 1038// non-2xx status code is an error. Response headers are in either 1039// *ListOperationsResponse.ServerResponse.Header or (if a response was 1040// returned at all) in error.(*googleapi.Error).Header. Use 1041// googleapi.IsNotModified to check whether the returned error was 1042// because http.StatusNotModified was returned. 1043func (c *OperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsResponse, error) { 1044 gensupport.SetOptions(c.urlParams_, opts...) 1045 res, err := c.doRequest("json") 1046 if res != nil && res.StatusCode == http.StatusNotModified { 1047 if res.Body != nil { 1048 res.Body.Close() 1049 } 1050 return nil, &googleapi.Error{ 1051 Code: res.StatusCode, 1052 Header: res.Header, 1053 } 1054 } 1055 if err != nil { 1056 return nil, err 1057 } 1058 defer googleapi.CloseBody(res) 1059 if err := googleapi.CheckResponse(res); err != nil { 1060 return nil, err 1061 } 1062 ret := &ListOperationsResponse{ 1063 ServerResponse: googleapi.ServerResponse{ 1064 Header: res.Header, 1065 HTTPStatusCode: res.StatusCode, 1066 }, 1067 } 1068 target := &ret 1069 if err := gensupport.DecodeResponse(target, res); err != nil { 1070 return nil, err 1071 } 1072 return ret, nil 1073 // { 1074 // "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.", 1075 // "flatPath": "v1beta1/operations", 1076 // "httpMethod": "GET", 1077 // "id": "speech.operations.list", 1078 // "parameterOrder": [], 1079 // "parameters": { 1080 // "filter": { 1081 // "description": "The standard list filter.", 1082 // "location": "query", 1083 // "type": "string" 1084 // }, 1085 // "name": { 1086 // "description": "The name of the operation's parent resource.", 1087 // "location": "query", 1088 // "type": "string" 1089 // }, 1090 // "pageSize": { 1091 // "description": "The standard list page size.", 1092 // "format": "int32", 1093 // "location": "query", 1094 // "type": "integer" 1095 // }, 1096 // "pageToken": { 1097 // "description": "The standard list page token.", 1098 // "location": "query", 1099 // "type": "string" 1100 // } 1101 // }, 1102 // "path": "v1beta1/operations", 1103 // "response": { 1104 // "$ref": "ListOperationsResponse" 1105 // }, 1106 // "scopes": [ 1107 // "https://www.googleapis.com/auth/cloud-platform" 1108 // ] 1109 // } 1110 1111} 1112 1113// Pages invokes f for each page of results. 1114// A non-nil error returned from f will halt the iteration. 1115// The provided context supersedes any context provided to the Context method. 1116func (c *OperationsListCall) Pages(ctx context.Context, f func(*ListOperationsResponse) error) error { 1117 c.ctx_ = ctx 1118 defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point 1119 for { 1120 x, err := c.Do() 1121 if err != nil { 1122 return err 1123 } 1124 if err := f(x); err != nil { 1125 return err 1126 } 1127 if x.NextPageToken == "" { 1128 return nil 1129 } 1130 c.PageToken(x.NextPageToken) 1131 } 1132} 1133 1134// method id "speech.speech.asyncrecognize": 1135 1136type SpeechAsyncrecognizeCall struct { 1137 s *Service 1138 asyncrecognizerequest *AsyncRecognizeRequest 1139 urlParams_ gensupport.URLParams 1140 ctx_ context.Context 1141 header_ http.Header 1142} 1143 1144// Asyncrecognize: Performs asynchronous speech recognition: receive 1145// results via 1146// the 1147// [google.longrunning.Operations] 1148// (/speech/reference/rest/v1beta1/op 1149// erations#Operation) 1150// interface. Returns either an 1151// `Operation.error` or an `Operation.response` which contains 1152// an `AsyncRecognizeResponse` message. 1153func (r *SpeechService) Asyncrecognize(asyncrecognizerequest *AsyncRecognizeRequest) *SpeechAsyncrecognizeCall { 1154 c := &SpeechAsyncrecognizeCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1155 c.asyncrecognizerequest = asyncrecognizerequest 1156 return c 1157} 1158 1159// Fields allows partial responses to be retrieved. See 1160// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1161// for more information. 1162func (c *SpeechAsyncrecognizeCall) Fields(s ...googleapi.Field) *SpeechAsyncrecognizeCall { 1163 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1164 return c 1165} 1166 1167// Context sets the context to be used in this call's Do method. Any 1168// pending HTTP request will be aborted if the provided context is 1169// canceled. 1170func (c *SpeechAsyncrecognizeCall) Context(ctx context.Context) *SpeechAsyncrecognizeCall { 1171 c.ctx_ = ctx 1172 return c 1173} 1174 1175// Header returns an http.Header that can be modified by the caller to 1176// add HTTP headers to the request. 1177func (c *SpeechAsyncrecognizeCall) Header() http.Header { 1178 if c.header_ == nil { 1179 c.header_ = make(http.Header) 1180 } 1181 return c.header_ 1182} 1183 1184func (c *SpeechAsyncrecognizeCall) doRequest(alt string) (*http.Response, error) { 1185 reqHeaders := make(http.Header) 1186 reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203") 1187 for k, v := range c.header_ { 1188 reqHeaders[k] = v 1189 } 1190 reqHeaders.Set("User-Agent", c.s.userAgent()) 1191 var body io.Reader = nil 1192 body, err := googleapi.WithoutDataWrapper.JSONReader(c.asyncrecognizerequest) 1193 if err != nil { 1194 return nil, err 1195 } 1196 reqHeaders.Set("Content-Type", "application/json") 1197 c.urlParams_.Set("alt", alt) 1198 c.urlParams_.Set("prettyPrint", "false") 1199 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/speech:asyncrecognize") 1200 urls += "?" + c.urlParams_.Encode() 1201 req, err := http.NewRequest("POST", urls, body) 1202 if err != nil { 1203 return nil, err 1204 } 1205 req.Header = reqHeaders 1206 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1207} 1208 1209// Do executes the "speech.speech.asyncrecognize" call. 1210// Exactly one of *Operation or error will be non-nil. Any non-2xx 1211// status code is an error. Response headers are in either 1212// *Operation.ServerResponse.Header or (if a response was returned at 1213// all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified 1214// to check whether the returned error was because 1215// http.StatusNotModified was returned. 1216func (c *SpeechAsyncrecognizeCall) Do(opts ...googleapi.CallOption) (*Operation, error) { 1217 gensupport.SetOptions(c.urlParams_, opts...) 1218 res, err := c.doRequest("json") 1219 if res != nil && res.StatusCode == http.StatusNotModified { 1220 if res.Body != nil { 1221 res.Body.Close() 1222 } 1223 return nil, &googleapi.Error{ 1224 Code: res.StatusCode, 1225 Header: res.Header, 1226 } 1227 } 1228 if err != nil { 1229 return nil, err 1230 } 1231 defer googleapi.CloseBody(res) 1232 if err := googleapi.CheckResponse(res); err != nil { 1233 return nil, err 1234 } 1235 ret := &Operation{ 1236 ServerResponse: googleapi.ServerResponse{ 1237 Header: res.Header, 1238 HTTPStatusCode: res.StatusCode, 1239 }, 1240 } 1241 target := &ret 1242 if err := gensupport.DecodeResponse(target, res); err != nil { 1243 return nil, err 1244 } 1245 return ret, nil 1246 // { 1247 // "description": "Performs asynchronous speech recognition: receive results via the\n[google.longrunning.Operations]\n(/speech/reference/rest/v1beta1/operations#Operation)\ninterface. Returns either an\n`Operation.error` or an `Operation.response` which contains\nan `AsyncRecognizeResponse` message.", 1248 // "flatPath": "v1beta1/speech:asyncrecognize", 1249 // "httpMethod": "POST", 1250 // "id": "speech.speech.asyncrecognize", 1251 // "parameterOrder": [], 1252 // "parameters": {}, 1253 // "path": "v1beta1/speech:asyncrecognize", 1254 // "request": { 1255 // "$ref": "AsyncRecognizeRequest" 1256 // }, 1257 // "response": { 1258 // "$ref": "Operation" 1259 // }, 1260 // "scopes": [ 1261 // "https://www.googleapis.com/auth/cloud-platform" 1262 // ] 1263 // } 1264 1265} 1266 1267// method id "speech.speech.syncrecognize": 1268 1269type SpeechSyncrecognizeCall struct { 1270 s *Service 1271 syncrecognizerequest *SyncRecognizeRequest 1272 urlParams_ gensupport.URLParams 1273 ctx_ context.Context 1274 header_ http.Header 1275} 1276 1277// Syncrecognize: Performs synchronous speech recognition: receive 1278// results after all audio 1279// has been sent and processed. 1280func (r *SpeechService) Syncrecognize(syncrecognizerequest *SyncRecognizeRequest) *SpeechSyncrecognizeCall { 1281 c := &SpeechSyncrecognizeCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1282 c.syncrecognizerequest = syncrecognizerequest 1283 return c 1284} 1285 1286// Fields allows partial responses to be retrieved. See 1287// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1288// for more information. 1289func (c *SpeechSyncrecognizeCall) Fields(s ...googleapi.Field) *SpeechSyncrecognizeCall { 1290 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1291 return c 1292} 1293 1294// Context sets the context to be used in this call's Do method. Any 1295// pending HTTP request will be aborted if the provided context is 1296// canceled. 1297func (c *SpeechSyncrecognizeCall) Context(ctx context.Context) *SpeechSyncrecognizeCall { 1298 c.ctx_ = ctx 1299 return c 1300} 1301 1302// Header returns an http.Header that can be modified by the caller to 1303// add HTTP headers to the request. 1304func (c *SpeechSyncrecognizeCall) Header() http.Header { 1305 if c.header_ == nil { 1306 c.header_ = make(http.Header) 1307 } 1308 return c.header_ 1309} 1310 1311func (c *SpeechSyncrecognizeCall) doRequest(alt string) (*http.Response, error) { 1312 reqHeaders := make(http.Header) 1313 reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203") 1314 for k, v := range c.header_ { 1315 reqHeaders[k] = v 1316 } 1317 reqHeaders.Set("User-Agent", c.s.userAgent()) 1318 var body io.Reader = nil 1319 body, err := googleapi.WithoutDataWrapper.JSONReader(c.syncrecognizerequest) 1320 if err != nil { 1321 return nil, err 1322 } 1323 reqHeaders.Set("Content-Type", "application/json") 1324 c.urlParams_.Set("alt", alt) 1325 c.urlParams_.Set("prettyPrint", "false") 1326 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/speech:syncrecognize") 1327 urls += "?" + c.urlParams_.Encode() 1328 req, err := http.NewRequest("POST", urls, body) 1329 if err != nil { 1330 return nil, err 1331 } 1332 req.Header = reqHeaders 1333 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1334} 1335 1336// Do executes the "speech.speech.syncrecognize" call. 1337// Exactly one of *SyncRecognizeResponse or error will be non-nil. Any 1338// non-2xx status code is an error. Response headers are in either 1339// *SyncRecognizeResponse.ServerResponse.Header or (if a response was 1340// returned at all) in error.(*googleapi.Error).Header. Use 1341// googleapi.IsNotModified to check whether the returned error was 1342// because http.StatusNotModified was returned. 1343func (c *SpeechSyncrecognizeCall) Do(opts ...googleapi.CallOption) (*SyncRecognizeResponse, error) { 1344 gensupport.SetOptions(c.urlParams_, opts...) 1345 res, err := c.doRequest("json") 1346 if res != nil && res.StatusCode == http.StatusNotModified { 1347 if res.Body != nil { 1348 res.Body.Close() 1349 } 1350 return nil, &googleapi.Error{ 1351 Code: res.StatusCode, 1352 Header: res.Header, 1353 } 1354 } 1355 if err != nil { 1356 return nil, err 1357 } 1358 defer googleapi.CloseBody(res) 1359 if err := googleapi.CheckResponse(res); err != nil { 1360 return nil, err 1361 } 1362 ret := &SyncRecognizeResponse{ 1363 ServerResponse: googleapi.ServerResponse{ 1364 Header: res.Header, 1365 HTTPStatusCode: res.StatusCode, 1366 }, 1367 } 1368 target := &ret 1369 if err := gensupport.DecodeResponse(target, res); err != nil { 1370 return nil, err 1371 } 1372 return ret, nil 1373 // { 1374 // "description": "Performs synchronous speech recognition: receive results after all audio\nhas been sent and processed.", 1375 // "flatPath": "v1beta1/speech:syncrecognize", 1376 // "httpMethod": "POST", 1377 // "id": "speech.speech.syncrecognize", 1378 // "parameterOrder": [], 1379 // "parameters": {}, 1380 // "path": "v1beta1/speech:syncrecognize", 1381 // "request": { 1382 // "$ref": "SyncRecognizeRequest" 1383 // }, 1384 // "response": { 1385 // "$ref": "SyncRecognizeResponse" 1386 // }, 1387 // "scopes": [ 1388 // "https://www.googleapis.com/auth/cloud-platform" 1389 // ] 1390 // } 1391 1392} 1393