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