Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

2543 linhas
91 KiB

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