1 // Copyright 2024 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 // # Library status 14 // 15 // These client libraries are officially supported by Google. However, this 16 // library is considered complete and is in maintenance mode. This means 17 // that we will address critical bugs and security issues but will not add 18 // any new features. 19 // 20 // When possible, we recommend using our newer 21 // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go) 22 // that are still actively being worked and iterated on. 23 // 24 // # Creating a client 25 // 26 // Usage example: 27 // 28 // import "google.golang.org/api/speech/v1p1beta1" 29 // ... 30 // ctx := context.Background() 31 // speechService, err := speech.NewService(ctx) 32 // 33 // In this example, Google Application Default Credentials are used for 34 // authentication. For information on how to create and obtain Application 35 // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials. 36 // 37 // # Other authentication options 38 // 39 // To use an API key for authentication (note: some APIs do not support API 40 // keys), use [google.golang.org/api/option.WithAPIKey]: 41 // 42 // speechService, err := speech.NewService(ctx, option.WithAPIKey("AIza...")) 43 // 44 // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth 45 // flow, use [google.golang.org/api/option.WithTokenSource]: 46 // 47 // config := &oauth2.Config{...} 48 // // ... 49 // token, err := config.Exchange(ctx, ...) 50 // speechService, err := speech.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) 51 // 52 // See [google.golang.org/api/option.ClientOption] for details on options. 53 package speech // import "google.golang.org/api/speech/v1p1beta1" 54 55 import ( 56 "bytes" 57 "context" 58 "encoding/json" 59 "errors" 60 "fmt" 61 "io" 62 "net/http" 63 "net/url" 64 "strconv" 65 "strings" 66 67 googleapi "google.golang.org/api/googleapi" 68 internal "google.golang.org/api/internal" 69 gensupport "google.golang.org/api/internal/gensupport" 70 option "google.golang.org/api/option" 71 internaloption "google.golang.org/api/option/internaloption" 72 htransport "google.golang.org/api/transport/http" 73 ) 74 75 // Always reference these packages, just in case the auto-generated code 76 // below doesn't. 77 var _ = bytes.NewBuffer 78 var _ = strconv.Itoa 79 var _ = fmt.Sprintf 80 var _ = json.NewDecoder 81 var _ = io.Copy 82 var _ = url.Parse 83 var _ = gensupport.MarshalJSON 84 var _ = googleapi.Version 85 var _ = errors.New 86 var _ = strings.Replace 87 var _ = context.Canceled 88 var _ = internaloption.WithDefaultEndpoint 89 var _ = internal.Version 90 91 const apiId = "speech:v1p1beta1" 92 const apiName = "speech" 93 const apiVersion = "v1p1beta1" 94 const basePath = "https://speech.googleapis.com/" 95 const basePathTemplate = "https://speech.UNIVERSE_DOMAIN/" 96 const mtlsBasePath = "https://speech.mtls.googleapis.com/" 97 98 // OAuth2 scopes used by this API. 99 const ( 100 // See, edit, configure, and delete your Google Cloud data and see the email 101 // address for your Google Account. 102 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform" 103 ) 104 105 // NewService creates a new Service. 106 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 107 scopesOption := internaloption.WithDefaultScopes( 108 "https://www.googleapis.com/auth/cloud-platform", 109 ) 110 // NOTE: prepend, so we don't override user-specified scopes. 111 opts = append([]option.ClientOption{scopesOption}, opts...) 112 opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) 113 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) 114 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) 115 opts = append(opts, internaloption.EnableNewAuthLibrary()) 116 client, endpoint, err := htransport.NewClient(ctx, opts...) 117 if err != nil { 118 return nil, err 119 } 120 s, err := New(client) 121 if err != nil { 122 return nil, err 123 } 124 if endpoint != "" { 125 s.BasePath = endpoint 126 } 127 return s, nil 128 } 129 130 // New creates a new Service. It uses the provided http.Client for requests. 131 // 132 // Deprecated: please use NewService instead. 133 // To provide a custom HTTP client, use option.WithHTTPClient. 134 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. 135 func New(client *http.Client) (*Service, error) { 136 if client == nil { 137 return nil, errors.New("client is nil") 138 } 139 s := &Service{client: client, BasePath: basePath} 140 s.Operations = NewOperationsService(s) 141 s.Projects = NewProjectsService(s) 142 s.Speech = NewSpeechService(s) 143 return s, nil 144 } 145 146 type Service struct { 147 client *http.Client 148 BasePath string // API endpoint base URL 149 UserAgent string // optional additional User-Agent fragment 150 151 Operations *OperationsService 152 153 Projects *ProjectsService 154 155 Speech *SpeechService 156 } 157 158 func (s *Service) userAgent() string { 159 if s.UserAgent == "" { 160 return googleapi.UserAgent 161 } 162 return googleapi.UserAgent + " " + s.UserAgent 163 } 164 165 func NewOperationsService(s *Service) *OperationsService { 166 rs := &OperationsService{s: s} 167 return rs 168 } 169 170 type OperationsService struct { 171 s *Service 172 } 173 174 func NewProjectsService(s *Service) *ProjectsService { 175 rs := &ProjectsService{s: s} 176 rs.Locations = NewProjectsLocationsService(s) 177 return rs 178 } 179 180 type ProjectsService struct { 181 s *Service 182 183 Locations *ProjectsLocationsService 184 } 185 186 func NewProjectsLocationsService(s *Service) *ProjectsLocationsService { 187 rs := &ProjectsLocationsService{s: s} 188 rs.CustomClasses = NewProjectsLocationsCustomClassesService(s) 189 rs.PhraseSets = NewProjectsLocationsPhraseSetsService(s) 190 return rs 191 } 192 193 type ProjectsLocationsService struct { 194 s *Service 195 196 CustomClasses *ProjectsLocationsCustomClassesService 197 198 PhraseSets *ProjectsLocationsPhraseSetsService 199 } 200 201 func NewProjectsLocationsCustomClassesService(s *Service) *ProjectsLocationsCustomClassesService { 202 rs := &ProjectsLocationsCustomClassesService{s: s} 203 return rs 204 } 205 206 type ProjectsLocationsCustomClassesService struct { 207 s *Service 208 } 209 210 func NewProjectsLocationsPhraseSetsService(s *Service) *ProjectsLocationsPhraseSetsService { 211 rs := &ProjectsLocationsPhraseSetsService{s: s} 212 return rs 213 } 214 215 type ProjectsLocationsPhraseSetsService struct { 216 s *Service 217 } 218 219 func NewSpeechService(s *Service) *SpeechService { 220 rs := &SpeechService{s: s} 221 return rs 222 } 223 224 type SpeechService struct { 225 s *Service 226 } 227 228 type ABNFGrammar struct { 229 // AbnfStrings: All declarations and rules of an ABNF grammar broken up into 230 // multiple strings that will end up concatenated. 231 AbnfStrings []string `json:"abnfStrings,omitempty"` 232 // ForceSendFields is a list of field names (e.g. "AbnfStrings") to 233 // unconditionally include in API requests. By default, fields with empty or 234 // default values are omitted from API requests. See 235 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 236 // details. 237 ForceSendFields []string `json:"-"` 238 // NullFields is a list of field names (e.g. "AbnfStrings") to include in API 239 // requests with the JSON null value. By default, fields with empty values are 240 // omitted from API requests. See 241 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 242 NullFields []string `json:"-"` 243 } 244 245 func (s *ABNFGrammar) MarshalJSON() ([]byte, error) { 246 type NoMethod ABNFGrammar 247 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 248 } 249 250 // ClassItem: An item of the class. 251 type ClassItem struct { 252 // Value: The class item's value. 253 Value string `json:"value,omitempty"` 254 // ForceSendFields is a list of field names (e.g. "Value") to unconditionally 255 // include in API requests. By default, fields with empty or default values are 256 // omitted from API requests. See 257 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 258 // details. 259 ForceSendFields []string `json:"-"` 260 // NullFields is a list of field names (e.g. "Value") to include in API 261 // requests with the JSON null value. By default, fields with empty values are 262 // omitted from API requests. See 263 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 264 NullFields []string `json:"-"` 265 } 266 267 func (s *ClassItem) MarshalJSON() ([]byte, error) { 268 type NoMethod ClassItem 269 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 270 } 271 272 // CreateCustomClassRequest: Message sent by the client for the 273 // `CreateCustomClass` method. 274 type CreateCustomClassRequest struct { 275 // CustomClass: Required. The custom class to create. 276 CustomClass *CustomClass `json:"customClass,omitempty"` 277 // CustomClassId: Required. The ID to use for the custom class, which will 278 // become the final component of the custom class' resource name. This value 279 // should restrict to letters, numbers, and hyphens, with the first character a 280 // letter, the last a letter or a number, and be 4-63 characters. 281 CustomClassId string `json:"customClassId,omitempty"` 282 // ForceSendFields is a list of field names (e.g. "CustomClass") to 283 // unconditionally include in API requests. By default, fields with empty or 284 // default values are omitted from API requests. See 285 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 286 // details. 287 ForceSendFields []string `json:"-"` 288 // NullFields is a list of field names (e.g. "CustomClass") to include in API 289 // requests with the JSON null value. By default, fields with empty values are 290 // omitted from API requests. See 291 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 292 NullFields []string `json:"-"` 293 } 294 295 func (s *CreateCustomClassRequest) MarshalJSON() ([]byte, error) { 296 type NoMethod CreateCustomClassRequest 297 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 298 } 299 300 // CreatePhraseSetRequest: Message sent by the client for the `CreatePhraseSet` 301 // method. 302 type CreatePhraseSetRequest struct { 303 // PhraseSet: Required. The phrase set to create. 304 PhraseSet *PhraseSet `json:"phraseSet,omitempty"` 305 // PhraseSetId: Required. The ID to use for the phrase set, which will become 306 // the final component of the phrase set's resource name. This value should 307 // restrict to letters, numbers, and hyphens, with the first character a 308 // letter, the last a letter or a number, and be 4-63 characters. 309 PhraseSetId string `json:"phraseSetId,omitempty"` 310 // ForceSendFields is a list of field names (e.g. "PhraseSet") to 311 // unconditionally include in API requests. By default, fields with empty or 312 // default values are omitted from API requests. See 313 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 314 // details. 315 ForceSendFields []string `json:"-"` 316 // NullFields is a list of field names (e.g. "PhraseSet") to include in API 317 // requests with the JSON null value. By default, fields with empty values are 318 // omitted from API requests. See 319 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 320 NullFields []string `json:"-"` 321 } 322 323 func (s *CreatePhraseSetRequest) MarshalJSON() ([]byte, error) { 324 type NoMethod CreatePhraseSetRequest 325 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 326 } 327 328 // CustomClass: A set of words or phrases that represents a common concept 329 // likely to appear in your audio, for example a list of passenger ship names. 330 // CustomClass items can be substituted into placeholders that you set in 331 // PhraseSet phrases. 332 type CustomClass struct { 333 // Annotations: Output only. Allows users to store small amounts of arbitrary 334 // data. Both the key and the value must be 63 characters or less each. At most 335 // 100 annotations. This field is not used. 336 Annotations map[string]string `json:"annotations,omitempty"` 337 // CustomClassId: If this custom class is a resource, the custom_class_id is 338 // the resource id of the CustomClass. Case sensitive. 339 CustomClassId string `json:"customClassId,omitempty"` 340 // DeleteTime: Output only. The time at which this resource was requested for 341 // deletion. This field is not used. 342 DeleteTime string `json:"deleteTime,omitempty"` 343 // DisplayName: Output only. User-settable, human-readable name for the 344 // CustomClass. Must be 63 characters or less. This field is not used. 345 DisplayName string `json:"displayName,omitempty"` 346 // Etag: Output only. This checksum is computed by the server based on the 347 // value of other fields. This may be sent on update, undelete, and delete 348 // requests to ensure the client has an up-to-date value before proceeding. 349 // This field is not used. 350 Etag string `json:"etag,omitempty"` 351 // ExpireTime: Output only. The time at which this resource will be purged. 352 // This field is not used. 353 ExpireTime string `json:"expireTime,omitempty"` 354 // Items: A collection of class items. 355 Items []*ClassItem `json:"items,omitempty"` 356 // KmsKeyName: Output only. The KMS key name 357 // (https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which the 358 // content of the ClassItem is encrypted. The expected format is 359 // `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{cryp 360 // to_key}`. 361 KmsKeyName string `json:"kmsKeyName,omitempty"` 362 // KmsKeyVersionName: Output only. The KMS key version name 363 // (https://cloud.google.com/kms/docs/resource-hierarchy#key_versions) with 364 // which content of the ClassItem is encrypted. The expected format is 365 // `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{cryp 366 // to_key}/cryptoKeyVersions/{crypto_key_version}`. 367 KmsKeyVersionName string `json:"kmsKeyVersionName,omitempty"` 368 // Name: The resource name of the custom class. 369 Name string `json:"name,omitempty"` 370 // Reconciling: Output only. Whether or not this CustomClass is in the process 371 // of being updated. This field is not used. 372 Reconciling bool `json:"reconciling,omitempty"` 373 // State: Output only. The CustomClass lifecycle state. This field is not used. 374 // 375 // Possible values: 376 // "STATE_UNSPECIFIED" - Unspecified state. This is only used/useful for 377 // distinguishing unset values. 378 // "ACTIVE" - The normal and active state. 379 // "DELETED" - This CustomClass has been deleted. 380 State string `json:"state,omitempty"` 381 // Uid: Output only. System-assigned unique identifier for the CustomClass. 382 // This field is not used. 383 Uid string `json:"uid,omitempty"` 384 385 // ServerResponse contains the HTTP response code and headers from the server. 386 googleapi.ServerResponse `json:"-"` 387 // ForceSendFields is a list of field names (e.g. "Annotations") to 388 // unconditionally include in API requests. By default, fields with empty or 389 // default values are omitted from API requests. See 390 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 391 // details. 392 ForceSendFields []string `json:"-"` 393 // NullFields is a list of field names (e.g. "Annotations") to include in API 394 // requests with the JSON null value. By default, fields with empty values are 395 // omitted from API requests. See 396 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 397 NullFields []string `json:"-"` 398 } 399 400 func (s *CustomClass) MarshalJSON() ([]byte, error) { 401 type NoMethod CustomClass 402 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 403 } 404 405 // Empty: A generic empty message that you can re-use to avoid defining 406 // duplicated empty messages in your APIs. A typical example is to use it as 407 // the request or the response type of an API method. For instance: service Foo 408 // { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } 409 type Empty struct { 410 // ServerResponse contains the HTTP response code and headers from the server. 411 googleapi.ServerResponse `json:"-"` 412 } 413 414 // Entry: A single replacement configuration. 415 type Entry struct { 416 // CaseSensitive: Whether the search is case sensitive. 417 CaseSensitive bool `json:"caseSensitive,omitempty"` 418 // Replace: What to replace with. Max length is 100 characters. 419 Replace string `json:"replace,omitempty"` 420 // Search: What to replace. Max length is 100 characters. 421 Search string `json:"search,omitempty"` 422 // ForceSendFields is a list of field names (e.g. "CaseSensitive") to 423 // unconditionally include in API requests. By default, fields with empty or 424 // default values are omitted from API requests. See 425 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 426 // details. 427 ForceSendFields []string `json:"-"` 428 // NullFields is a list of field names (e.g. "CaseSensitive") to include in API 429 // requests with the JSON null value. By default, fields with empty values are 430 // omitted from API requests. See 431 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 432 NullFields []string `json:"-"` 433 } 434 435 func (s *Entry) MarshalJSON() ([]byte, error) { 436 type NoMethod Entry 437 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 438 } 439 440 // ListCustomClassesResponse: Message returned to the client by the 441 // `ListCustomClasses` method. 442 type ListCustomClassesResponse struct { 443 // CustomClasses: The custom classes. 444 CustomClasses []*CustomClass `json:"customClasses,omitempty"` 445 // NextPageToken: A token, which can be sent as `page_token` to retrieve the 446 // next page. If this field is omitted, there are no subsequent pages. 447 NextPageToken string `json:"nextPageToken,omitempty"` 448 449 // ServerResponse contains the HTTP response code and headers from the server. 450 googleapi.ServerResponse `json:"-"` 451 // ForceSendFields is a list of field names (e.g. "CustomClasses") to 452 // unconditionally include in API requests. By default, fields with empty or 453 // default values are omitted from API requests. See 454 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 455 // details. 456 ForceSendFields []string `json:"-"` 457 // NullFields is a list of field names (e.g. "CustomClasses") to include in API 458 // requests with the JSON null value. By default, fields with empty values are 459 // omitted from API requests. See 460 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 461 NullFields []string `json:"-"` 462 } 463 464 func (s *ListCustomClassesResponse) MarshalJSON() ([]byte, error) { 465 type NoMethod ListCustomClassesResponse 466 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 467 } 468 469 // ListOperationsResponse: The response message for Operations.ListOperations. 470 type ListOperationsResponse struct { 471 // NextPageToken: The standard List next-page token. 472 NextPageToken string `json:"nextPageToken,omitempty"` 473 // Operations: A list of operations that matches the specified filter in the 474 // request. 475 Operations []*Operation `json:"operations,omitempty"` 476 477 // ServerResponse contains the HTTP response code and headers from the server. 478 googleapi.ServerResponse `json:"-"` 479 // ForceSendFields is a list of field names (e.g. "NextPageToken") to 480 // unconditionally include in API requests. By default, fields with empty or 481 // default values are omitted from API requests. See 482 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 483 // details. 484 ForceSendFields []string `json:"-"` 485 // NullFields is a list of field names (e.g. "NextPageToken") to include in API 486 // requests with the JSON null value. By default, fields with empty values are 487 // omitted from API requests. See 488 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 489 NullFields []string `json:"-"` 490 } 491 492 func (s *ListOperationsResponse) MarshalJSON() ([]byte, error) { 493 type NoMethod ListOperationsResponse 494 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 495 } 496 497 // ListPhraseSetResponse: Message returned to the client by the `ListPhraseSet` 498 // method. 499 type ListPhraseSetResponse struct { 500 // NextPageToken: A token, which can be sent as `page_token` to retrieve the 501 // next page. If this field is omitted, there are no subsequent pages. 502 NextPageToken string `json:"nextPageToken,omitempty"` 503 // PhraseSets: The phrase set. 504 PhraseSets []*PhraseSet `json:"phraseSets,omitempty"` 505 506 // ServerResponse contains the HTTP response code and headers from the server. 507 googleapi.ServerResponse `json:"-"` 508 // ForceSendFields is a list of field names (e.g. "NextPageToken") to 509 // unconditionally include in API requests. By default, fields with empty or 510 // default values are omitted from API requests. See 511 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 512 // details. 513 ForceSendFields []string `json:"-"` 514 // NullFields is a list of field names (e.g. "NextPageToken") to include in API 515 // requests with the JSON null value. By default, fields with empty values are 516 // omitted from API requests. See 517 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 518 NullFields []string `json:"-"` 519 } 520 521 func (s *ListPhraseSetResponse) MarshalJSON() ([]byte, error) { 522 type NoMethod ListPhraseSetResponse 523 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 524 } 525 526 // LongRunningRecognizeMetadata: Describes the progress of a long-running 527 // `LongRunningRecognize` call. It is included in the `metadata` field of the 528 // `Operation` returned by the `GetOperation` call of the 529 // `google::longrunning::Operations` service. 530 type LongRunningRecognizeMetadata struct { 531 // LastUpdateTime: Time of the most recent processing update. 532 LastUpdateTime string `json:"lastUpdateTime,omitempty"` 533 // OutputConfig: Output only. A copy of the TranscriptOutputConfig if it was 534 // set in the request. 535 OutputConfig *TranscriptOutputConfig `json:"outputConfig,omitempty"` 536 // ProgressPercent: Approximate percentage of audio processed thus far. 537 // Guaranteed to be 100 when the audio is fully processed and the results are 538 // available. 539 ProgressPercent int64 `json:"progressPercent,omitempty"` 540 // StartTime: Time when the request was received. 541 StartTime string `json:"startTime,omitempty"` 542 // Uri: Output only. The URI of the audio file being transcribed. Empty if the 543 // audio was sent as byte content. 544 Uri string `json:"uri,omitempty"` 545 // ForceSendFields is a list of field names (e.g. "LastUpdateTime") to 546 // unconditionally include in API requests. By default, fields with empty or 547 // default values are omitted from API requests. See 548 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 549 // details. 550 ForceSendFields []string `json:"-"` 551 // NullFields is a list of field names (e.g. "LastUpdateTime") to include in 552 // API requests with the JSON null value. By default, fields with empty values 553 // are omitted from API requests. See 554 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 555 NullFields []string `json:"-"` 556 } 557 558 func (s *LongRunningRecognizeMetadata) MarshalJSON() ([]byte, error) { 559 type NoMethod LongRunningRecognizeMetadata 560 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 561 } 562 563 // LongRunningRecognizeRequest: The top-level message sent by the client for 564 // the `LongRunningRecognize` method. 565 type LongRunningRecognizeRequest struct { 566 // Audio: Required. The audio data to be recognized. 567 Audio *RecognitionAudio `json:"audio,omitempty"` 568 // Config: Required. Provides information to the recognizer that specifies how 569 // to process the request. 570 Config *RecognitionConfig `json:"config,omitempty"` 571 // OutputConfig: Optional. Specifies an optional destination for the 572 // recognition results. 573 OutputConfig *TranscriptOutputConfig `json:"outputConfig,omitempty"` 574 // ForceSendFields is a list of field names (e.g. "Audio") to unconditionally 575 // include in API requests. By default, fields with empty or default values are 576 // omitted from API requests. See 577 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 578 // details. 579 ForceSendFields []string `json:"-"` 580 // NullFields is a list of field names (e.g. "Audio") to include in API 581 // requests with the JSON null value. By default, fields with empty values are 582 // omitted from API requests. See 583 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 584 NullFields []string `json:"-"` 585 } 586 587 func (s *LongRunningRecognizeRequest) MarshalJSON() ([]byte, error) { 588 type NoMethod LongRunningRecognizeRequest 589 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 590 } 591 592 // LongRunningRecognizeResponse: The only message returned to the client by the 593 // `LongRunningRecognize` method. It contains the result as zero or more 594 // sequential `SpeechRecognitionResult` messages. It is included in the 595 // `result.response` field of the `Operation` returned by the `GetOperation` 596 // call of the `google::longrunning::Operations` service. 597 type LongRunningRecognizeResponse struct { 598 // OutputConfig: Original output config if present in the request. 599 OutputConfig *TranscriptOutputConfig `json:"outputConfig,omitempty"` 600 // OutputError: If the transcript output fails this field contains the relevant 601 // error. 602 OutputError *Status `json:"outputError,omitempty"` 603 // RequestId: The ID associated with the request. This is a unique ID specific 604 // only to the given request. 605 RequestId int64 `json:"requestId,omitempty,string"` 606 // Results: Sequential list of transcription results corresponding to 607 // sequential portions of audio. 608 Results []*SpeechRecognitionResult `json:"results,omitempty"` 609 // SpeechAdaptationInfo: Provides information on speech adaptation behavior in 610 // response 611 SpeechAdaptationInfo *SpeechAdaptationInfo `json:"speechAdaptationInfo,omitempty"` 612 // TotalBilledTime: When available, billed audio seconds for the corresponding 613 // request. 614 TotalBilledTime string `json:"totalBilledTime,omitempty"` 615 // ForceSendFields is a list of field names (e.g. "OutputConfig") to 616 // unconditionally include in API requests. By default, fields with empty or 617 // default values are omitted from API requests. See 618 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 619 // details. 620 ForceSendFields []string `json:"-"` 621 // NullFields is a list of field names (e.g. "OutputConfig") to include in API 622 // requests with the JSON null value. By default, fields with empty values are 623 // omitted from API requests. See 624 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 625 NullFields []string `json:"-"` 626 } 627 628 func (s *LongRunningRecognizeResponse) MarshalJSON() ([]byte, error) { 629 type NoMethod LongRunningRecognizeResponse 630 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 631 } 632 633 // Operation: This resource represents a long-running operation that is the 634 // result of a network API call. 635 type Operation struct { 636 // Done: If the value is `false`, it means the operation is still in progress. 637 // If `true`, the operation is completed, and either `error` or `response` is 638 // available. 639 Done bool `json:"done,omitempty"` 640 // Error: The error result of the operation in case of failure or cancellation. 641 Error *Status `json:"error,omitempty"` 642 // Metadata: Service-specific metadata associated with the operation. It 643 // typically contains progress information and common metadata such as create 644 // time. Some services might not provide such metadata. Any method that returns 645 // a long-running operation should document the metadata type, if any. 646 Metadata googleapi.RawMessage `json:"metadata,omitempty"` 647 // Name: The server-assigned name, which is only unique within the same service 648 // that originally returns it. If you use the default HTTP mapping, the `name` 649 // should be a resource name ending with `operations/{unique_id}`. 650 Name string `json:"name,omitempty"` 651 // Response: The normal, successful response of the operation. If the original 652 // method returns no data on success, such as `Delete`, the response is 653 // `google.protobuf.Empty`. If the original method is standard 654 // `Get`/`Create`/`Update`, the response should be the resource. For other 655 // methods, the response should have the type `XxxResponse`, where `Xxx` is the 656 // original method name. For example, if the original method name is 657 // `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`. 658 Response googleapi.RawMessage `json:"response,omitempty"` 659 660 // ServerResponse contains the HTTP response code and headers from the server. 661 googleapi.ServerResponse `json:"-"` 662 // ForceSendFields is a list of field names (e.g. "Done") to unconditionally 663 // include in API requests. By default, fields with empty or default values are 664 // omitted from API requests. See 665 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 666 // details. 667 ForceSendFields []string `json:"-"` 668 // NullFields is a list of field names (e.g. "Done") to include in API requests 669 // with the JSON null value. By default, fields with empty values are omitted 670 // from API requests. See 671 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 672 NullFields []string `json:"-"` 673 } 674 675 func (s *Operation) MarshalJSON() ([]byte, error) { 676 type NoMethod Operation 677 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 678 } 679 680 // Phrase: A phrases containing words and phrase "hints" so that the speech 681 // recognition is more likely to recognize them. This can be used to improve 682 // the accuracy for specific words and phrases, for example, if specific 683 // commands are typically spoken by the user. This can also be used to add 684 // additional words to the vocabulary of the recognizer. See usage limits 685 // (https://cloud.google.com/speech-to-text/quotas#content). List items can 686 // also include pre-built or custom classes containing groups of words that 687 // represent common concepts that occur in natural language. For example, 688 // rather than providing a phrase hint for every month of the year (e.g. "i was 689 // born in january", "i was born in febuary", ...), use the pre-built `$MONTH` 690 // class improves the likelihood of correctly transcribing audio that includes 691 // months (e.g. "i was born in $month"). To refer to pre-built classes, use the 692 // class' symbol prepended with `$` e.g. `$MONTH`. To refer to custom classes 693 // that were defined inline in the request, set the class's `custom_class_id` 694 // to a string unique to all class resources and inline classes. Then use the 695 // class' id wrapped in $`{...}` e.g. "${my-months}". To refer to custom 696 // classes resources, use the class' id wrapped in `${}` (e.g. `${my-months}`). 697 // Speech-to-Text supports three locations: `global`, `us` (US North America), 698 // and `eu` (Europe). If you are calling the `speech.googleapis.com` endpoint, 699 // use the `global` location. To specify a region, use a regional endpoint 700 // (https://cloud.google.com/speech-to-text/docs/endpoints) with matching `us` 701 // or `eu` location value. 702 type Phrase struct { 703 // Boost: Hint Boost. Overrides the boost set at the phrase set level. Positive 704 // value will increase the probability that a specific phrase will be 705 // recognized over other similar sounding phrases. The higher the boost, the 706 // higher the chance of false positive recognition as well. Negative boost will 707 // simply be ignored. Though `boost` can accept a wide range of positive 708 // values, most use cases are best served with values between 0 and 20. We 709 // recommend using a binary search approach to finding the optimal value for 710 // your use case as well as adding phrases both with and without boost to your 711 // requests. 712 Boost float64 `json:"boost,omitempty"` 713 // Value: The phrase itself. 714 Value string `json:"value,omitempty"` 715 // ForceSendFields is a list of field names (e.g. "Boost") to unconditionally 716 // include in API requests. By default, fields with empty or default values are 717 // omitted from API requests. See 718 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 719 // details. 720 ForceSendFields []string `json:"-"` 721 // NullFields is a list of field names (e.g. "Boost") to include in API 722 // requests with the JSON null value. By default, fields with empty values are 723 // omitted from API requests. See 724 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 725 NullFields []string `json:"-"` 726 } 727 728 func (s *Phrase) MarshalJSON() ([]byte, error) { 729 type NoMethod Phrase 730 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 731 } 732 733 func (s *Phrase) UnmarshalJSON(data []byte) error { 734 type NoMethod Phrase 735 var s1 struct { 736 Boost gensupport.JSONFloat64 `json:"boost"` 737 *NoMethod 738 } 739 s1.NoMethod = (*NoMethod)(s) 740 if err := json.Unmarshal(data, &s1); err != nil { 741 return err 742 } 743 s.Boost = float64(s1.Boost) 744 return nil 745 } 746 747 // PhraseSet: Provides "hints" to the speech recognizer to favor specific words 748 // and phrases in the results. 749 type PhraseSet struct { 750 // Annotations: Output only. Allows users to store small amounts of arbitrary 751 // data. Both the key and the value must be 63 characters or less each. At most 752 // 100 annotations. This field is not used. 753 Annotations map[string]string `json:"annotations,omitempty"` 754 // Boost: Hint Boost. Positive value will increase the probability that a 755 // specific phrase will be recognized over other similar sounding phrases. The 756 // higher the boost, the higher the chance of false positive recognition as 757 // well. Negative boost values would correspond to anti-biasing. Anti-biasing 758 // is not enabled, so negative boost will simply be ignored. Though `boost` can 759 // accept a wide range of positive values, most use cases are best served with 760 // values between 0 (exclusive) and 20. We recommend using a binary search 761 // approach to finding the optimal value for your use case as well as adding 762 // phrases both with and without boost to your requests. 763 Boost float64 `json:"boost,omitempty"` 764 // DeleteTime: Output only. The time at which this resource was requested for 765 // deletion. This field is not used. 766 DeleteTime string `json:"deleteTime,omitempty"` 767 // DisplayName: Output only. User-settable, human-readable name for the 768 // PhraseSet. Must be 63 characters or less. This field is not used. 769 DisplayName string `json:"displayName,omitempty"` 770 // Etag: Output only. This checksum is computed by the server based on the 771 // value of other fields. This may be sent on update, undelete, and delete 772 // requests to ensure the client has an up-to-date value before proceeding. 773 // This field is not used. 774 Etag string `json:"etag,omitempty"` 775 // ExpireTime: Output only. The time at which this resource will be purged. 776 // This field is not used. 777 ExpireTime string `json:"expireTime,omitempty"` 778 // KmsKeyName: Output only. The KMS key name 779 // (https://cloud.google.com/kms/docs/resource-hierarchy#keys) with which the 780 // content of the PhraseSet is encrypted. The expected format is 781 // `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{cryp 782 // to_key}`. 783 KmsKeyName string `json:"kmsKeyName,omitempty"` 784 // KmsKeyVersionName: Output only. The KMS key version name 785 // (https://cloud.google.com/kms/docs/resource-hierarchy#key_versions) with 786 // which content of the PhraseSet is encrypted. The expected format is 787 // `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{cryp 788 // to_key}/cryptoKeyVersions/{crypto_key_version}`. 789 KmsKeyVersionName string `json:"kmsKeyVersionName,omitempty"` 790 // Name: The resource name of the phrase set. 791 Name string `json:"name,omitempty"` 792 // Phrases: A list of word and phrases. 793 Phrases []*Phrase `json:"phrases,omitempty"` 794 // Reconciling: Output only. Whether or not this PhraseSet is in the process of 795 // being updated. This field is not used. 796 Reconciling bool `json:"reconciling,omitempty"` 797 // State: Output only. The CustomClass lifecycle state. This field is not used. 798 // 799 // Possible values: 800 // "STATE_UNSPECIFIED" - Unspecified state. This is only used/useful for 801 // distinguishing unset values. 802 // "ACTIVE" - The normal and active state. 803 // "DELETED" - This CustomClass has been deleted. 804 State string `json:"state,omitempty"` 805 // Uid: Output only. System-assigned unique identifier for the PhraseSet. This 806 // field is not used. 807 Uid string `json:"uid,omitempty"` 808 809 // ServerResponse contains the HTTP response code and headers from the server. 810 googleapi.ServerResponse `json:"-"` 811 // ForceSendFields is a list of field names (e.g. "Annotations") to 812 // unconditionally include in API requests. By default, fields with empty or 813 // default values are omitted from API requests. See 814 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 815 // details. 816 ForceSendFields []string `json:"-"` 817 // NullFields is a list of field names (e.g. "Annotations") to include in API 818 // requests with the JSON null value. By default, fields with empty values are 819 // omitted from API requests. See 820 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 821 NullFields []string `json:"-"` 822 } 823 824 func (s *PhraseSet) MarshalJSON() ([]byte, error) { 825 type NoMethod PhraseSet 826 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 827 } 828 829 func (s *PhraseSet) UnmarshalJSON(data []byte) error { 830 type NoMethod PhraseSet 831 var s1 struct { 832 Boost gensupport.JSONFloat64 `json:"boost"` 833 *NoMethod 834 } 835 s1.NoMethod = (*NoMethod)(s) 836 if err := json.Unmarshal(data, &s1); err != nil { 837 return err 838 } 839 s.Boost = float64(s1.Boost) 840 return nil 841 } 842 843 // RecognitionAudio: Contains audio data in the encoding specified in the 844 // `RecognitionConfig`. Either `content` or `uri` must be supplied. Supplying 845 // both or neither returns google.rpc.Code.INVALID_ARGUMENT. See content limits 846 // (https://cloud.google.com/speech-to-text/quotas#content). 847 type RecognitionAudio struct { 848 // Content: The audio data bytes encoded as specified in `RecognitionConfig`. 849 // Note: as with all bytes fields, proto buffers use a pure binary 850 // representation, whereas JSON representations use base64. 851 Content string `json:"content,omitempty"` 852 // Uri: URI that points to a file that contains audio data bytes as specified 853 // in `RecognitionConfig`. The file must not be compressed (for example, gzip). 854 // Currently, only Google Cloud Storage URIs are supported, which must be 855 // specified in the following format: `gs://bucket_name/object_name` (other URI 856 // formats return google.rpc.Code.INVALID_ARGUMENT). For more information, see 857 // Request URIs (https://cloud.google.com/storage/docs/reference-uris). 858 Uri string `json:"uri,omitempty"` 859 // ForceSendFields is a list of field names (e.g. "Content") to unconditionally 860 // include in API requests. By default, fields with empty or default values are 861 // omitted from API requests. See 862 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 863 // details. 864 ForceSendFields []string `json:"-"` 865 // NullFields is a list of field names (e.g. "Content") to include in API 866 // requests with the JSON null value. By default, fields with empty values are 867 // omitted from API requests. See 868 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 869 NullFields []string `json:"-"` 870 } 871 872 func (s *RecognitionAudio) MarshalJSON() ([]byte, error) { 873 type NoMethod RecognitionAudio 874 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 875 } 876 877 // RecognitionConfig: Provides information to the recognizer that specifies how 878 // to process the request. 879 type RecognitionConfig struct { 880 // Adaptation: Speech adaptation configuration improves the accuracy of speech 881 // recognition. For more information, see the speech adaptation 882 // (https://cloud.google.com/speech-to-text/docs/adaptation) documentation. 883 // When speech adaptation is set it supersedes the `speech_contexts` field. 884 Adaptation *SpeechAdaptation `json:"adaptation,omitempty"` 885 // AlternativeLanguageCodes: A list of up to 3 additional BCP-47 886 // (https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tags, listing 887 // possible alternative languages of the supplied audio. See Language Support 888 // (https://cloud.google.com/speech-to-text/docs/languages) for a list of the 889 // currently supported language codes. If alternative languages are listed, 890 // recognition result will contain recognition in the most likely language 891 // detected including the main language_code. The recognition result will 892 // include the language tag of the language detected in the audio. Note: This 893 // feature is only supported for Voice Command and Voice Search use cases and 894 // performance may vary for other use cases (e.g., phone call transcription). 895 AlternativeLanguageCodes []string `json:"alternativeLanguageCodes,omitempty"` 896 // AudioChannelCount: The number of channels in the input audio data. ONLY set 897 // this for MULTI-CHANNEL recognition. Valid values for LINEAR16, OGG_OPUS and 898 // FLAC are `1`-`8`. Valid value for MULAW, AMR, AMR_WB and 899 // SPEEX_WITH_HEADER_BYTE is only `1`. If `0` or omitted, defaults to one 900 // channel (mono). Note: We only recognize the first channel by default. To 901 // perform independent recognition on each channel set 902 // `enable_separate_recognition_per_channel` to 'true'. 903 AudioChannelCount int64 `json:"audioChannelCount,omitempty"` 904 // DiarizationConfig: Config to enable speaker diarization and set additional 905 // parameters to make diarization better suited for your application. Note: 906 // When this is enabled, we send all the words from the beginning of the audio 907 // for the top alternative in every consecutive STREAMING responses. This is 908 // done in order to improve our speaker tags as our models learn to identify 909 // the speakers in the conversation over time. For non-streaming requests, the 910 // diarization results will be provided only in the top alternative of the 911 // FINAL SpeechRecognitionResult. 912 DiarizationConfig *SpeakerDiarizationConfig `json:"diarizationConfig,omitempty"` 913 // DiarizationSpeakerCount: If set, specifies the estimated number of speakers 914 // in the conversation. Defaults to '2'. Ignored unless 915 // enable_speaker_diarization is set to true. Note: Use diarization_config 916 // instead. 917 DiarizationSpeakerCount int64 `json:"diarizationSpeakerCount,omitempty"` 918 // EnableAutomaticPunctuation: If 'true', adds punctuation to recognition 919 // result hypotheses. This feature is only available in select languages. 920 // Setting this for requests in other languages has no effect at all. The 921 // default 'false' value does not add punctuation to result hypotheses. 922 EnableAutomaticPunctuation bool `json:"enableAutomaticPunctuation,omitempty"` 923 // EnableSeparateRecognitionPerChannel: This needs to be set to `true` 924 // explicitly and `audio_channel_count` > 1 to get each channel recognized 925 // separately. The recognition result will contain a `channel_tag` field to 926 // state which channel that result belongs to. If this is not true, we will 927 // only recognize the first channel. The request is billed cumulatively for all 928 // channels recognized: `audio_channel_count` multiplied by the length of the 929 // audio. 930 EnableSeparateRecognitionPerChannel bool `json:"enableSeparateRecognitionPerChannel,omitempty"` 931 // EnableSpeakerDiarization: If 'true', enables speaker detection for each 932 // recognized word in the top alternative of the recognition result using a 933 // speaker_label provided in the WordInfo. Note: Use diarization_config 934 // instead. 935 EnableSpeakerDiarization bool `json:"enableSpeakerDiarization,omitempty"` 936 // EnableSpokenEmojis: The spoken emoji behavior for the call If not set, uses 937 // default behavior based on model of choice If 'true', adds spoken emoji 938 // formatting for the request. This will replace spoken emojis with the 939 // corresponding Unicode symbols in the final transcript. If 'false', spoken 940 // emojis are not replaced. 941 EnableSpokenEmojis bool `json:"enableSpokenEmojis,omitempty"` 942 // EnableSpokenPunctuation: The spoken punctuation behavior for the call If not 943 // set, uses default behavior based on model of choice e.g. command_and_search 944 // will enable spoken punctuation by default If 'true', replaces spoken 945 // punctuation with the corresponding symbols in the request. For example, "how 946 // are you question mark" becomes "how are you?". See 947 // https://cloud.google.com/speech-to-text/docs/spoken-punctuation for support. 948 // If 'false', spoken punctuation is not replaced. 949 EnableSpokenPunctuation bool `json:"enableSpokenPunctuation,omitempty"` 950 // EnableWordConfidence: If `true`, the top result includes a list of words and 951 // the confidence for those words. If `false`, no word-level confidence 952 // information is returned. The default is `false`. 953 EnableWordConfidence bool `json:"enableWordConfidence,omitempty"` 954 // EnableWordTimeOffsets: If `true`, the top result includes a list of words 955 // and the start and end time offsets (timestamps) for those words. If `false`, 956 // no word-level time offset information is returned. The default is `false`. 957 EnableWordTimeOffsets bool `json:"enableWordTimeOffsets,omitempty"` 958 // Encoding: Encoding of audio data sent in all `RecognitionAudio` messages. 959 // This field is optional for `FLAC` and `WAV` audio files and required for all 960 // other audio formats. For details, see AudioEncoding. 961 // 962 // Possible values: 963 // "ENCODING_UNSPECIFIED" - Not specified. 964 // "LINEAR16" - Uncompressed 16-bit signed little-endian samples (Linear 965 // PCM). 966 // "FLAC" - `FLAC` (Free Lossless Audio Codec) is the recommended encoding 967 // because it is lossless--therefore recognition is not compromised--and 968 // requires only about half the bandwidth of `LINEAR16`. `FLAC` stream encoding 969 // supports 16-bit and 24-bit samples, however, not all fields in `STREAMINFO` 970 // are supported. 971 // "MULAW" - 8-bit samples that compand 14-bit audio samples using G.711 972 // PCMU/mu-law. 973 // "AMR" - Adaptive Multi-Rate Narrowband codec. `sample_rate_hertz` must be 974 // 8000. 975 // "AMR_WB" - Adaptive Multi-Rate Wideband codec. `sample_rate_hertz` must be 976 // 16000. 977 // "OGG_OPUS" - Opus encoded audio frames in Ogg container 978 // ([OggOpus](https://wiki.xiph.org/OggOpus)). `sample_rate_hertz` must be one 979 // of 8000, 12000, 16000, 24000, or 48000. 980 // "SPEEX_WITH_HEADER_BYTE" - Although the use of lossy encodings is not 981 // recommended, if a very low bitrate encoding is required, `OGG_OPUS` is 982 // highly preferred over Speex encoding. The [Speex](https://speex.org/) 983 // encoding supported by Cloud Speech API has a header byte in each block, as 984 // in MIME type `audio/x-speex-with-header-byte`. It is a variant of the RTP 985 // Speex encoding defined in [RFC 5574](https://tools.ietf.org/html/rfc5574). 986 // The stream is a sequence of blocks, one block per RTP packet. Each block 987 // starts with a byte containing the length of the block, in bytes, followed by 988 // one or more frames of Speex data, padded to an integral number of bytes 989 // (octets) as specified in RFC 5574. In other words, each RTP header is 990 // replaced with a single byte containing the block length. Only Speex wideband 991 // is supported. `sample_rate_hertz` must be 16000. 992 // "MP3" - MP3 audio. MP3 encoding is a Beta feature and only available in 993 // v1p1beta1. Support all standard MP3 bitrates (which range from 32-320 kbps). 994 // When using this encoding, `sample_rate_hertz` has to match the sample rate 995 // of the file being used. 996 // "WEBM_OPUS" - Opus encoded audio frames in WebM container 997 // ([WebM](https://www.webmproject.org/docs/container/)). `sample_rate_hertz` 998 // must be one of 8000, 12000, 16000, 24000, or 48000. 999 Encoding string `json:"encoding,omitempty"` 1000 // LanguageCode: Required. The language of the supplied audio as a BCP-47 1001 // (https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. Example: 1002 // "en-US". See Language Support 1003 // (https://cloud.google.com/speech-to-text/docs/languages) for a list of the 1004 // currently supported language codes. 1005 LanguageCode string `json:"languageCode,omitempty"` 1006 // MaxAlternatives: Maximum number of recognition hypotheses to be returned. 1007 // Specifically, the maximum number of `SpeechRecognitionAlternative` messages 1008 // within each `SpeechRecognitionResult`. The server may return fewer than 1009 // `max_alternatives`. Valid values are `0`-`30`. A value of `0` or `1` will 1010 // return a maximum of one. If omitted, will return a maximum of one. 1011 MaxAlternatives int64 `json:"maxAlternatives,omitempty"` 1012 // Metadata: Metadata regarding this request. 1013 Metadata *RecognitionMetadata `json:"metadata,omitempty"` 1014 // Model: Which model to select for the given request. Select the model best 1015 // suited to your domain to get best results. If a model is not explicitly 1016 // specified, then we auto-select a model based on the parameters in the 1017 // RecognitionConfig. *Model* *Description* latest_long Best for long form 1018 // content like media or conversation. latest_short Best for short form content 1019 // like commands or single shot directed speech. command_and_search Best for 1020 // short queries such as voice commands or voice search. phone_call Best for 1021 // audio that originated from a phone call (typically recorded at an 8khz 1022 // sampling rate). video Best for audio that originated from video or includes 1023 // multiple speakers. Ideally the audio is recorded at a 16khz or greater 1024 // sampling rate. This is a premium model that costs more than the standard 1025 // rate. default Best for audio that is not one of the specific audio models. 1026 // For example, long-form audio. Ideally the audio is high-fidelity, recorded 1027 // at a 16khz or greater sampling rate. medical_conversation Best for audio 1028 // that originated from a conversation between a medical provider and patient. 1029 // medical_dictation Best for audio that originated from dictation notes by a 1030 // medical provider. 1031 Model string `json:"model,omitempty"` 1032 // ProfanityFilter: If set to `true`, the server will attempt to filter out 1033 // profanities, replacing all but the initial character in each filtered word 1034 // with asterisks, e.g. "f***". If set to `false` or omitted, profanities won't 1035 // be filtered out. 1036 ProfanityFilter bool `json:"profanityFilter,omitempty"` 1037 // SampleRateHertz: Sample rate in Hertz of the audio data sent in all 1038 // `RecognitionAudio` messages. Valid values are: 8000-48000. 16000 is optimal. 1039 // For best results, set the sampling rate of the audio source to 16000 Hz. If 1040 // that's not possible, use the native sample rate of the audio source (instead 1041 // of re-sampling). This field is optional for FLAC and WAV audio files, but is 1042 // required for all other audio formats. For details, see AudioEncoding. 1043 SampleRateHertz int64 `json:"sampleRateHertz,omitempty"` 1044 // SpeechContexts: Array of SpeechContext. A means to provide context to assist 1045 // the speech recognition. For more information, see speech adaptation 1046 // (https://cloud.google.com/speech-to-text/docs/adaptation). 1047 SpeechContexts []*SpeechContext `json:"speechContexts,omitempty"` 1048 // TranscriptNormalization: Optional. Use transcription normalization to 1049 // automatically replace parts of the transcript with phrases of your choosing. 1050 // For StreamingRecognize, this normalization only applies to stable partial 1051 // transcripts (stability > 0.8) and final transcripts. 1052 TranscriptNormalization *TranscriptNormalization `json:"transcriptNormalization,omitempty"` 1053 // UseEnhanced: Set to true to use an enhanced model for speech recognition. If 1054 // `use_enhanced` is set to true and the `model` field is not set, then an 1055 // appropriate enhanced model is chosen if an enhanced model exists for the 1056 // audio. If `use_enhanced` is true and an enhanced version of the specified 1057 // model does not exist, then the speech is recognized using the standard 1058 // version of the specified model. 1059 UseEnhanced bool `json:"useEnhanced,omitempty"` 1060 // ForceSendFields is a list of field names (e.g. "Adaptation") to 1061 // unconditionally include in API requests. By default, fields with empty or 1062 // default values are omitted from API requests. See 1063 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1064 // details. 1065 ForceSendFields []string `json:"-"` 1066 // NullFields is a list of field names (e.g. "Adaptation") to include in API 1067 // requests with the JSON null value. By default, fields with empty values are 1068 // omitted from API requests. See 1069 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1070 NullFields []string `json:"-"` 1071 } 1072 1073 func (s *RecognitionConfig) MarshalJSON() ([]byte, error) { 1074 type NoMethod RecognitionConfig 1075 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1076 } 1077 1078 // RecognitionMetadata: Description of audio data to be recognized. 1079 type RecognitionMetadata struct { 1080 // AudioTopic: Description of the content. Eg. "Recordings of federal supreme 1081 // court hearings from 2012". 1082 AudioTopic string `json:"audioTopic,omitempty"` 1083 // IndustryNaicsCodeOfAudio: The industry vertical to which this speech 1084 // recognition request most closely applies. This is most indicative of the 1085 // topics contained in the audio. Use the 6-digit NAICS code to identify the 1086 // industry vertical - see https://www.naics.com/search/. 1087 IndustryNaicsCodeOfAudio int64 `json:"industryNaicsCodeOfAudio,omitempty"` 1088 // InteractionType: The use case most closely describing the audio content to 1089 // be recognized. 1090 // 1091 // Possible values: 1092 // "INTERACTION_TYPE_UNSPECIFIED" - Use case is either unknown or is 1093 // something other than one of the other values below. 1094 // "DISCUSSION" - Multiple people in a conversation or discussion. For 1095 // example in a meeting with two or more people actively participating. 1096 // Typically all the primary people speaking would be in the same room (if not, 1097 // see PHONE_CALL) 1098 // "PRESENTATION" - One or more persons lecturing or presenting to others, 1099 // mostly uninterrupted. 1100 // "PHONE_CALL" - A phone-call or video-conference in which two or more 1101 // people, who are not in the same room, are actively participating. 1102 // "VOICEMAIL" - A recorded message intended for another person to listen to. 1103 // "PROFESSIONALLY_PRODUCED" - Professionally produced audio (eg. TV Show, 1104 // Podcast). 1105 // "VOICE_SEARCH" - Transcribe spoken questions and queries into text. 1106 // "VOICE_COMMAND" - Transcribe voice commands, such as for controlling a 1107 // device. 1108 // "DICTATION" - Transcribe speech to text to create a written document, such 1109 // as a text-message, email or report. 1110 InteractionType string `json:"interactionType,omitempty"` 1111 // MicrophoneDistance: The audio type that most closely describes the audio 1112 // being recognized. 1113 // 1114 // Possible values: 1115 // "MICROPHONE_DISTANCE_UNSPECIFIED" - Audio type is not known. 1116 // "NEARFIELD" - The audio was captured from a closely placed microphone. Eg. 1117 // phone, dictaphone, or handheld microphone. Generally if there speaker is 1118 // within 1 meter of the microphone. 1119 // "MIDFIELD" - The speaker if within 3 meters of the microphone. 1120 // "FARFIELD" - The speaker is more than 3 meters away from the microphone. 1121 MicrophoneDistance string `json:"microphoneDistance,omitempty"` 1122 // ObfuscatedId: Obfuscated (privacy-protected) ID of the user, to identify 1123 // number of unique users using the service. 1124 ObfuscatedId int64 `json:"obfuscatedId,omitempty,string"` 1125 // OriginalMediaType: The original media the speech was recorded on. 1126 // 1127 // Possible values: 1128 // "ORIGINAL_MEDIA_TYPE_UNSPECIFIED" - Unknown original media type. 1129 // "AUDIO" - The speech data is an audio recording. 1130 // "VIDEO" - The speech data originally recorded on a video. 1131 OriginalMediaType string `json:"originalMediaType,omitempty"` 1132 // OriginalMimeType: Mime type of the original audio file. For example 1133 // `audio/m4a`, `audio/x-alaw-basic`, `audio/mp3`, `audio/3gpp`. A list of 1134 // possible audio mime types is maintained at 1135 // http://www.iana.org/assignments/media-types/media-types.xhtml#audio 1136 OriginalMimeType string `json:"originalMimeType,omitempty"` 1137 // RecordingDeviceName: The device used to make the recording. Examples 'Nexus 1138 // 5X' or 'Polycom SoundStation IP 6000' or 'POTS' or 'VoIP' or 'Cardioid 1139 // Microphone'. 1140 RecordingDeviceName string `json:"recordingDeviceName,omitempty"` 1141 // RecordingDeviceType: The type of device the speech was recorded with. 1142 // 1143 // Possible values: 1144 // "RECORDING_DEVICE_TYPE_UNSPECIFIED" - The recording device is unknown. 1145 // "SMARTPHONE" - Speech was recorded on a smartphone. 1146 // "PC" - Speech was recorded using a personal computer or tablet. 1147 // "PHONE_LINE" - Speech was recorded over a phone line. 1148 // "VEHICLE" - Speech was recorded in a vehicle. 1149 // "OTHER_OUTDOOR_DEVICE" - Speech was recorded outdoors. 1150 // "OTHER_INDOOR_DEVICE" - Speech was recorded indoors. 1151 RecordingDeviceType string `json:"recordingDeviceType,omitempty"` 1152 // ForceSendFields is a list of field names (e.g. "AudioTopic") to 1153 // unconditionally include in API requests. By default, fields with empty or 1154 // default values are omitted from API requests. See 1155 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1156 // details. 1157 ForceSendFields []string `json:"-"` 1158 // NullFields is a list of field names (e.g. "AudioTopic") to include in API 1159 // requests with the JSON null value. By default, fields with empty values are 1160 // omitted from API requests. See 1161 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1162 NullFields []string `json:"-"` 1163 } 1164 1165 func (s *RecognitionMetadata) MarshalJSON() ([]byte, error) { 1166 type NoMethod RecognitionMetadata 1167 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1168 } 1169 1170 // RecognizeRequest: The top-level message sent by the client for the 1171 // `Recognize` method. 1172 type RecognizeRequest struct { 1173 // Audio: Required. The audio data to be recognized. 1174 Audio *RecognitionAudio `json:"audio,omitempty"` 1175 // Config: Required. Provides information to the recognizer that specifies how 1176 // to process the request. 1177 Config *RecognitionConfig `json:"config,omitempty"` 1178 // ForceSendFields is a list of field names (e.g. "Audio") to unconditionally 1179 // include in API requests. By default, fields with empty or default values are 1180 // omitted from API requests. See 1181 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1182 // details. 1183 ForceSendFields []string `json:"-"` 1184 // NullFields is a list of field names (e.g. "Audio") to include in API 1185 // requests with the JSON null value. By default, fields with empty values are 1186 // omitted from API requests. See 1187 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1188 NullFields []string `json:"-"` 1189 } 1190 1191 func (s *RecognizeRequest) MarshalJSON() ([]byte, error) { 1192 type NoMethod RecognizeRequest 1193 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1194 } 1195 1196 // RecognizeResponse: The only message returned to the client by the 1197 // `Recognize` method. It contains the result as zero or more sequential 1198 // `SpeechRecognitionResult` messages. 1199 type RecognizeResponse struct { 1200 // RequestId: The ID associated with the request. This is a unique ID specific 1201 // only to the given request. 1202 RequestId int64 `json:"requestId,omitempty,string"` 1203 // Results: Sequential list of transcription results corresponding to 1204 // sequential portions of audio. 1205 Results []*SpeechRecognitionResult `json:"results,omitempty"` 1206 // SpeechAdaptationInfo: Provides information on adaptation behavior in 1207 // response 1208 SpeechAdaptationInfo *SpeechAdaptationInfo `json:"speechAdaptationInfo,omitempty"` 1209 // TotalBilledTime: When available, billed audio seconds for the corresponding 1210 // request. 1211 TotalBilledTime string `json:"totalBilledTime,omitempty"` 1212 // UsingLegacyModels: Whether request used legacy asr models (was not 1213 // automatically migrated to use conformer models). 1214 UsingLegacyModels bool `json:"usingLegacyModels,omitempty"` 1215 1216 // ServerResponse contains the HTTP response code and headers from the server. 1217 googleapi.ServerResponse `json:"-"` 1218 // ForceSendFields is a list of field names (e.g. "RequestId") to 1219 // unconditionally include in API requests. By default, fields with empty or 1220 // default values are omitted from API requests. See 1221 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1222 // details. 1223 ForceSendFields []string `json:"-"` 1224 // NullFields is a list of field names (e.g. "RequestId") to include in API 1225 // requests with the JSON null value. By default, fields with empty values are 1226 // omitted from API requests. See 1227 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1228 NullFields []string `json:"-"` 1229 } 1230 1231 func (s *RecognizeResponse) MarshalJSON() ([]byte, error) { 1232 type NoMethod RecognizeResponse 1233 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1234 } 1235 1236 // SpeakerDiarizationConfig: Config to enable speaker diarization. 1237 type SpeakerDiarizationConfig struct { 1238 // EnableSpeakerDiarization: If 'true', enables speaker detection for each 1239 // recognized word in the top alternative of the recognition result using a 1240 // speaker_label provided in the WordInfo. 1241 EnableSpeakerDiarization bool `json:"enableSpeakerDiarization,omitempty"` 1242 // MaxSpeakerCount: Maximum number of speakers in the conversation. This range 1243 // gives you more flexibility by allowing the system to automatically determine 1244 // the correct number of speakers. If not set, the default value is 6. 1245 MaxSpeakerCount int64 `json:"maxSpeakerCount,omitempty"` 1246 // MinSpeakerCount: Minimum number of speakers in the conversation. This range 1247 // gives you more flexibility by allowing the system to automatically determine 1248 // the correct number of speakers. If not set, the default value is 2. 1249 MinSpeakerCount int64 `json:"minSpeakerCount,omitempty"` 1250 // SpeakerTag: Output only. Unused. 1251 SpeakerTag int64 `json:"speakerTag,omitempty"` 1252 // ForceSendFields is a list of field names (e.g. "EnableSpeakerDiarization") 1253 // to unconditionally include in API requests. By default, fields with empty or 1254 // default values are omitted from API requests. See 1255 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1256 // details. 1257 ForceSendFields []string `json:"-"` 1258 // NullFields is a list of field names (e.g. "EnableSpeakerDiarization") to 1259 // include in API requests with the JSON null value. By default, fields with 1260 // empty values are omitted from API requests. See 1261 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1262 NullFields []string `json:"-"` 1263 } 1264 1265 func (s *SpeakerDiarizationConfig) MarshalJSON() ([]byte, error) { 1266 type NoMethod SpeakerDiarizationConfig 1267 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1268 } 1269 1270 // SpeechAdaptation: Speech adaptation configuration. 1271 type SpeechAdaptation struct { 1272 // AbnfGrammar: Augmented Backus-Naur form (ABNF) is a standardized grammar 1273 // notation comprised by a set of derivation rules. See specifications: 1274 // https://www.w3.org/TR/speech-grammar 1275 AbnfGrammar *ABNFGrammar `json:"abnfGrammar,omitempty"` 1276 // CustomClasses: A collection of custom classes. To specify the classes 1277 // inline, leave the class' `name` blank and fill in the rest of its fields, 1278 // giving it a unique `custom_class_id`. Refer to the inline defined class in 1279 // phrase hints by its `custom_class_id`. 1280 CustomClasses []*CustomClass `json:"customClasses,omitempty"` 1281 // PhraseSetReferences: A collection of phrase set resource names to use. 1282 PhraseSetReferences []string `json:"phraseSetReferences,omitempty"` 1283 // PhraseSets: A collection of phrase sets. To specify the hints inline, leave 1284 // the phrase set's `name` blank and fill in the rest of its fields. Any phrase 1285 // set can use any custom class. 1286 PhraseSets []*PhraseSet `json:"phraseSets,omitempty"` 1287 // ForceSendFields is a list of field names (e.g. "AbnfGrammar") to 1288 // unconditionally include in API requests. By default, fields with empty or 1289 // default values are omitted from API requests. See 1290 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1291 // details. 1292 ForceSendFields []string `json:"-"` 1293 // NullFields is a list of field names (e.g. "AbnfGrammar") to include in API 1294 // requests with the JSON null value. By default, fields with empty values are 1295 // omitted from API requests. See 1296 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1297 NullFields []string `json:"-"` 1298 } 1299 1300 func (s *SpeechAdaptation) MarshalJSON() ([]byte, error) { 1301 type NoMethod SpeechAdaptation 1302 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1303 } 1304 1305 // SpeechAdaptationInfo: Information on speech adaptation use in results 1306 type SpeechAdaptationInfo struct { 1307 // AdaptationTimeout: Whether there was a timeout when applying speech 1308 // adaptation. If true, adaptation had no effect in the response transcript. 1309 AdaptationTimeout bool `json:"adaptationTimeout,omitempty"` 1310 // TimeoutMessage: If set, returns a message specifying which part of the 1311 // speech adaptation request timed out. 1312 TimeoutMessage string `json:"timeoutMessage,omitempty"` 1313 // ForceSendFields is a list of field names (e.g. "AdaptationTimeout") to 1314 // unconditionally include in API requests. By default, fields with empty or 1315 // default values are omitted from API requests. See 1316 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1317 // details. 1318 ForceSendFields []string `json:"-"` 1319 // NullFields is a list of field names (e.g. "AdaptationTimeout") to include in 1320 // API requests with the JSON null value. By default, fields with empty values 1321 // are omitted from API requests. See 1322 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1323 NullFields []string `json:"-"` 1324 } 1325 1326 func (s *SpeechAdaptationInfo) MarshalJSON() ([]byte, error) { 1327 type NoMethod SpeechAdaptationInfo 1328 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1329 } 1330 1331 // SpeechContext: Provides "hints" to the speech recognizer to favor specific 1332 // words and phrases in the results. 1333 type SpeechContext struct { 1334 // Boost: Hint Boost. Positive value will increase the probability that a 1335 // specific phrase will be recognized over other similar sounding phrases. The 1336 // higher the boost, the higher the chance of false positive recognition as 1337 // well. Negative boost values would correspond to anti-biasing. Anti-biasing 1338 // is not enabled, so negative boost will simply be ignored. Though `boost` can 1339 // accept a wide range of positive values, most use cases are best served with 1340 // values between 0 and 20. We recommend using a binary search approach to 1341 // finding the optimal value for your use case. 1342 Boost float64 `json:"boost,omitempty"` 1343 // Phrases: A list of strings containing words and phrases "hints" so that the 1344 // speech recognition is more likely to recognize them. This can be used to 1345 // improve the accuracy for specific words and phrases, for example, if 1346 // specific commands are typically spoken by the user. This can also be used to 1347 // add additional words to the vocabulary of the recognizer. See usage limits 1348 // (https://cloud.google.com/speech-to-text/quotas#content). List items can 1349 // also be set to classes for groups of words that represent common concepts 1350 // that occur in natural language. For example, rather than providing phrase 1351 // hints for every month of the year, using the $MONTH class improves the 1352 // likelihood of correctly transcribing audio that includes months. 1353 Phrases []string `json:"phrases,omitempty"` 1354 // ForceSendFields is a list of field names (e.g. "Boost") to unconditionally 1355 // include in API requests. By default, fields with empty or default values are 1356 // omitted from API requests. See 1357 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1358 // details. 1359 ForceSendFields []string `json:"-"` 1360 // NullFields is a list of field names (e.g. "Boost") to include in API 1361 // requests with the JSON null value. By default, fields with empty values are 1362 // omitted from API requests. See 1363 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1364 NullFields []string `json:"-"` 1365 } 1366 1367 func (s *SpeechContext) MarshalJSON() ([]byte, error) { 1368 type NoMethod SpeechContext 1369 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1370 } 1371 1372 func (s *SpeechContext) UnmarshalJSON(data []byte) error { 1373 type NoMethod SpeechContext 1374 var s1 struct { 1375 Boost gensupport.JSONFloat64 `json:"boost"` 1376 *NoMethod 1377 } 1378 s1.NoMethod = (*NoMethod)(s) 1379 if err := json.Unmarshal(data, &s1); err != nil { 1380 return err 1381 } 1382 s.Boost = float64(s1.Boost) 1383 return nil 1384 } 1385 1386 // SpeechRecognitionAlternative: Alternative hypotheses (a.k.a. n-best list). 1387 type SpeechRecognitionAlternative struct { 1388 // Confidence: The confidence estimate between 0.0 and 1.0. A higher number 1389 // indicates an estimated greater likelihood that the recognized words are 1390 // correct. This field is set only for the top alternative of a non-streaming 1391 // result or, of a streaming result where `is_final=true`. This field is not 1392 // guaranteed to be accurate and users should not rely on it to be always 1393 // provided. The default of 0.0 is a sentinel value indicating `confidence` was 1394 // not set. 1395 Confidence float64 `json:"confidence,omitempty"` 1396 // Transcript: Transcript text representing the words that the user spoke. In 1397 // languages that use spaces to separate words, the transcript might have a 1398 // leading space if it isn't the first result. You can concatenate each result 1399 // to obtain the full transcript without using a separator. 1400 Transcript string `json:"transcript,omitempty"` 1401 // Words: A list of word-specific information for each recognized word. Note: 1402 // When `enable_speaker_diarization` is true, you will see all the words from 1403 // the beginning of the audio. 1404 Words []*WordInfo `json:"words,omitempty"` 1405 // ForceSendFields is a list of field names (e.g. "Confidence") to 1406 // unconditionally include in API requests. By default, fields with empty or 1407 // default values are omitted from API requests. See 1408 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1409 // details. 1410 ForceSendFields []string `json:"-"` 1411 // NullFields is a list of field names (e.g. "Confidence") to include in API 1412 // requests with the JSON null value. By default, fields with empty values are 1413 // omitted from API requests. See 1414 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1415 NullFields []string `json:"-"` 1416 } 1417 1418 func (s *SpeechRecognitionAlternative) MarshalJSON() ([]byte, error) { 1419 type NoMethod SpeechRecognitionAlternative 1420 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1421 } 1422 1423 func (s *SpeechRecognitionAlternative) UnmarshalJSON(data []byte) error { 1424 type NoMethod SpeechRecognitionAlternative 1425 var s1 struct { 1426 Confidence gensupport.JSONFloat64 `json:"confidence"` 1427 *NoMethod 1428 } 1429 s1.NoMethod = (*NoMethod)(s) 1430 if err := json.Unmarshal(data, &s1); err != nil { 1431 return err 1432 } 1433 s.Confidence = float64(s1.Confidence) 1434 return nil 1435 } 1436 1437 // SpeechRecognitionResult: A speech recognition result corresponding to a 1438 // portion of the audio. 1439 type SpeechRecognitionResult struct { 1440 // Alternatives: May contain one or more recognition hypotheses (up to the 1441 // maximum specified in `max_alternatives`). These alternatives are ordered in 1442 // terms of accuracy, with the top (first) alternative being the most probable, 1443 // as ranked by the recognizer. 1444 Alternatives []*SpeechRecognitionAlternative `json:"alternatives,omitempty"` 1445 // ChannelTag: For multi-channel audio, this is the channel number 1446 // corresponding to the recognized result for the audio from that channel. For 1447 // audio_channel_count = N, its output values can range from '1' to 'N'. 1448 ChannelTag int64 `json:"channelTag,omitempty"` 1449 // LanguageCode: Output only. The BCP-47 1450 // (https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag of the language 1451 // in this result. This language code was detected to have the most likelihood 1452 // of being spoken in the audio. 1453 LanguageCode string `json:"languageCode,omitempty"` 1454 // ResultEndTime: Time offset of the end of this result relative to the 1455 // beginning of the audio. 1456 ResultEndTime string `json:"resultEndTime,omitempty"` 1457 // ForceSendFields is a list of field names (e.g. "Alternatives") to 1458 // unconditionally include in API requests. By default, fields with empty or 1459 // default values are omitted from API requests. See 1460 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1461 // details. 1462 ForceSendFields []string `json:"-"` 1463 // NullFields is a list of field names (e.g. "Alternatives") to include in API 1464 // requests with the JSON null value. By default, fields with empty values are 1465 // omitted from API requests. See 1466 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1467 NullFields []string `json:"-"` 1468 } 1469 1470 func (s *SpeechRecognitionResult) MarshalJSON() ([]byte, error) { 1471 type NoMethod SpeechRecognitionResult 1472 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1473 } 1474 1475 // Status: The `Status` type defines a logical error model that is suitable for 1476 // different programming environments, including REST APIs and RPC APIs. It is 1477 // used by gRPC (https://github.com/grpc). Each `Status` message contains three 1478 // pieces of data: error code, error message, and error details. You can find 1479 // out more about this error model and how to work with it in the API Design 1480 // Guide (https://cloud.google.com/apis/design/errors). 1481 type Status struct { 1482 // Code: The status code, which should be an enum value of google.rpc.Code. 1483 Code int64 `json:"code,omitempty"` 1484 // Details: A list of messages that carry the error details. There is a common 1485 // set of message types for APIs to use. 1486 Details []googleapi.RawMessage `json:"details,omitempty"` 1487 // Message: A developer-facing error message, which should be in English. Any 1488 // user-facing error message should be localized and sent in the 1489 // google.rpc.Status.details field, or localized by the client. 1490 Message string `json:"message,omitempty"` 1491 // ForceSendFields is a list of field names (e.g. "Code") to unconditionally 1492 // include in API requests. By default, fields with empty or default values are 1493 // omitted from API requests. See 1494 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1495 // details. 1496 ForceSendFields []string `json:"-"` 1497 // NullFields is a list of field names (e.g. "Code") to include in API requests 1498 // with the JSON null value. By default, fields with empty values are omitted 1499 // from API requests. See 1500 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1501 NullFields []string `json:"-"` 1502 } 1503 1504 func (s *Status) MarshalJSON() ([]byte, error) { 1505 type NoMethod Status 1506 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1507 } 1508 1509 // TranscriptNormalization: Transcription normalization configuration. Use 1510 // transcription normalization to automatically replace parts of the transcript 1511 // with phrases of your choosing. For StreamingRecognize, this normalization 1512 // only applies to stable partial transcripts (stability > 0.8) and final 1513 // transcripts. 1514 type TranscriptNormalization struct { 1515 // Entries: A list of replacement entries. We will perform replacement with one 1516 // entry at a time. For example, the second entry in ["cat" => "dog", "mountain 1517 // cat" => "mountain dog"] will never be applied because we will always process 1518 // the first entry before it. At most 100 entries. 1519 Entries []*Entry `json:"entries,omitempty"` 1520 // ForceSendFields is a list of field names (e.g. "Entries") to unconditionally 1521 // include in API requests. By default, fields with empty or default values are 1522 // omitted from API requests. See 1523 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1524 // details. 1525 ForceSendFields []string `json:"-"` 1526 // NullFields is a list of field names (e.g. "Entries") to include in API 1527 // requests with the JSON null value. By default, fields with empty values are 1528 // omitted from API requests. See 1529 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1530 NullFields []string `json:"-"` 1531 } 1532 1533 func (s *TranscriptNormalization) MarshalJSON() ([]byte, error) { 1534 type NoMethod TranscriptNormalization 1535 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1536 } 1537 1538 // TranscriptOutputConfig: Specifies an optional destination for the 1539 // recognition results. 1540 type TranscriptOutputConfig struct { 1541 // GcsUri: Specifies a Cloud Storage URI for the recognition results. Must be 1542 // specified in the format: `gs://bucket_name/object_name`, and the bucket must 1543 // already exist. 1544 GcsUri string `json:"gcsUri,omitempty"` 1545 // ForceSendFields is a list of field names (e.g. "GcsUri") to unconditionally 1546 // include in API requests. By default, fields with empty or default values are 1547 // omitted from API requests. See 1548 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1549 // details. 1550 ForceSendFields []string `json:"-"` 1551 // NullFields is a list of field names (e.g. "GcsUri") to include in API 1552 // requests with the JSON null value. By default, fields with empty values are 1553 // omitted from API requests. See 1554 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1555 NullFields []string `json:"-"` 1556 } 1557 1558 func (s *TranscriptOutputConfig) MarshalJSON() ([]byte, error) { 1559 type NoMethod TranscriptOutputConfig 1560 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1561 } 1562 1563 // WordInfo: Word-specific information for recognized words. 1564 type WordInfo struct { 1565 // Confidence: The confidence estimate between 0.0 and 1.0. A higher number 1566 // indicates an estimated greater likelihood that the recognized words are 1567 // correct. This field is set only for the top alternative of a non-streaming 1568 // result or, of a streaming result where `is_final=true`. This field is not 1569 // guaranteed to be accurate and users should not rely on it to be always 1570 // provided. The default of 0.0 is a sentinel value indicating `confidence` was 1571 // not set. 1572 Confidence float64 `json:"confidence,omitempty"` 1573 // EndTime: Time offset relative to the beginning of the audio, and 1574 // corresponding to the end of the spoken word. This field is only set if 1575 // `enable_word_time_offsets=true` and only in the top hypothesis. This is an 1576 // experimental feature and the accuracy of the time offset can vary. 1577 EndTime string `json:"endTime,omitempty"` 1578 // SpeakerLabel: Output only. A label value assigned for every unique speaker 1579 // within the audio. This field specifies which speaker was detected to have 1580 // spoken this word. For some models, like medical_conversation this can be 1581 // actual speaker role, for example "patient" or "provider", but generally this 1582 // would be a number identifying a speaker. This field is only set if 1583 // enable_speaker_diarization = 'true' and only for the top alternative. 1584 SpeakerLabel string `json:"speakerLabel,omitempty"` 1585 // SpeakerTag: Output only. A distinct integer value is assigned for every 1586 // speaker within the audio. This field specifies which one of those speakers 1587 // was detected to have spoken this word. Value ranges from '1' to 1588 // diarization_speaker_count. speaker_tag is set if enable_speaker_diarization 1589 // = 'true' and only for the top alternative. Note: Use speaker_label instead. 1590 SpeakerTag int64 `json:"speakerTag,omitempty"` 1591 // StartTime: Time offset relative to the beginning of the audio, and 1592 // corresponding to the start of the spoken word. This field is only set if 1593 // `enable_word_time_offsets=true` and only in the top hypothesis. This is an 1594 // experimental feature and the accuracy of the time offset can vary. 1595 StartTime string `json:"startTime,omitempty"` 1596 // Word: The word corresponding to this set of information. 1597 Word string `json:"word,omitempty"` 1598 // ForceSendFields is a list of field names (e.g. "Confidence") to 1599 // unconditionally include in API requests. By default, fields with empty or 1600 // default values are omitted from API requests. See 1601 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 1602 // details. 1603 ForceSendFields []string `json:"-"` 1604 // NullFields is a list of field names (e.g. "Confidence") to include in API 1605 // requests with the JSON null value. By default, fields with empty values are 1606 // omitted from API requests. See 1607 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 1608 NullFields []string `json:"-"` 1609 } 1610 1611 func (s *WordInfo) MarshalJSON() ([]byte, error) { 1612 type NoMethod WordInfo 1613 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 1614 } 1615 1616 func (s *WordInfo) UnmarshalJSON(data []byte) error { 1617 type NoMethod WordInfo 1618 var s1 struct { 1619 Confidence gensupport.JSONFloat64 `json:"confidence"` 1620 *NoMethod 1621 } 1622 s1.NoMethod = (*NoMethod)(s) 1623 if err := json.Unmarshal(data, &s1); err != nil { 1624 return err 1625 } 1626 s.Confidence = float64(s1.Confidence) 1627 return nil 1628 } 1629 1630 type OperationsGetCall struct { 1631 s *Service 1632 name string 1633 urlParams_ gensupport.URLParams 1634 ifNoneMatch_ string 1635 ctx_ context.Context 1636 header_ http.Header 1637 } 1638 1639 // Get: Gets the latest state of a long-running operation. Clients can use this 1640 // method to poll the operation result at intervals as recommended by the API 1641 // service. 1642 // 1643 // - name: The name of the operation resource. 1644 func (r *OperationsService) Get(name string) *OperationsGetCall { 1645 c := &OperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1646 c.name = name 1647 return c 1648 } 1649 1650 // Fields allows partial responses to be retrieved. See 1651 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 1652 // details. 1653 func (c *OperationsGetCall) Fields(s ...googleapi.Field) *OperationsGetCall { 1654 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1655 return c 1656 } 1657 1658 // IfNoneMatch sets an optional parameter which makes the operation fail if the 1659 // object's ETag matches the given value. This is useful for getting updates 1660 // only after the object has changed since the last request. 1661 func (c *OperationsGetCall) IfNoneMatch(entityTag string) *OperationsGetCall { 1662 c.ifNoneMatch_ = entityTag 1663 return c 1664 } 1665 1666 // Context sets the context to be used in this call's Do method. 1667 func (c *OperationsGetCall) Context(ctx context.Context) *OperationsGetCall { 1668 c.ctx_ = ctx 1669 return c 1670 } 1671 1672 // Header returns a http.Header that can be modified by the caller to add 1673 // headers to the request. 1674 func (c *OperationsGetCall) Header() http.Header { 1675 if c.header_ == nil { 1676 c.header_ = make(http.Header) 1677 } 1678 return c.header_ 1679 } 1680 1681 func (c *OperationsGetCall) doRequest(alt string) (*http.Response, error) { 1682 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) 1683 if c.ifNoneMatch_ != "" { 1684 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1685 } 1686 var body io.Reader = nil 1687 c.urlParams_.Set("alt", alt) 1688 c.urlParams_.Set("prettyPrint", "false") 1689 urls := googleapi.ResolveRelative(c.s.BasePath, "v1p1beta1/operations/{+name}") 1690 urls += "?" + c.urlParams_.Encode() 1691 req, err := http.NewRequest("GET", urls, body) 1692 if err != nil { 1693 return nil, err 1694 } 1695 req.Header = reqHeaders 1696 googleapi.Expand(req.URL, map[string]string{ 1697 "name": c.name, 1698 }) 1699 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1700 } 1701 1702 // Do executes the "speech.operations.get" call. 1703 // Any non-2xx status code is an error. Response headers are in either 1704 // *Operation.ServerResponse.Header or (if a response was returned at all) in 1705 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 1706 // whether the returned error was because http.StatusNotModified was returned. 1707 func (c *OperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) { 1708 gensupport.SetOptions(c.urlParams_, opts...) 1709 res, err := c.doRequest("json") 1710 if res != nil && res.StatusCode == http.StatusNotModified { 1711 if res.Body != nil { 1712 res.Body.Close() 1713 } 1714 return nil, gensupport.WrapError(&googleapi.Error{ 1715 Code: res.StatusCode, 1716 Header: res.Header, 1717 }) 1718 } 1719 if err != nil { 1720 return nil, err 1721 } 1722 defer googleapi.CloseBody(res) 1723 if err := googleapi.CheckResponse(res); err != nil { 1724 return nil, gensupport.WrapError(err) 1725 } 1726 ret := &Operation{ 1727 ServerResponse: googleapi.ServerResponse{ 1728 Header: res.Header, 1729 HTTPStatusCode: res.StatusCode, 1730 }, 1731 } 1732 target := &ret 1733 if err := gensupport.DecodeResponse(target, res); err != nil { 1734 return nil, err 1735 } 1736 return ret, nil 1737 } 1738 1739 type OperationsListCall struct { 1740 s *Service 1741 urlParams_ gensupport.URLParams 1742 ifNoneMatch_ string 1743 ctx_ context.Context 1744 header_ http.Header 1745 } 1746 1747 // List: Lists operations that match the specified filter in the request. If 1748 // the server doesn't support this method, it returns `UNIMPLEMENTED`. 1749 func (r *OperationsService) List() *OperationsListCall { 1750 c := &OperationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1751 return c 1752 } 1753 1754 // Filter sets the optional parameter "filter": The standard list filter. 1755 func (c *OperationsListCall) Filter(filter string) *OperationsListCall { 1756 c.urlParams_.Set("filter", filter) 1757 return c 1758 } 1759 1760 // Name sets the optional parameter "name": The name of the operation's parent 1761 // resource. 1762 func (c *OperationsListCall) Name(name string) *OperationsListCall { 1763 c.urlParams_.Set("name", name) 1764 return c 1765 } 1766 1767 // PageSize sets the optional parameter "pageSize": The standard list page 1768 // size. 1769 func (c *OperationsListCall) PageSize(pageSize int64) *OperationsListCall { 1770 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) 1771 return c 1772 } 1773 1774 // PageToken sets the optional parameter "pageToken": The standard list page 1775 // token. 1776 func (c *OperationsListCall) PageToken(pageToken string) *OperationsListCall { 1777 c.urlParams_.Set("pageToken", pageToken) 1778 return c 1779 } 1780 1781 // Fields allows partial responses to be retrieved. See 1782 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 1783 // details. 1784 func (c *OperationsListCall) Fields(s ...googleapi.Field) *OperationsListCall { 1785 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1786 return c 1787 } 1788 1789 // IfNoneMatch sets an optional parameter which makes the operation fail if the 1790 // object's ETag matches the given value. This is useful for getting updates 1791 // only after the object has changed since the last request. 1792 func (c *OperationsListCall) IfNoneMatch(entityTag string) *OperationsListCall { 1793 c.ifNoneMatch_ = entityTag 1794 return c 1795 } 1796 1797 // Context sets the context to be used in this call's Do method. 1798 func (c *OperationsListCall) Context(ctx context.Context) *OperationsListCall { 1799 c.ctx_ = ctx 1800 return c 1801 } 1802 1803 // Header returns a http.Header that can be modified by the caller to add 1804 // headers to the request. 1805 func (c *OperationsListCall) Header() http.Header { 1806 if c.header_ == nil { 1807 c.header_ = make(http.Header) 1808 } 1809 return c.header_ 1810 } 1811 1812 func (c *OperationsListCall) doRequest(alt string) (*http.Response, error) { 1813 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) 1814 if c.ifNoneMatch_ != "" { 1815 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1816 } 1817 var body io.Reader = nil 1818 c.urlParams_.Set("alt", alt) 1819 c.urlParams_.Set("prettyPrint", "false") 1820 urls := googleapi.ResolveRelative(c.s.BasePath, "v1p1beta1/operations") 1821 urls += "?" + c.urlParams_.Encode() 1822 req, err := http.NewRequest("GET", urls, body) 1823 if err != nil { 1824 return nil, err 1825 } 1826 req.Header = reqHeaders 1827 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1828 } 1829 1830 // Do executes the "speech.operations.list" call. 1831 // Any non-2xx status code is an error. Response headers are in either 1832 // *ListOperationsResponse.ServerResponse.Header or (if a response was returned 1833 // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to 1834 // check whether the returned error was because http.StatusNotModified was 1835 // returned. 1836 func (c *OperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsResponse, error) { 1837 gensupport.SetOptions(c.urlParams_, opts...) 1838 res, err := c.doRequest("json") 1839 if res != nil && res.StatusCode == http.StatusNotModified { 1840 if res.Body != nil { 1841 res.Body.Close() 1842 } 1843 return nil, gensupport.WrapError(&googleapi.Error{ 1844 Code: res.StatusCode, 1845 Header: res.Header, 1846 }) 1847 } 1848 if err != nil { 1849 return nil, err 1850 } 1851 defer googleapi.CloseBody(res) 1852 if err := googleapi.CheckResponse(res); err != nil { 1853 return nil, gensupport.WrapError(err) 1854 } 1855 ret := &ListOperationsResponse{ 1856 ServerResponse: googleapi.ServerResponse{ 1857 Header: res.Header, 1858 HTTPStatusCode: res.StatusCode, 1859 }, 1860 } 1861 target := &ret 1862 if err := gensupport.DecodeResponse(target, res); err != nil { 1863 return nil, err 1864 } 1865 return ret, nil 1866 } 1867 1868 // Pages invokes f for each page of results. 1869 // A non-nil error returned from f will halt the iteration. 1870 // The provided context supersedes any context provided to the Context method. 1871 func (c *OperationsListCall) Pages(ctx context.Context, f func(*ListOperationsResponse) error) error { 1872 c.ctx_ = ctx 1873 defer c.PageToken(c.urlParams_.Get("pageToken")) 1874 for { 1875 x, err := c.Do() 1876 if err != nil { 1877 return err 1878 } 1879 if err := f(x); err != nil { 1880 return err 1881 } 1882 if x.NextPageToken == "" { 1883 return nil 1884 } 1885 c.PageToken(x.NextPageToken) 1886 } 1887 } 1888 1889 type ProjectsLocationsCustomClassesCreateCall struct { 1890 s *Service 1891 parent string 1892 createcustomclassrequest *CreateCustomClassRequest 1893 urlParams_ gensupport.URLParams 1894 ctx_ context.Context 1895 header_ http.Header 1896 } 1897 1898 // Create: Create a custom class. 1899 // 1900 // - parent: The parent resource where this custom class will be created. 1901 // Format: `projects/{project}/locations/{location}/customClasses` 1902 // Speech-to-Text supports three locations: `global`, `us` (US North 1903 // America), and `eu` (Europe). If you are calling the 1904 // `speech.googleapis.com` endpoint, use the `global` location. To specify a 1905 // region, use a regional endpoint 1906 // (https://cloud.google.com/speech-to-text/docs/endpoints) with matching 1907 // `us` or `eu` location value. 1908 func (r *ProjectsLocationsCustomClassesService) Create(parent string, createcustomclassrequest *CreateCustomClassRequest) *ProjectsLocationsCustomClassesCreateCall { 1909 c := &ProjectsLocationsCustomClassesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1910 c.parent = parent 1911 c.createcustomclassrequest = createcustomclassrequest 1912 return c 1913 } 1914 1915 // Fields allows partial responses to be retrieved. See 1916 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 1917 // details. 1918 func (c *ProjectsLocationsCustomClassesCreateCall) Fields(s ...googleapi.Field) *ProjectsLocationsCustomClassesCreateCall { 1919 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1920 return c 1921 } 1922 1923 // Context sets the context to be used in this call's Do method. 1924 func (c *ProjectsLocationsCustomClassesCreateCall) Context(ctx context.Context) *ProjectsLocationsCustomClassesCreateCall { 1925 c.ctx_ = ctx 1926 return c 1927 } 1928 1929 // Header returns a http.Header that can be modified by the caller to add 1930 // headers to the request. 1931 func (c *ProjectsLocationsCustomClassesCreateCall) Header() http.Header { 1932 if c.header_ == nil { 1933 c.header_ = make(http.Header) 1934 } 1935 return c.header_ 1936 } 1937 1938 func (c *ProjectsLocationsCustomClassesCreateCall) doRequest(alt string) (*http.Response, error) { 1939 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 1940 var body io.Reader = nil 1941 body, err := googleapi.WithoutDataWrapper.JSONReader(c.createcustomclassrequest) 1942 if err != nil { 1943 return nil, err 1944 } 1945 c.urlParams_.Set("alt", alt) 1946 c.urlParams_.Set("prettyPrint", "false") 1947 urls := googleapi.ResolveRelative(c.s.BasePath, "v1p1beta1/{+parent}/customClasses") 1948 urls += "?" + c.urlParams_.Encode() 1949 req, err := http.NewRequest("POST", urls, body) 1950 if err != nil { 1951 return nil, err 1952 } 1953 req.Header = reqHeaders 1954 googleapi.Expand(req.URL, map[string]string{ 1955 "parent": c.parent, 1956 }) 1957 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1958 } 1959 1960 // Do executes the "speech.projects.locations.customClasses.create" call. 1961 // Any non-2xx status code is an error. Response headers are in either 1962 // *CustomClass.ServerResponse.Header or (if a response was returned at all) in 1963 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 1964 // whether the returned error was because http.StatusNotModified was returned. 1965 func (c *ProjectsLocationsCustomClassesCreateCall) Do(opts ...googleapi.CallOption) (*CustomClass, error) { 1966 gensupport.SetOptions(c.urlParams_, opts...) 1967 res, err := c.doRequest("json") 1968 if res != nil && res.StatusCode == http.StatusNotModified { 1969 if res.Body != nil { 1970 res.Body.Close() 1971 } 1972 return nil, gensupport.WrapError(&googleapi.Error{ 1973 Code: res.StatusCode, 1974 Header: res.Header, 1975 }) 1976 } 1977 if err != nil { 1978 return nil, err 1979 } 1980 defer googleapi.CloseBody(res) 1981 if err := googleapi.CheckResponse(res); err != nil { 1982 return nil, gensupport.WrapError(err) 1983 } 1984 ret := &CustomClass{ 1985 ServerResponse: googleapi.ServerResponse{ 1986 Header: res.Header, 1987 HTTPStatusCode: res.StatusCode, 1988 }, 1989 } 1990 target := &ret 1991 if err := gensupport.DecodeResponse(target, res); err != nil { 1992 return nil, err 1993 } 1994 return ret, nil 1995 } 1996 1997 type ProjectsLocationsCustomClassesDeleteCall struct { 1998 s *Service 1999 name string 2000 urlParams_ gensupport.URLParams 2001 ctx_ context.Context 2002 header_ http.Header 2003 } 2004 2005 // Delete: Delete a custom class. 2006 // 2007 // - name: The name of the custom class to delete. Format: 2008 // `projects/{project}/locations/{location}/customClasses/{custom_class}` 2009 // Speech-to-Text supports three locations: `global`, `us` (US North 2010 // America), and `eu` (Europe). If you are calling the 2011 // `speech.googleapis.com` endpoint, use the `global` location. To specify a 2012 // region, use a regional endpoint 2013 // (https://cloud.google.com/speech-to-text/docs/endpoints) with matching 2014 // `us` or `eu` location value. 2015 func (r *ProjectsLocationsCustomClassesService) Delete(name string) *ProjectsLocationsCustomClassesDeleteCall { 2016 c := &ProjectsLocationsCustomClassesDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} 2017 c.name = name 2018 return c 2019 } 2020 2021 // Fields allows partial responses to be retrieved. See 2022 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 2023 // details. 2024 func (c *ProjectsLocationsCustomClassesDeleteCall) Fields(s ...googleapi.Field) *ProjectsLocationsCustomClassesDeleteCall { 2025 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 2026 return c 2027 } 2028 2029 // Context sets the context to be used in this call's Do method. 2030 func (c *ProjectsLocationsCustomClassesDeleteCall) Context(ctx context.Context) *ProjectsLocationsCustomClassesDeleteCall { 2031 c.ctx_ = ctx 2032 return c 2033 } 2034 2035 // Header returns a http.Header that can be modified by the caller to add 2036 // headers to the request. 2037 func (c *ProjectsLocationsCustomClassesDeleteCall) Header() http.Header { 2038 if c.header_ == nil { 2039 c.header_ = make(http.Header) 2040 } 2041 return c.header_ 2042 } 2043 2044 func (c *ProjectsLocationsCustomClassesDeleteCall) doRequest(alt string) (*http.Response, error) { 2045 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) 2046 var body io.Reader = nil 2047 c.urlParams_.Set("alt", alt) 2048 c.urlParams_.Set("prettyPrint", "false") 2049 urls := googleapi.ResolveRelative(c.s.BasePath, "v1p1beta1/{+name}") 2050 urls += "?" + c.urlParams_.Encode() 2051 req, err := http.NewRequest("DELETE", urls, body) 2052 if err != nil { 2053 return nil, err 2054 } 2055 req.Header = reqHeaders 2056 googleapi.Expand(req.URL, map[string]string{ 2057 "name": c.name, 2058 }) 2059 return gensupport.SendRequest(c.ctx_, c.s.client, req) 2060 } 2061 2062 // Do executes the "speech.projects.locations.customClasses.delete" call. 2063 // Any non-2xx status code is an error. Response headers are in either 2064 // *Empty.ServerResponse.Header or (if a response was returned at all) in 2065 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 2066 // whether the returned error was because http.StatusNotModified was returned. 2067 func (c *ProjectsLocationsCustomClassesDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) { 2068 gensupport.SetOptions(c.urlParams_, opts...) 2069 res, err := c.doRequest("json") 2070 if res != nil && res.StatusCode == http.StatusNotModified { 2071 if res.Body != nil { 2072 res.Body.Close() 2073 } 2074 return nil, gensupport.WrapError(&googleapi.Error{ 2075 Code: res.StatusCode, 2076 Header: res.Header, 2077 }) 2078 } 2079 if err != nil { 2080 return nil, err 2081 } 2082 defer googleapi.CloseBody(res) 2083 if err := googleapi.CheckResponse(res); err != nil { 2084 return nil, gensupport.WrapError(err) 2085 } 2086 ret := &Empty{ 2087 ServerResponse: googleapi.ServerResponse{ 2088 Header: res.Header, 2089 HTTPStatusCode: res.StatusCode, 2090 }, 2091 } 2092 target := &ret 2093 if err := gensupport.DecodeResponse(target, res); err != nil { 2094 return nil, err 2095 } 2096 return ret, nil 2097 } 2098 2099 type ProjectsLocationsCustomClassesGetCall struct { 2100 s *Service 2101 name string 2102 urlParams_ gensupport.URLParams 2103 ifNoneMatch_ string 2104 ctx_ context.Context 2105 header_ http.Header 2106 } 2107 2108 // Get: Get a custom class. 2109 // 2110 // - name: The name of the custom class to retrieve. Format: 2111 // `projects/{project}/locations/{location}/customClasses/{custom_class}`. 2112 func (r *ProjectsLocationsCustomClassesService) Get(name string) *ProjectsLocationsCustomClassesGetCall { 2113 c := &ProjectsLocationsCustomClassesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 2114 c.name = name 2115 return c 2116 } 2117 2118 // Fields allows partial responses to be retrieved. See 2119 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 2120 // details. 2121 func (c *ProjectsLocationsCustomClassesGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsCustomClassesGetCall { 2122 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 2123 return c 2124 } 2125 2126 // IfNoneMatch sets an optional parameter which makes the operation fail if the 2127 // object's ETag matches the given value. This is useful for getting updates 2128 // only after the object has changed since the last request. 2129 func (c *ProjectsLocationsCustomClassesGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsCustomClassesGetCall { 2130 c.ifNoneMatch_ = entityTag 2131 return c 2132 } 2133 2134 // Context sets the context to be used in this call's Do method. 2135 func (c *ProjectsLocationsCustomClassesGetCall) Context(ctx context.Context) *ProjectsLocationsCustomClassesGetCall { 2136 c.ctx_ = ctx 2137 return c 2138 } 2139 2140 // Header returns a http.Header that can be modified by the caller to add 2141 // headers to the request. 2142 func (c *ProjectsLocationsCustomClassesGetCall) Header() http.Header { 2143 if c.header_ == nil { 2144 c.header_ = make(http.Header) 2145 } 2146 return c.header_ 2147 } 2148 2149 func (c *ProjectsLocationsCustomClassesGetCall) doRequest(alt string) (*http.Response, error) { 2150 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) 2151 if c.ifNoneMatch_ != "" { 2152 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 2153 } 2154 var body io.Reader = nil 2155 c.urlParams_.Set("alt", alt) 2156 c.urlParams_.Set("prettyPrint", "false") 2157 urls := googleapi.ResolveRelative(c.s.BasePath, "v1p1beta1/{+name}") 2158 urls += "?" + c.urlParams_.Encode() 2159 req, err := http.NewRequest("GET", urls, body) 2160 if err != nil { 2161 return nil, err 2162 } 2163 req.Header = reqHeaders 2164 googleapi.Expand(req.URL, map[string]string{ 2165 "name": c.name, 2166 }) 2167 return gensupport.SendRequest(c.ctx_, c.s.client, req) 2168 } 2169 2170 // Do executes the "speech.projects.locations.customClasses.get" call. 2171 // Any non-2xx status code is an error. Response headers are in either 2172 // *CustomClass.ServerResponse.Header or (if a response was returned at all) in 2173 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 2174 // whether the returned error was because http.StatusNotModified was returned. 2175 func (c *ProjectsLocationsCustomClassesGetCall) Do(opts ...googleapi.CallOption) (*CustomClass, error) { 2176 gensupport.SetOptions(c.urlParams_, opts...) 2177 res, err := c.doRequest("json") 2178 if res != nil && res.StatusCode == http.StatusNotModified { 2179 if res.Body != nil { 2180 res.Body.Close() 2181 } 2182 return nil, gensupport.WrapError(&googleapi.Error{ 2183 Code: res.StatusCode, 2184 Header: res.Header, 2185 }) 2186 } 2187 if err != nil { 2188 return nil, err 2189 } 2190 defer googleapi.CloseBody(res) 2191 if err := googleapi.CheckResponse(res); err != nil { 2192 return nil, gensupport.WrapError(err) 2193 } 2194 ret := &CustomClass{ 2195 ServerResponse: googleapi.ServerResponse{ 2196 Header: res.Header, 2197 HTTPStatusCode: res.StatusCode, 2198 }, 2199 } 2200 target := &ret 2201 if err := gensupport.DecodeResponse(target, res); err != nil { 2202 return nil, err 2203 } 2204 return ret, nil 2205 } 2206 2207 type ProjectsLocationsCustomClassesListCall struct { 2208 s *Service 2209 parent string 2210 urlParams_ gensupport.URLParams 2211 ifNoneMatch_ string 2212 ctx_ context.Context 2213 header_ http.Header 2214 } 2215 2216 // List: List custom classes. 2217 // 2218 // - parent: The parent, which owns this collection of custom classes. Format: 2219 // `projects/{project}/locations/{location}/customClasses` Speech-to-Text 2220 // supports three locations: `global`, `us` (US North America), and `eu` 2221 // (Europe). If you are calling the `speech.googleapis.com` endpoint, use the 2222 // `global` location. To specify a region, use a regional endpoint 2223 // (https://cloud.google.com/speech-to-text/docs/endpoints) with matching 2224 // `us` or `eu` location value. 2225 func (r *ProjectsLocationsCustomClassesService) List(parent string) *ProjectsLocationsCustomClassesListCall { 2226 c := &ProjectsLocationsCustomClassesListCall{s: r.s, urlParams_: make(gensupport.URLParams)} 2227 c.parent = parent 2228 return c 2229 } 2230 2231 // PageSize sets the optional parameter "pageSize": The maximum number of 2232 // custom classes to return. The service may return fewer than this value. If 2233 // unspecified, at most 50 custom classes will be returned. The maximum value 2234 // is 1000; values above 1000 will be coerced to 1000. 2235 func (c *ProjectsLocationsCustomClassesListCall) PageSize(pageSize int64) *ProjectsLocationsCustomClassesListCall { 2236 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) 2237 return c 2238 } 2239 2240 // PageToken sets the optional parameter "pageToken": A page token, received 2241 // from a previous `ListCustomClass` call. Provide this to retrieve the 2242 // subsequent page. When paginating, all other parameters provided to 2243 // `ListCustomClass` must match the call that provided the page token. 2244 func (c *ProjectsLocationsCustomClassesListCall) PageToken(pageToken string) *ProjectsLocationsCustomClassesListCall { 2245 c.urlParams_.Set("pageToken", pageToken) 2246 return c 2247 } 2248 2249 // Fields allows partial responses to be retrieved. See 2250 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 2251 // details. 2252 func (c *ProjectsLocationsCustomClassesListCall) Fields(s ...googleapi.Field) *ProjectsLocationsCustomClassesListCall { 2253 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 2254 return c 2255 } 2256 2257 // IfNoneMatch sets an optional parameter which makes the operation fail if the 2258 // object's ETag matches the given value. This is useful for getting updates 2259 // only after the object has changed since the last request. 2260 func (c *ProjectsLocationsCustomClassesListCall) IfNoneMatch(entityTag string) *ProjectsLocationsCustomClassesListCall { 2261 c.ifNoneMatch_ = entityTag 2262 return c 2263 } 2264 2265 // Context sets the context to be used in this call's Do method. 2266 func (c *ProjectsLocationsCustomClassesListCall) Context(ctx context.Context) *ProjectsLocationsCustomClassesListCall { 2267 c.ctx_ = ctx 2268 return c 2269 } 2270 2271 // Header returns a http.Header that can be modified by the caller to add 2272 // headers to the request. 2273 func (c *ProjectsLocationsCustomClassesListCall) Header() http.Header { 2274 if c.header_ == nil { 2275 c.header_ = make(http.Header) 2276 } 2277 return c.header_ 2278 } 2279 2280 func (c *ProjectsLocationsCustomClassesListCall) doRequest(alt string) (*http.Response, error) { 2281 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) 2282 if c.ifNoneMatch_ != "" { 2283 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 2284 } 2285 var body io.Reader = nil 2286 c.urlParams_.Set("alt", alt) 2287 c.urlParams_.Set("prettyPrint", "false") 2288 urls := googleapi.ResolveRelative(c.s.BasePath, "v1p1beta1/{+parent}/customClasses") 2289 urls += "?" + c.urlParams_.Encode() 2290 req, err := http.NewRequest("GET", urls, body) 2291 if err != nil { 2292 return nil, err 2293 } 2294 req.Header = reqHeaders 2295 googleapi.Expand(req.URL, map[string]string{ 2296 "parent": c.parent, 2297 }) 2298 return gensupport.SendRequest(c.ctx_, c.s.client, req) 2299 } 2300 2301 // Do executes the "speech.projects.locations.customClasses.list" call. 2302 // Any non-2xx status code is an error. Response headers are in either 2303 // *ListCustomClassesResponse.ServerResponse.Header or (if a response was 2304 // returned at all) in error.(*googleapi.Error).Header. Use 2305 // googleapi.IsNotModified to check whether the returned error was because 2306 // http.StatusNotModified was returned. 2307 func (c *ProjectsLocationsCustomClassesListCall) Do(opts ...googleapi.CallOption) (*ListCustomClassesResponse, error) { 2308 gensupport.SetOptions(c.urlParams_, opts...) 2309 res, err := c.doRequest("json") 2310 if res != nil && res.StatusCode == http.StatusNotModified { 2311 if res.Body != nil { 2312 res.Body.Close() 2313 } 2314 return nil, gensupport.WrapError(&googleapi.Error{ 2315 Code: res.StatusCode, 2316 Header: res.Header, 2317 }) 2318 } 2319 if err != nil { 2320 return nil, err 2321 } 2322 defer googleapi.CloseBody(res) 2323 if err := googleapi.CheckResponse(res); err != nil { 2324 return nil, gensupport.WrapError(err) 2325 } 2326 ret := &ListCustomClassesResponse{ 2327 ServerResponse: googleapi.ServerResponse{ 2328 Header: res.Header, 2329 HTTPStatusCode: res.StatusCode, 2330 }, 2331 } 2332 target := &ret 2333 if err := gensupport.DecodeResponse(target, res); err != nil { 2334 return nil, err 2335 } 2336 return ret, nil 2337 } 2338 2339 // Pages invokes f for each page of results. 2340 // A non-nil error returned from f will halt the iteration. 2341 // The provided context supersedes any context provided to the Context method. 2342 func (c *ProjectsLocationsCustomClassesListCall) Pages(ctx context.Context, f func(*ListCustomClassesResponse) error) error { 2343 c.ctx_ = ctx 2344 defer c.PageToken(c.urlParams_.Get("pageToken")) 2345 for { 2346 x, err := c.Do() 2347 if err != nil { 2348 return err 2349 } 2350 if err := f(x); err != nil { 2351 return err 2352 } 2353 if x.NextPageToken == "" { 2354 return nil 2355 } 2356 c.PageToken(x.NextPageToken) 2357 } 2358 } 2359 2360 type ProjectsLocationsCustomClassesPatchCall struct { 2361 s *Service 2362 name string 2363 customclass *CustomClass 2364 urlParams_ gensupport.URLParams 2365 ctx_ context.Context 2366 header_ http.Header 2367 } 2368 2369 // Patch: Update a custom class. 2370 // 2371 // - name: The resource name of the custom class. 2372 func (r *ProjectsLocationsCustomClassesService) Patch(name string, customclass *CustomClass) *ProjectsLocationsCustomClassesPatchCall { 2373 c := &ProjectsLocationsCustomClassesPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)} 2374 c.name = name 2375 c.customclass = customclass 2376 return c 2377 } 2378 2379 // UpdateMask sets the optional parameter "updateMask": The list of fields to 2380 // be updated. 2381 func (c *ProjectsLocationsCustomClassesPatchCall) UpdateMask(updateMask string) *ProjectsLocationsCustomClassesPatchCall { 2382 c.urlParams_.Set("updateMask", updateMask) 2383 return c 2384 } 2385 2386 // Fields allows partial responses to be retrieved. See 2387 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 2388 // details. 2389 func (c *ProjectsLocationsCustomClassesPatchCall) Fields(s ...googleapi.Field) *ProjectsLocationsCustomClassesPatchCall { 2390 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 2391 return c 2392 } 2393 2394 // Context sets the context to be used in this call's Do method. 2395 func (c *ProjectsLocationsCustomClassesPatchCall) Context(ctx context.Context) *ProjectsLocationsCustomClassesPatchCall { 2396 c.ctx_ = ctx 2397 return c 2398 } 2399 2400 // Header returns a http.Header that can be modified by the caller to add 2401 // headers to the request. 2402 func (c *ProjectsLocationsCustomClassesPatchCall) Header() http.Header { 2403 if c.header_ == nil { 2404 c.header_ = make(http.Header) 2405 } 2406 return c.header_ 2407 } 2408 2409 func (c *ProjectsLocationsCustomClassesPatchCall) doRequest(alt string) (*http.Response, error) { 2410 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 2411 var body io.Reader = nil 2412 body, err := googleapi.WithoutDataWrapper.JSONReader(c.customclass) 2413 if err != nil { 2414 return nil, err 2415 } 2416 c.urlParams_.Set("alt", alt) 2417 c.urlParams_.Set("prettyPrint", "false") 2418 urls := googleapi.ResolveRelative(c.s.BasePath, "v1p1beta1/{+name}") 2419 urls += "?" + c.urlParams_.Encode() 2420 req, err := http.NewRequest("PATCH", urls, body) 2421 if err != nil { 2422 return nil, err 2423 } 2424 req.Header = reqHeaders 2425 googleapi.Expand(req.URL, map[string]string{ 2426 "name": c.name, 2427 }) 2428 return gensupport.SendRequest(c.ctx_, c.s.client, req) 2429 } 2430 2431 // Do executes the "speech.projects.locations.customClasses.patch" call. 2432 // Any non-2xx status code is an error. Response headers are in either 2433 // *CustomClass.ServerResponse.Header or (if a response was returned at all) in 2434 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 2435 // whether the returned error was because http.StatusNotModified was returned. 2436 func (c *ProjectsLocationsCustomClassesPatchCall) Do(opts ...googleapi.CallOption) (*CustomClass, error) { 2437 gensupport.SetOptions(c.urlParams_, opts...) 2438 res, err := c.doRequest("json") 2439 if res != nil && res.StatusCode == http.StatusNotModified { 2440 if res.Body != nil { 2441 res.Body.Close() 2442 } 2443 return nil, gensupport.WrapError(&googleapi.Error{ 2444 Code: res.StatusCode, 2445 Header: res.Header, 2446 }) 2447 } 2448 if err != nil { 2449 return nil, err 2450 } 2451 defer googleapi.CloseBody(res) 2452 if err := googleapi.CheckResponse(res); err != nil { 2453 return nil, gensupport.WrapError(err) 2454 } 2455 ret := &CustomClass{ 2456 ServerResponse: googleapi.ServerResponse{ 2457 Header: res.Header, 2458 HTTPStatusCode: res.StatusCode, 2459 }, 2460 } 2461 target := &ret 2462 if err := gensupport.DecodeResponse(target, res); err != nil { 2463 return nil, err 2464 } 2465 return ret, nil 2466 } 2467 2468 type ProjectsLocationsPhraseSetsCreateCall struct { 2469 s *Service 2470 parent string 2471 createphrasesetrequest *CreatePhraseSetRequest 2472 urlParams_ gensupport.URLParams 2473 ctx_ context.Context 2474 header_ http.Header 2475 } 2476 2477 // Create: Create a set of phrase hints. Each item in the set can be a single 2478 // word or a multi-word phrase. The items in the PhraseSet are favored by the 2479 // recognition model when you send a call that includes the PhraseSet. 2480 // 2481 // - parent: The parent resource where this phrase set will be created. Format: 2482 // `projects/{project}/locations/{location}` Speech-to-Text supports three 2483 // locations: `global`, `us` (US North America), and `eu` (Europe). If you 2484 // are calling the `speech.googleapis.com` endpoint, use the `global` 2485 // location. To specify a region, use a regional endpoint 2486 // (https://cloud.google.com/speech-to-text/docs/endpoints) with matching 2487 // `us` or `eu` location value. 2488 func (r *ProjectsLocationsPhraseSetsService) Create(parent string, createphrasesetrequest *CreatePhraseSetRequest) *ProjectsLocationsPhraseSetsCreateCall { 2489 c := &ProjectsLocationsPhraseSetsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)} 2490 c.parent = parent 2491 c.createphrasesetrequest = createphrasesetrequest 2492 return c 2493 } 2494 2495 // Fields allows partial responses to be retrieved. See 2496 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 2497 // details. 2498 func (c *ProjectsLocationsPhraseSetsCreateCall) Fields(s ...googleapi.Field) *ProjectsLocationsPhraseSetsCreateCall { 2499 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 2500 return c 2501 } 2502 2503 // Context sets the context to be used in this call's Do method. 2504 func (c *ProjectsLocationsPhraseSetsCreateCall) Context(ctx context.Context) *ProjectsLocationsPhraseSetsCreateCall { 2505 c.ctx_ = ctx 2506 return c 2507 } 2508 2509 // Header returns a http.Header that can be modified by the caller to add 2510 // headers to the request. 2511 func (c *ProjectsLocationsPhraseSetsCreateCall) Header() http.Header { 2512 if c.header_ == nil { 2513 c.header_ = make(http.Header) 2514 } 2515 return c.header_ 2516 } 2517 2518 func (c *ProjectsLocationsPhraseSetsCreateCall) doRequest(alt string) (*http.Response, error) { 2519 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 2520 var body io.Reader = nil 2521 body, err := googleapi.WithoutDataWrapper.JSONReader(c.createphrasesetrequest) 2522 if err != nil { 2523 return nil, err 2524 } 2525 c.urlParams_.Set("alt", alt) 2526 c.urlParams_.Set("prettyPrint", "false") 2527 urls := googleapi.ResolveRelative(c.s.BasePath, "v1p1beta1/{+parent}/phraseSets") 2528 urls += "?" + c.urlParams_.Encode() 2529 req, err := http.NewRequest("POST", urls, body) 2530 if err != nil { 2531 return nil, err 2532 } 2533 req.Header = reqHeaders 2534 googleapi.Expand(req.URL, map[string]string{ 2535 "parent": c.parent, 2536 }) 2537 return gensupport.SendRequest(c.ctx_, c.s.client, req) 2538 } 2539 2540 // Do executes the "speech.projects.locations.phraseSets.create" call. 2541 // Any non-2xx status code is an error. Response headers are in either 2542 // *PhraseSet.ServerResponse.Header or (if a response was returned at all) in 2543 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 2544 // whether the returned error was because http.StatusNotModified was returned. 2545 func (c *ProjectsLocationsPhraseSetsCreateCall) Do(opts ...googleapi.CallOption) (*PhraseSet, error) { 2546 gensupport.SetOptions(c.urlParams_, opts...) 2547 res, err := c.doRequest("json") 2548 if res != nil && res.StatusCode == http.StatusNotModified { 2549 if res.Body != nil { 2550 res.Body.Close() 2551 } 2552 return nil, gensupport.WrapError(&googleapi.Error{ 2553 Code: res.StatusCode, 2554 Header: res.Header, 2555 }) 2556 } 2557 if err != nil { 2558 return nil, err 2559 } 2560 defer googleapi.CloseBody(res) 2561 if err := googleapi.CheckResponse(res); err != nil { 2562 return nil, gensupport.WrapError(err) 2563 } 2564 ret := &PhraseSet{ 2565 ServerResponse: googleapi.ServerResponse{ 2566 Header: res.Header, 2567 HTTPStatusCode: res.StatusCode, 2568 }, 2569 } 2570 target := &ret 2571 if err := gensupport.DecodeResponse(target, res); err != nil { 2572 return nil, err 2573 } 2574 return ret, nil 2575 } 2576 2577 type ProjectsLocationsPhraseSetsDeleteCall struct { 2578 s *Service 2579 name string 2580 urlParams_ gensupport.URLParams 2581 ctx_ context.Context 2582 header_ http.Header 2583 } 2584 2585 // Delete: Delete a phrase set. 2586 // 2587 // - name: The name of the phrase set to delete. Format: 2588 // `projects/{project}/locations/{location}/phraseSets/{phrase_set}`. 2589 func (r *ProjectsLocationsPhraseSetsService) Delete(name string) *ProjectsLocationsPhraseSetsDeleteCall { 2590 c := &ProjectsLocationsPhraseSetsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} 2591 c.name = name 2592 return c 2593 } 2594 2595 // Fields allows partial responses to be retrieved. See 2596 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 2597 // details. 2598 func (c *ProjectsLocationsPhraseSetsDeleteCall) Fields(s ...googleapi.Field) *ProjectsLocationsPhraseSetsDeleteCall { 2599 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 2600 return c 2601 } 2602 2603 // Context sets the context to be used in this call's Do method. 2604 func (c *ProjectsLocationsPhraseSetsDeleteCall) Context(ctx context.Context) *ProjectsLocationsPhraseSetsDeleteCall { 2605 c.ctx_ = ctx 2606 return c 2607 } 2608 2609 // Header returns a http.Header that can be modified by the caller to add 2610 // headers to the request. 2611 func (c *ProjectsLocationsPhraseSetsDeleteCall) Header() http.Header { 2612 if c.header_ == nil { 2613 c.header_ = make(http.Header) 2614 } 2615 return c.header_ 2616 } 2617 2618 func (c *ProjectsLocationsPhraseSetsDeleteCall) doRequest(alt string) (*http.Response, error) { 2619 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) 2620 var body io.Reader = nil 2621 c.urlParams_.Set("alt", alt) 2622 c.urlParams_.Set("prettyPrint", "false") 2623 urls := googleapi.ResolveRelative(c.s.BasePath, "v1p1beta1/{+name}") 2624 urls += "?" + c.urlParams_.Encode() 2625 req, err := http.NewRequest("DELETE", urls, body) 2626 if err != nil { 2627 return nil, err 2628 } 2629 req.Header = reqHeaders 2630 googleapi.Expand(req.URL, map[string]string{ 2631 "name": c.name, 2632 }) 2633 return gensupport.SendRequest(c.ctx_, c.s.client, req) 2634 } 2635 2636 // Do executes the "speech.projects.locations.phraseSets.delete" call. 2637 // Any non-2xx status code is an error. Response headers are in either 2638 // *Empty.ServerResponse.Header or (if a response was returned at all) in 2639 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 2640 // whether the returned error was because http.StatusNotModified was returned. 2641 func (c *ProjectsLocationsPhraseSetsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) { 2642 gensupport.SetOptions(c.urlParams_, opts...) 2643 res, err := c.doRequest("json") 2644 if res != nil && res.StatusCode == http.StatusNotModified { 2645 if res.Body != nil { 2646 res.Body.Close() 2647 } 2648 return nil, gensupport.WrapError(&googleapi.Error{ 2649 Code: res.StatusCode, 2650 Header: res.Header, 2651 }) 2652 } 2653 if err != nil { 2654 return nil, err 2655 } 2656 defer googleapi.CloseBody(res) 2657 if err := googleapi.CheckResponse(res); err != nil { 2658 return nil, gensupport.WrapError(err) 2659 } 2660 ret := &Empty{ 2661 ServerResponse: googleapi.ServerResponse{ 2662 Header: res.Header, 2663 HTTPStatusCode: res.StatusCode, 2664 }, 2665 } 2666 target := &ret 2667 if err := gensupport.DecodeResponse(target, res); err != nil { 2668 return nil, err 2669 } 2670 return ret, nil 2671 } 2672 2673 type ProjectsLocationsPhraseSetsGetCall struct { 2674 s *Service 2675 name string 2676 urlParams_ gensupport.URLParams 2677 ifNoneMatch_ string 2678 ctx_ context.Context 2679 header_ http.Header 2680 } 2681 2682 // Get: Get a phrase set. 2683 // 2684 // - name: The name of the phrase set to retrieve. Format: 2685 // `projects/{project}/locations/{location}/phraseSets/{phrase_set}` 2686 // Speech-to-Text supports three locations: `global`, `us` (US North 2687 // America), and `eu` (Europe). If you are calling the 2688 // `speech.googleapis.com` endpoint, use the `global` location. To specify a 2689 // region, use a regional endpoint 2690 // (https://cloud.google.com/speech-to-text/docs/endpoints) with matching 2691 // `us` or `eu` location value. 2692 func (r *ProjectsLocationsPhraseSetsService) Get(name string) *ProjectsLocationsPhraseSetsGetCall { 2693 c := &ProjectsLocationsPhraseSetsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 2694 c.name = name 2695 return c 2696 } 2697 2698 // Fields allows partial responses to be retrieved. See 2699 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 2700 // details. 2701 func (c *ProjectsLocationsPhraseSetsGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsPhraseSetsGetCall { 2702 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 2703 return c 2704 } 2705 2706 // IfNoneMatch sets an optional parameter which makes the operation fail if the 2707 // object's ETag matches the given value. This is useful for getting updates 2708 // only after the object has changed since the last request. 2709 func (c *ProjectsLocationsPhraseSetsGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsPhraseSetsGetCall { 2710 c.ifNoneMatch_ = entityTag 2711 return c 2712 } 2713 2714 // Context sets the context to be used in this call's Do method. 2715 func (c *ProjectsLocationsPhraseSetsGetCall) Context(ctx context.Context) *ProjectsLocationsPhraseSetsGetCall { 2716 c.ctx_ = ctx 2717 return c 2718 } 2719 2720 // Header returns a http.Header that can be modified by the caller to add 2721 // headers to the request. 2722 func (c *ProjectsLocationsPhraseSetsGetCall) Header() http.Header { 2723 if c.header_ == nil { 2724 c.header_ = make(http.Header) 2725 } 2726 return c.header_ 2727 } 2728 2729 func (c *ProjectsLocationsPhraseSetsGetCall) doRequest(alt string) (*http.Response, error) { 2730 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) 2731 if c.ifNoneMatch_ != "" { 2732 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 2733 } 2734 var body io.Reader = nil 2735 c.urlParams_.Set("alt", alt) 2736 c.urlParams_.Set("prettyPrint", "false") 2737 urls := googleapi.ResolveRelative(c.s.BasePath, "v1p1beta1/{+name}") 2738 urls += "?" + c.urlParams_.Encode() 2739 req, err := http.NewRequest("GET", urls, body) 2740 if err != nil { 2741 return nil, err 2742 } 2743 req.Header = reqHeaders 2744 googleapi.Expand(req.URL, map[string]string{ 2745 "name": c.name, 2746 }) 2747 return gensupport.SendRequest(c.ctx_, c.s.client, req) 2748 } 2749 2750 // Do executes the "speech.projects.locations.phraseSets.get" call. 2751 // Any non-2xx status code is an error. Response headers are in either 2752 // *PhraseSet.ServerResponse.Header or (if a response was returned at all) in 2753 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 2754 // whether the returned error was because http.StatusNotModified was returned. 2755 func (c *ProjectsLocationsPhraseSetsGetCall) Do(opts ...googleapi.CallOption) (*PhraseSet, error) { 2756 gensupport.SetOptions(c.urlParams_, opts...) 2757 res, err := c.doRequest("json") 2758 if res != nil && res.StatusCode == http.StatusNotModified { 2759 if res.Body != nil { 2760 res.Body.Close() 2761 } 2762 return nil, gensupport.WrapError(&googleapi.Error{ 2763 Code: res.StatusCode, 2764 Header: res.Header, 2765 }) 2766 } 2767 if err != nil { 2768 return nil, err 2769 } 2770 defer googleapi.CloseBody(res) 2771 if err := googleapi.CheckResponse(res); err != nil { 2772 return nil, gensupport.WrapError(err) 2773 } 2774 ret := &PhraseSet{ 2775 ServerResponse: googleapi.ServerResponse{ 2776 Header: res.Header, 2777 HTTPStatusCode: res.StatusCode, 2778 }, 2779 } 2780 target := &ret 2781 if err := gensupport.DecodeResponse(target, res); err != nil { 2782 return nil, err 2783 } 2784 return ret, nil 2785 } 2786 2787 type ProjectsLocationsPhraseSetsListCall struct { 2788 s *Service 2789 parent string 2790 urlParams_ gensupport.URLParams 2791 ifNoneMatch_ string 2792 ctx_ context.Context 2793 header_ http.Header 2794 } 2795 2796 // List: List phrase sets. 2797 // 2798 // - parent: The parent, which owns this collection of phrase set. Format: 2799 // `projects/{project}/locations/{location}` Speech-to-Text supports three 2800 // locations: `global`, `us` (US North America), and `eu` (Europe). If you 2801 // are calling the `speech.googleapis.com` endpoint, use the `global` 2802 // location. To specify a region, use a regional endpoint 2803 // (https://cloud.google.com/speech-to-text/docs/endpoints) with matching 2804 // `us` or `eu` location value. 2805 func (r *ProjectsLocationsPhraseSetsService) List(parent string) *ProjectsLocationsPhraseSetsListCall { 2806 c := &ProjectsLocationsPhraseSetsListCall{s: r.s, urlParams_: make(gensupport.URLParams)} 2807 c.parent = parent 2808 return c 2809 } 2810 2811 // PageSize sets the optional parameter "pageSize": The maximum number of 2812 // phrase sets to return. The service may return fewer than this value. If 2813 // unspecified, at most 50 phrase sets will be returned. The maximum value is 2814 // 1000; values above 1000 will be coerced to 1000. 2815 func (c *ProjectsLocationsPhraseSetsListCall) PageSize(pageSize int64) *ProjectsLocationsPhraseSetsListCall { 2816 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) 2817 return c 2818 } 2819 2820 // PageToken sets the optional parameter "pageToken": A page token, received 2821 // from a previous `ListPhraseSet` call. Provide this to retrieve the 2822 // subsequent page. When paginating, all other parameters provided to 2823 // `ListPhraseSet` must match the call that provided the page token. 2824 func (c *ProjectsLocationsPhraseSetsListCall) PageToken(pageToken string) *ProjectsLocationsPhraseSetsListCall { 2825 c.urlParams_.Set("pageToken", pageToken) 2826 return c 2827 } 2828 2829 // Fields allows partial responses to be retrieved. See 2830 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 2831 // details. 2832 func (c *ProjectsLocationsPhraseSetsListCall) Fields(s ...googleapi.Field) *ProjectsLocationsPhraseSetsListCall { 2833 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 2834 return c 2835 } 2836 2837 // IfNoneMatch sets an optional parameter which makes the operation fail if the 2838 // object's ETag matches the given value. This is useful for getting updates 2839 // only after the object has changed since the last request. 2840 func (c *ProjectsLocationsPhraseSetsListCall) IfNoneMatch(entityTag string) *ProjectsLocationsPhraseSetsListCall { 2841 c.ifNoneMatch_ = entityTag 2842 return c 2843 } 2844 2845 // Context sets the context to be used in this call's Do method. 2846 func (c *ProjectsLocationsPhraseSetsListCall) Context(ctx context.Context) *ProjectsLocationsPhraseSetsListCall { 2847 c.ctx_ = ctx 2848 return c 2849 } 2850 2851 // Header returns a http.Header that can be modified by the caller to add 2852 // headers to the request. 2853 func (c *ProjectsLocationsPhraseSetsListCall) Header() http.Header { 2854 if c.header_ == nil { 2855 c.header_ = make(http.Header) 2856 } 2857 return c.header_ 2858 } 2859 2860 func (c *ProjectsLocationsPhraseSetsListCall) doRequest(alt string) (*http.Response, error) { 2861 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) 2862 if c.ifNoneMatch_ != "" { 2863 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 2864 } 2865 var body io.Reader = nil 2866 c.urlParams_.Set("alt", alt) 2867 c.urlParams_.Set("prettyPrint", "false") 2868 urls := googleapi.ResolveRelative(c.s.BasePath, "v1p1beta1/{+parent}/phraseSets") 2869 urls += "?" + c.urlParams_.Encode() 2870 req, err := http.NewRequest("GET", urls, body) 2871 if err != nil { 2872 return nil, err 2873 } 2874 req.Header = reqHeaders 2875 googleapi.Expand(req.URL, map[string]string{ 2876 "parent": c.parent, 2877 }) 2878 return gensupport.SendRequest(c.ctx_, c.s.client, req) 2879 } 2880 2881 // Do executes the "speech.projects.locations.phraseSets.list" call. 2882 // Any non-2xx status code is an error. Response headers are in either 2883 // *ListPhraseSetResponse.ServerResponse.Header or (if a response was returned 2884 // at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to 2885 // check whether the returned error was because http.StatusNotModified was 2886 // returned. 2887 func (c *ProjectsLocationsPhraseSetsListCall) Do(opts ...googleapi.CallOption) (*ListPhraseSetResponse, error) { 2888 gensupport.SetOptions(c.urlParams_, opts...) 2889 res, err := c.doRequest("json") 2890 if res != nil && res.StatusCode == http.StatusNotModified { 2891 if res.Body != nil { 2892 res.Body.Close() 2893 } 2894 return nil, gensupport.WrapError(&googleapi.Error{ 2895 Code: res.StatusCode, 2896 Header: res.Header, 2897 }) 2898 } 2899 if err != nil { 2900 return nil, err 2901 } 2902 defer googleapi.CloseBody(res) 2903 if err := googleapi.CheckResponse(res); err != nil { 2904 return nil, gensupport.WrapError(err) 2905 } 2906 ret := &ListPhraseSetResponse{ 2907 ServerResponse: googleapi.ServerResponse{ 2908 Header: res.Header, 2909 HTTPStatusCode: res.StatusCode, 2910 }, 2911 } 2912 target := &ret 2913 if err := gensupport.DecodeResponse(target, res); err != nil { 2914 return nil, err 2915 } 2916 return ret, nil 2917 } 2918 2919 // Pages invokes f for each page of results. 2920 // A non-nil error returned from f will halt the iteration. 2921 // The provided context supersedes any context provided to the Context method. 2922 func (c *ProjectsLocationsPhraseSetsListCall) Pages(ctx context.Context, f func(*ListPhraseSetResponse) error) error { 2923 c.ctx_ = ctx 2924 defer c.PageToken(c.urlParams_.Get("pageToken")) 2925 for { 2926 x, err := c.Do() 2927 if err != nil { 2928 return err 2929 } 2930 if err := f(x); err != nil { 2931 return err 2932 } 2933 if x.NextPageToken == "" { 2934 return nil 2935 } 2936 c.PageToken(x.NextPageToken) 2937 } 2938 } 2939 2940 type ProjectsLocationsPhraseSetsPatchCall struct { 2941 s *Service 2942 name string 2943 phraseset *PhraseSet 2944 urlParams_ gensupport.URLParams 2945 ctx_ context.Context 2946 header_ http.Header 2947 } 2948 2949 // Patch: Update a phrase set. 2950 // 2951 // - name: The resource name of the phrase set. 2952 func (r *ProjectsLocationsPhraseSetsService) Patch(name string, phraseset *PhraseSet) *ProjectsLocationsPhraseSetsPatchCall { 2953 c := &ProjectsLocationsPhraseSetsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)} 2954 c.name = name 2955 c.phraseset = phraseset 2956 return c 2957 } 2958 2959 // UpdateMask sets the optional parameter "updateMask": The list of fields to 2960 // be updated. 2961 func (c *ProjectsLocationsPhraseSetsPatchCall) UpdateMask(updateMask string) *ProjectsLocationsPhraseSetsPatchCall { 2962 c.urlParams_.Set("updateMask", updateMask) 2963 return c 2964 } 2965 2966 // Fields allows partial responses to be retrieved. See 2967 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 2968 // details. 2969 func (c *ProjectsLocationsPhraseSetsPatchCall) Fields(s ...googleapi.Field) *ProjectsLocationsPhraseSetsPatchCall { 2970 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 2971 return c 2972 } 2973 2974 // Context sets the context to be used in this call's Do method. 2975 func (c *ProjectsLocationsPhraseSetsPatchCall) Context(ctx context.Context) *ProjectsLocationsPhraseSetsPatchCall { 2976 c.ctx_ = ctx 2977 return c 2978 } 2979 2980 // Header returns a http.Header that can be modified by the caller to add 2981 // headers to the request. 2982 func (c *ProjectsLocationsPhraseSetsPatchCall) Header() http.Header { 2983 if c.header_ == nil { 2984 c.header_ = make(http.Header) 2985 } 2986 return c.header_ 2987 } 2988 2989 func (c *ProjectsLocationsPhraseSetsPatchCall) doRequest(alt string) (*http.Response, error) { 2990 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 2991 var body io.Reader = nil 2992 body, err := googleapi.WithoutDataWrapper.JSONReader(c.phraseset) 2993 if err != nil { 2994 return nil, err 2995 } 2996 c.urlParams_.Set("alt", alt) 2997 c.urlParams_.Set("prettyPrint", "false") 2998 urls := googleapi.ResolveRelative(c.s.BasePath, "v1p1beta1/{+name}") 2999 urls += "?" + c.urlParams_.Encode() 3000 req, err := http.NewRequest("PATCH", urls, body) 3001 if err != nil { 3002 return nil, err 3003 } 3004 req.Header = reqHeaders 3005 googleapi.Expand(req.URL, map[string]string{ 3006 "name": c.name, 3007 }) 3008 return gensupport.SendRequest(c.ctx_, c.s.client, req) 3009 } 3010 3011 // Do executes the "speech.projects.locations.phraseSets.patch" call. 3012 // Any non-2xx status code is an error. Response headers are in either 3013 // *PhraseSet.ServerResponse.Header or (if a response was returned at all) in 3014 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 3015 // whether the returned error was because http.StatusNotModified was returned. 3016 func (c *ProjectsLocationsPhraseSetsPatchCall) Do(opts ...googleapi.CallOption) (*PhraseSet, error) { 3017 gensupport.SetOptions(c.urlParams_, opts...) 3018 res, err := c.doRequest("json") 3019 if res != nil && res.StatusCode == http.StatusNotModified { 3020 if res.Body != nil { 3021 res.Body.Close() 3022 } 3023 return nil, gensupport.WrapError(&googleapi.Error{ 3024 Code: res.StatusCode, 3025 Header: res.Header, 3026 }) 3027 } 3028 if err != nil { 3029 return nil, err 3030 } 3031 defer googleapi.CloseBody(res) 3032 if err := googleapi.CheckResponse(res); err != nil { 3033 return nil, gensupport.WrapError(err) 3034 } 3035 ret := &PhraseSet{ 3036 ServerResponse: googleapi.ServerResponse{ 3037 Header: res.Header, 3038 HTTPStatusCode: res.StatusCode, 3039 }, 3040 } 3041 target := &ret 3042 if err := gensupport.DecodeResponse(target, res); err != nil { 3043 return nil, err 3044 } 3045 return ret, nil 3046 } 3047 3048 type SpeechLongrunningrecognizeCall struct { 3049 s *Service 3050 longrunningrecognizerequest *LongRunningRecognizeRequest 3051 urlParams_ gensupport.URLParams 3052 ctx_ context.Context 3053 header_ http.Header 3054 } 3055 3056 // Longrunningrecognize: Performs asynchronous speech recognition: receive 3057 // results via the google.longrunning.Operations interface. Returns either an 3058 // `Operation.error` or an `Operation.response` which contains a 3059 // `LongRunningRecognizeResponse` message. For more information on asynchronous 3060 // speech recognition, see the how-to 3061 // (https://cloud.google.com/speech-to-text/docs/async-recognize). 3062 func (r *SpeechService) Longrunningrecognize(longrunningrecognizerequest *LongRunningRecognizeRequest) *SpeechLongrunningrecognizeCall { 3063 c := &SpeechLongrunningrecognizeCall{s: r.s, urlParams_: make(gensupport.URLParams)} 3064 c.longrunningrecognizerequest = longrunningrecognizerequest 3065 return c 3066 } 3067 3068 // Fields allows partial responses to be retrieved. See 3069 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 3070 // details. 3071 func (c *SpeechLongrunningrecognizeCall) Fields(s ...googleapi.Field) *SpeechLongrunningrecognizeCall { 3072 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 3073 return c 3074 } 3075 3076 // Context sets the context to be used in this call's Do method. 3077 func (c *SpeechLongrunningrecognizeCall) Context(ctx context.Context) *SpeechLongrunningrecognizeCall { 3078 c.ctx_ = ctx 3079 return c 3080 } 3081 3082 // Header returns a http.Header that can be modified by the caller to add 3083 // headers to the request. 3084 func (c *SpeechLongrunningrecognizeCall) Header() http.Header { 3085 if c.header_ == nil { 3086 c.header_ = make(http.Header) 3087 } 3088 return c.header_ 3089 } 3090 3091 func (c *SpeechLongrunningrecognizeCall) doRequest(alt string) (*http.Response, error) { 3092 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 3093 var body io.Reader = nil 3094 body, err := googleapi.WithoutDataWrapper.JSONReader(c.longrunningrecognizerequest) 3095 if err != nil { 3096 return nil, err 3097 } 3098 c.urlParams_.Set("alt", alt) 3099 c.urlParams_.Set("prettyPrint", "false") 3100 urls := googleapi.ResolveRelative(c.s.BasePath, "v1p1beta1/speech:longrunningrecognize") 3101 urls += "?" + c.urlParams_.Encode() 3102 req, err := http.NewRequest("POST", urls, body) 3103 if err != nil { 3104 return nil, err 3105 } 3106 req.Header = reqHeaders 3107 return gensupport.SendRequest(c.ctx_, c.s.client, req) 3108 } 3109 3110 // Do executes the "speech.speech.longrunningrecognize" call. 3111 // Any non-2xx status code is an error. Response headers are in either 3112 // *Operation.ServerResponse.Header or (if a response was returned at all) in 3113 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 3114 // whether the returned error was because http.StatusNotModified was returned. 3115 func (c *SpeechLongrunningrecognizeCall) Do(opts ...googleapi.CallOption) (*Operation, error) { 3116 gensupport.SetOptions(c.urlParams_, opts...) 3117 res, err := c.doRequest("json") 3118 if res != nil && res.StatusCode == http.StatusNotModified { 3119 if res.Body != nil { 3120 res.Body.Close() 3121 } 3122 return nil, gensupport.WrapError(&googleapi.Error{ 3123 Code: res.StatusCode, 3124 Header: res.Header, 3125 }) 3126 } 3127 if err != nil { 3128 return nil, err 3129 } 3130 defer googleapi.CloseBody(res) 3131 if err := googleapi.CheckResponse(res); err != nil { 3132 return nil, gensupport.WrapError(err) 3133 } 3134 ret := &Operation{ 3135 ServerResponse: googleapi.ServerResponse{ 3136 Header: res.Header, 3137 HTTPStatusCode: res.StatusCode, 3138 }, 3139 } 3140 target := &ret 3141 if err := gensupport.DecodeResponse(target, res); err != nil { 3142 return nil, err 3143 } 3144 return ret, nil 3145 } 3146 3147 type SpeechRecognizeCall struct { 3148 s *Service 3149 recognizerequest *RecognizeRequest 3150 urlParams_ gensupport.URLParams 3151 ctx_ context.Context 3152 header_ http.Header 3153 } 3154 3155 // Recognize: Performs synchronous speech recognition: receive results after 3156 // all audio has been sent and processed. 3157 func (r *SpeechService) Recognize(recognizerequest *RecognizeRequest) *SpeechRecognizeCall { 3158 c := &SpeechRecognizeCall{s: r.s, urlParams_: make(gensupport.URLParams)} 3159 c.recognizerequest = recognizerequest 3160 return c 3161 } 3162 3163 // Fields allows partial responses to be retrieved. See 3164 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 3165 // details. 3166 func (c *SpeechRecognizeCall) Fields(s ...googleapi.Field) *SpeechRecognizeCall { 3167 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 3168 return c 3169 } 3170 3171 // Context sets the context to be used in this call's Do method. 3172 func (c *SpeechRecognizeCall) Context(ctx context.Context) *SpeechRecognizeCall { 3173 c.ctx_ = ctx 3174 return c 3175 } 3176 3177 // Header returns a http.Header that can be modified by the caller to add 3178 // headers to the request. 3179 func (c *SpeechRecognizeCall) Header() http.Header { 3180 if c.header_ == nil { 3181 c.header_ = make(http.Header) 3182 } 3183 return c.header_ 3184 } 3185 3186 func (c *SpeechRecognizeCall) doRequest(alt string) (*http.Response, error) { 3187 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 3188 var body io.Reader = nil 3189 body, err := googleapi.WithoutDataWrapper.JSONReader(c.recognizerequest) 3190 if err != nil { 3191 return nil, err 3192 } 3193 c.urlParams_.Set("alt", alt) 3194 c.urlParams_.Set("prettyPrint", "false") 3195 urls := googleapi.ResolveRelative(c.s.BasePath, "v1p1beta1/speech:recognize") 3196 urls += "?" + c.urlParams_.Encode() 3197 req, err := http.NewRequest("POST", urls, body) 3198 if err != nil { 3199 return nil, err 3200 } 3201 req.Header = reqHeaders 3202 return gensupport.SendRequest(c.ctx_, c.s.client, req) 3203 } 3204 3205 // Do executes the "speech.speech.recognize" call. 3206 // Any non-2xx status code is an error. Response headers are in either 3207 // *RecognizeResponse.ServerResponse.Header or (if a response was returned at 3208 // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to 3209 // check whether the returned error was because http.StatusNotModified was 3210 // returned. 3211 func (c *SpeechRecognizeCall) Do(opts ...googleapi.CallOption) (*RecognizeResponse, error) { 3212 gensupport.SetOptions(c.urlParams_, opts...) 3213 res, err := c.doRequest("json") 3214 if res != nil && res.StatusCode == http.StatusNotModified { 3215 if res.Body != nil { 3216 res.Body.Close() 3217 } 3218 return nil, gensupport.WrapError(&googleapi.Error{ 3219 Code: res.StatusCode, 3220 Header: res.Header, 3221 }) 3222 } 3223 if err != nil { 3224 return nil, err 3225 } 3226 defer googleapi.CloseBody(res) 3227 if err := googleapi.CheckResponse(res); err != nil { 3228 return nil, gensupport.WrapError(err) 3229 } 3230 ret := &RecognizeResponse{ 3231 ServerResponse: googleapi.ServerResponse{ 3232 Header: res.Header, 3233 HTTPStatusCode: res.StatusCode, 3234 }, 3235 } 3236 target := &ret 3237 if err := gensupport.DecodeResponse(target, res); err != nil { 3238 return nil, err 3239 } 3240 return ret, nil 3241 } 3242