You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2378 lines
84 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/v1"
  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/v1"
  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:v1"
  69. const apiName = "speech"
  70. const apiVersion = "v1"
  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. // AudioChannelCount: *Optional* The number of channels in the input
  429. // audio data.
  430. // ONLY set this for MULTI-CHANNEL recognition.
  431. // Valid values for LINEAR16 and FLAC are `1`-`8`.
  432. // Valid values for OGG_OPUS are '1'-'254'.
  433. // Valid value for MULAW, AMR, AMR_WB and SPEEX_WITH_HEADER_BYTE is only
  434. // `1`.
  435. // If `0` or omitted, defaults to one channel (mono).
  436. // Note: We only recognize the first channel by default.
  437. // To perform independent recognition on each channel
  438. // set
  439. // `enable_separate_recognition_per_channel` to 'true'.
  440. AudioChannelCount int64 `json:"audioChannelCount,omitempty"`
  441. // EnableAutomaticPunctuation: *Optional* If 'true', adds punctuation to
  442. // recognition result hypotheses.
  443. // This feature is only available in select languages. Setting this
  444. // for
  445. // requests in other languages has no effect at all.
  446. // The default 'false' value does not add punctuation to result
  447. // hypotheses.
  448. // Note: This is currently offered as an experimental service,
  449. // complimentary
  450. // to all users. In the future this may be exclusively available as
  451. // a
  452. // premium feature.
  453. EnableAutomaticPunctuation bool `json:"enableAutomaticPunctuation,omitempty"`
  454. // EnableSeparateRecognitionPerChannel: This needs to be set to `true`
  455. // explicitly and `audio_channel_count` > 1
  456. // to get each channel recognized separately. The recognition result
  457. // will
  458. // contain a `channel_tag` field to state which channel that result
  459. // belongs
  460. // to. If this is not true, we will only recognize the first channel.
  461. // The
  462. // request is billed cumulatively for all channels
  463. // recognized:
  464. // `audio_channel_count` multiplied by the length of the audio.
  465. EnableSeparateRecognitionPerChannel bool `json:"enableSeparateRecognitionPerChannel,omitempty"`
  466. // EnableWordTimeOffsets: *Optional* If `true`, the top result includes
  467. // a list of words and
  468. // the start and end time offsets (timestamps) for those words.
  469. // If
  470. // `false`, no word-level time offset information is returned. The
  471. // default is
  472. // `false`.
  473. EnableWordTimeOffsets bool `json:"enableWordTimeOffsets,omitempty"`
  474. // Encoding: Encoding of audio data sent in all `RecognitionAudio`
  475. // messages.
  476. // This field is optional for `FLAC` and `WAV` audio files and
  477. // required
  478. // for all other audio formats. For details, see AudioEncoding.
  479. //
  480. // Possible values:
  481. // "ENCODING_UNSPECIFIED" - Not specified.
  482. // "LINEAR16" - Uncompressed 16-bit signed little-endian samples
  483. // (Linear PCM).
  484. // "FLAC" - `FLAC` (Free Lossless Audio
  485. // Codec) is the recommended encoding because it is
  486. // lossless--therefore recognition is not compromised--and
  487. // requires only about half the bandwidth of `LINEAR16`. `FLAC`
  488. // stream
  489. // encoding supports 16-bit and 24-bit samples, however, not all fields
  490. // in
  491. // `STREAMINFO` are supported.
  492. // "MULAW" - 8-bit samples that compand 14-bit audio samples using
  493. // G.711 PCMU/mu-law.
  494. // "AMR" - Adaptive Multi-Rate Narrowband codec. `sample_rate_hertz`
  495. // must be 8000.
  496. // "AMR_WB" - Adaptive Multi-Rate Wideband codec. `sample_rate_hertz`
  497. // must be 16000.
  498. // "OGG_OPUS" - Opus encoded audio frames in Ogg
  499. // container
  500. // ([OggOpus](https://wiki.xiph.org/OggOpus)).
  501. // `sample_rate_her
  502. // tz` must be one of 8000, 12000, 16000, 24000, or 48000.
  503. // "SPEEX_WITH_HEADER_BYTE" - Although the use of lossy encodings is
  504. // not recommended, if a very low
  505. // bitrate encoding is required, `OGG_OPUS` is highly preferred
  506. // over
  507. // Speex encoding. The [Speex](https://speex.org/) encoding supported
  508. // by
  509. // Cloud Speech API has a header byte in each block, as in MIME
  510. // type
  511. // `audio/x-speex-with-header-byte`.
  512. // It is a variant of the RTP Speex encoding defined in
  513. // [RFC 5574](https://tools.ietf.org/html/rfc5574).
  514. // The stream is a sequence of blocks, one block per RTP packet. Each
  515. // block
  516. // starts with a byte containing the length of the block, in bytes,
  517. // followed
  518. // by one or more frames of Speex data, padded to an integral number
  519. // of
  520. // bytes (octets) as specified in RFC 5574. In other words, each RTP
  521. // header
  522. // is replaced with a single byte containing the block length. Only
  523. // Speex
  524. // wideband is supported. `sample_rate_hertz` must be 16000.
  525. Encoding string `json:"encoding,omitempty"`
  526. // LanguageCode: *Required* The language of the supplied audio as
  527. // a
  528. // [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language
  529. // tag.
  530. // Example: "en-US".
  531. // See [Language Support](/speech-to-text/docs/languages)
  532. // for a list of the currently supported language codes.
  533. LanguageCode string `json:"languageCode,omitempty"`
  534. // MaxAlternatives: *Optional* Maximum number of recognition hypotheses
  535. // to be returned.
  536. // Specifically, the maximum number of `SpeechRecognitionAlternative`
  537. // messages
  538. // within each `SpeechRecognitionResult`.
  539. // The server may return fewer than `max_alternatives`.
  540. // Valid values are `0`-`30`. A value of `0` or `1` will return a
  541. // maximum of
  542. // one. If omitted, will return a maximum of one.
  543. MaxAlternatives int64 `json:"maxAlternatives,omitempty"`
  544. // Metadata: *Optional* Metadata regarding this request.
  545. Metadata *RecognitionMetadata `json:"metadata,omitempty"`
  546. // Model: *Optional* Which model to select for the given request. Select
  547. // the model
  548. // best suited to your domain to get best results. If a model is
  549. // not
  550. // explicitly specified, then we auto-select a model based on the
  551. // parameters
  552. // in the RecognitionConfig.
  553. // <table>
  554. // <tr>
  555. // <td><b>Model</b></td>
  556. // <td><b>Description</b></td>
  557. // </tr>
  558. // <tr>
  559. // <td><code>command_and_search</code></td>
  560. // <td>Best for short queries such as voice commands or voice
  561. // search.</td>
  562. // </tr>
  563. // <tr>
  564. // <td><code>phone_call</code></td>
  565. // <td>Best for audio that originated from a phone call (typically
  566. // recorded at an 8khz sampling rate).</td>
  567. // </tr>
  568. // <tr>
  569. // <td><code>video</code></td>
  570. // <td>Best for audio that originated from from video or includes
  571. // multiple
  572. // speakers. Ideally the audio is recorded at a 16khz or
  573. // greater
  574. // sampling rate. This is a premium model that costs more than
  575. // the
  576. // standard rate.</td>
  577. // </tr>
  578. // <tr>
  579. // <td><code>default</code></td>
  580. // <td>Best for audio that is not one of the specific audio models.
  581. // For example, long-form audio. Ideally the audio is
  582. // high-fidelity,
  583. // recorded at a 16khz or greater sampling rate.</td>
  584. // </tr>
  585. // </table>
  586. Model string `json:"model,omitempty"`
  587. // ProfanityFilter: *Optional* If set to `true`, the server will attempt
  588. // to filter out
  589. // profanities, replacing all but the initial character in each filtered
  590. // word
  591. // with asterisks, e.g. "f***". If set to `false` or omitted,
  592. // profanities
  593. // won't be filtered out.
  594. ProfanityFilter bool `json:"profanityFilter,omitempty"`
  595. // SampleRateHertz: Sample rate in Hertz of the audio data sent in
  596. // all
  597. // `RecognitionAudio` messages. Valid values are: 8000-48000.
  598. // 16000 is optimal. For best results, set the sampling rate of the
  599. // audio
  600. // source to 16000 Hz. If that's not possible, use the native sample
  601. // rate of
  602. // the audio source (instead of re-sampling).
  603. // This field is optional for `FLAC`, `WAV`. and 'MP3' audio files, and
  604. // is
  605. // required for all other audio formats. For details, see AudioEncoding.
  606. SampleRateHertz int64 `json:"sampleRateHertz,omitempty"`
  607. // SpeechContexts: *Optional* array of SpeechContext.
  608. // A means to provide context to assist the speech recognition. For
  609. // more
  610. // information, see [Phrase
  611. // Hints](/speech-to-text/docs/basics#phrase-hints).
  612. SpeechContexts []*SpeechContext `json:"speechContexts,omitempty"`
  613. // UseEnhanced: *Optional* Set to true to use an enhanced model for
  614. // speech recognition.
  615. // If `use_enhanced` is set to true and the `model` field is not set,
  616. // then
  617. // an appropriate enhanced model is chosen if:
  618. // 1. project is eligible for requesting enhanced models
  619. // 2. an enhanced model exists for the audio
  620. //
  621. // If `use_enhanced` is true and an enhanced version of the specified
  622. // model
  623. // does not exist, then the speech is recognized using the standard
  624. // version
  625. // of the specified model.
  626. //
  627. // Enhanced speech models require that you opt-in to data logging
  628. // using
  629. // instructions in
  630. // the
  631. // [documentation](/speech-to-text/docs/enable-data-logging). If you
  632. // set
  633. // `use_enhanced` to true and you have not enabled audio logging, then
  634. // you
  635. // will receive an error.
  636. UseEnhanced bool `json:"useEnhanced,omitempty"`
  637. // ForceSendFields is a list of field names (e.g. "AudioChannelCount")
  638. // to unconditionally include in API requests. By default, fields with
  639. // empty values are omitted from API requests. However, any non-pointer,
  640. // non-interface field appearing in ForceSendFields will be sent to the
  641. // server regardless of whether the field is empty or not. This may be
  642. // used to include empty fields in Patch requests.
  643. ForceSendFields []string `json:"-"`
  644. // NullFields is a list of field names (e.g. "AudioChannelCount") to
  645. // include in API requests with the JSON null value. By default, fields
  646. // with empty values are omitted from API requests. However, any field
  647. // with an empty value appearing in NullFields will be sent to the
  648. // server as null. It is an error if a field in this list has a
  649. // non-empty value. This may be used to include null fields in Patch
  650. // requests.
  651. NullFields []string `json:"-"`
  652. }
  653. func (s *RecognitionConfig) MarshalJSON() ([]byte, error) {
  654. type NoMethod RecognitionConfig
  655. raw := NoMethod(*s)
  656. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  657. }
  658. // RecognitionMetadata: Description of audio data to be recognized.
  659. type RecognitionMetadata struct {
  660. // AudioTopic: Description of the content. Eg. "Recordings of federal
  661. // supreme court
  662. // hearings from 2012".
  663. AudioTopic string `json:"audioTopic,omitempty"`
  664. // IndustryNaicsCodeOfAudio: The industry vertical to which this speech
  665. // recognition request most
  666. // closely applies. This is most indicative of the topics contained
  667. // in the audio. Use the 6-digit NAICS code to identify the
  668. // industry
  669. // vertical - see https://www.naics.com/search/.
  670. IndustryNaicsCodeOfAudio int64 `json:"industryNaicsCodeOfAudio,omitempty"`
  671. // InteractionType: The use case most closely describing the audio
  672. // content to be recognized.
  673. //
  674. // Possible values:
  675. // "INTERACTION_TYPE_UNSPECIFIED" - Use case is either unknown or is
  676. // something other than one of the other
  677. // values below.
  678. // "DISCUSSION" - Multiple people in a conversation or discussion. For
  679. // example in a
  680. // meeting with two or more people actively participating. Typically
  681. // all the primary people speaking would be in the same room (if
  682. // not,
  683. // see PHONE_CALL)
  684. // "PRESENTATION" - One or more persons lecturing or presenting to
  685. // others, mostly
  686. // uninterrupted.
  687. // "PHONE_CALL" - A phone-call or video-conference in which two or
  688. // more people, who are
  689. // not in the same room, are actively participating.
  690. // "VOICEMAIL" - A recorded message intended for another person to
  691. // listen to.
  692. // "PROFESSIONALLY_PRODUCED" - Professionally produced audio (eg. TV
  693. // Show, Podcast).
  694. // "VOICE_SEARCH" - Transcribe spoken questions and queries into text.
  695. // "VOICE_COMMAND" - Transcribe voice commands, such as for
  696. // controlling a device.
  697. // "DICTATION" - Transcribe speech to text to create a written
  698. // document, such as a
  699. // text-message, email or report.
  700. InteractionType string `json:"interactionType,omitempty"`
  701. // MicrophoneDistance: The audio type that most closely describes the
  702. // audio being recognized.
  703. //
  704. // Possible values:
  705. // "MICROPHONE_DISTANCE_UNSPECIFIED" - Audio type is not known.
  706. // "NEARFIELD" - The audio was captured from a closely placed
  707. // microphone. Eg. phone,
  708. // dictaphone, or handheld microphone. Generally if there speaker is
  709. // within
  710. // 1 meter of the microphone.
  711. // "MIDFIELD" - The speaker if within 3 meters of the microphone.
  712. // "FARFIELD" - The speaker is more than 3 meters away from the
  713. // microphone.
  714. MicrophoneDistance string `json:"microphoneDistance,omitempty"`
  715. // ObfuscatedId: Obfuscated (privacy-protected) ID of the user, to
  716. // identify number of
  717. // unique users using the service.
  718. ObfuscatedId int64 `json:"obfuscatedId,omitempty,string"`
  719. // OriginalMediaType: The original media the speech was recorded on.
  720. //
  721. // Possible values:
  722. // "ORIGINAL_MEDIA_TYPE_UNSPECIFIED" - Unknown original media type.
  723. // "AUDIO" - The speech data is an audio recording.
  724. // "VIDEO" - The speech data originally recorded on a video.
  725. OriginalMediaType string `json:"originalMediaType,omitempty"`
  726. // OriginalMimeType: Mime type of the original audio file. For example
  727. // `audio/m4a`,
  728. // `audio/x-alaw-basic`, `audio/mp3`, `audio/3gpp`.
  729. // A list of possible audio mime types is maintained
  730. // at
  731. // http://www.iana.org/assignments/media-types/media-types.xhtml#audio
  732. OriginalMimeType string `json:"originalMimeType,omitempty"`
  733. // RecordingDeviceName: The device used to make the recording. Examples
  734. // 'Nexus 5X' or
  735. // 'Polycom SoundStation IP 6000' or 'POTS' or 'VoIP' or
  736. // 'Cardioid Microphone'.
  737. RecordingDeviceName string `json:"recordingDeviceName,omitempty"`
  738. // RecordingDeviceType: The type of device the speech was recorded with.
  739. //
  740. // Possible values:
  741. // "RECORDING_DEVICE_TYPE_UNSPECIFIED" - The recording device is
  742. // unknown.
  743. // "SMARTPHONE" - Speech was recorded on a smartphone.
  744. // "PC" - Speech was recorded using a personal computer or tablet.
  745. // "PHONE_LINE" - Speech was recorded over a phone line.
  746. // "VEHICLE" - Speech was recorded in a vehicle.
  747. // "OTHER_OUTDOOR_DEVICE" - Speech was recorded outdoors.
  748. // "OTHER_INDOOR_DEVICE" - Speech was recorded indoors.
  749. RecordingDeviceType string `json:"recordingDeviceType,omitempty"`
  750. // ForceSendFields is a list of field names (e.g. "AudioTopic") to
  751. // unconditionally include in API requests. By default, fields with
  752. // empty values are omitted from API requests. However, any non-pointer,
  753. // non-interface field appearing in ForceSendFields will be sent to the
  754. // server regardless of whether the field is empty or not. This may be
  755. // used to include empty fields in Patch requests.
  756. ForceSendFields []string `json:"-"`
  757. // NullFields is a list of field names (e.g. "AudioTopic") to include in
  758. // API requests with the JSON null value. By default, fields with empty
  759. // values are omitted from API requests. However, any field with an
  760. // empty value appearing in NullFields will be sent to the server as
  761. // null. It is an error if a field in this list has a non-empty value.
  762. // This may be used to include null fields in Patch requests.
  763. NullFields []string `json:"-"`
  764. }
  765. func (s *RecognitionMetadata) MarshalJSON() ([]byte, error) {
  766. type NoMethod RecognitionMetadata
  767. raw := NoMethod(*s)
  768. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  769. }
  770. // RecognizeRequest: The top-level message sent by the client for the
  771. // `Recognize` method.
  772. type RecognizeRequest struct {
  773. // Audio: *Required* The audio data to be recognized.
  774. Audio *RecognitionAudio `json:"audio,omitempty"`
  775. // Config: *Required* Provides information to the recognizer that
  776. // specifies how to
  777. // process the request.
  778. Config *RecognitionConfig `json:"config,omitempty"`
  779. // ForceSendFields is a list of field names (e.g. "Audio") to
  780. // unconditionally include in API requests. By default, fields with
  781. // empty values are omitted from API requests. However, any non-pointer,
  782. // non-interface field appearing in ForceSendFields will be sent to the
  783. // server regardless of whether the field is empty or not. This may be
  784. // used to include empty fields in Patch requests.
  785. ForceSendFields []string `json:"-"`
  786. // NullFields is a list of field names (e.g. "Audio") to include in API
  787. // requests with the JSON null value. By default, fields with empty
  788. // values are omitted from API requests. However, any field with an
  789. // empty value appearing in NullFields will be sent to the server as
  790. // null. It is an error if a field in this list has a non-empty value.
  791. // This may be used to include null fields in Patch requests.
  792. NullFields []string `json:"-"`
  793. }
  794. func (s *RecognizeRequest) MarshalJSON() ([]byte, error) {
  795. type NoMethod RecognizeRequest
  796. raw := NoMethod(*s)
  797. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  798. }
  799. // RecognizeResponse: The only message returned to the client by the
  800. // `Recognize` method. It
  801. // contains the result as zero or more sequential
  802. // `SpeechRecognitionResult`
  803. // messages.
  804. type RecognizeResponse struct {
  805. // Results: Output only. Sequential list of transcription results
  806. // corresponding to
  807. // sequential portions of audio.
  808. Results []*SpeechRecognitionResult `json:"results,omitempty"`
  809. // ServerResponse contains the HTTP response code and headers from the
  810. // server.
  811. googleapi.ServerResponse `json:"-"`
  812. // ForceSendFields is a list of field names (e.g. "Results") to
  813. // unconditionally include in API requests. By default, fields with
  814. // empty values are omitted from API requests. However, any non-pointer,
  815. // non-interface field appearing in ForceSendFields will be sent to the
  816. // server regardless of whether the field is empty or not. This may be
  817. // used to include empty fields in Patch requests.
  818. ForceSendFields []string `json:"-"`
  819. // NullFields is a list of field names (e.g. "Results") to include in
  820. // API requests with the JSON null value. By default, fields with empty
  821. // values are omitted from API requests. However, any field with an
  822. // empty value appearing in NullFields will be sent to the server as
  823. // null. It is an error if a field in this list has a non-empty value.
  824. // This may be used to include null fields in Patch requests.
  825. NullFields []string `json:"-"`
  826. }
  827. func (s *RecognizeResponse) MarshalJSON() ([]byte, error) {
  828. type NoMethod RecognizeResponse
  829. raw := NoMethod(*s)
  830. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  831. }
  832. // SpeechContext: Provides "hints" to the speech recognizer to favor
  833. // specific words and phrases
  834. // in the results.
  835. type SpeechContext struct {
  836. // Phrases: *Optional* A list of strings containing words and phrases
  837. // "hints" so that
  838. // the speech recognition is more likely to recognize them. This can be
  839. // used
  840. // to improve the accuracy for specific words and phrases, for example,
  841. // if
  842. // specific commands are typically spoken by the user. This can also be
  843. // used
  844. // to add additional words to the vocabulary of the recognizer.
  845. // See
  846. // [usage limits](/speech-to-text/quotas#content).
  847. Phrases []string `json:"phrases,omitempty"`
  848. // ForceSendFields is a list of field names (e.g. "Phrases") to
  849. // unconditionally include in API requests. By default, fields with
  850. // empty values are omitted from API requests. However, any non-pointer,
  851. // non-interface field appearing in ForceSendFields will be sent to the
  852. // server regardless of whether the field is empty or not. This may be
  853. // used to include empty fields in Patch requests.
  854. ForceSendFields []string `json:"-"`
  855. // NullFields is a list of field names (e.g. "Phrases") to include in
  856. // API requests with the JSON null value. By default, fields with empty
  857. // values are omitted from API requests. However, any field with an
  858. // empty value appearing in NullFields will be sent to the server as
  859. // null. It is an error if a field in this list has a non-empty value.
  860. // This may be used to include null fields in Patch requests.
  861. NullFields []string `json:"-"`
  862. }
  863. func (s *SpeechContext) MarshalJSON() ([]byte, error) {
  864. type NoMethod SpeechContext
  865. raw := NoMethod(*s)
  866. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  867. }
  868. // SpeechRecognitionAlternative: Alternative hypotheses (a.k.a. n-best
  869. // list).
  870. type SpeechRecognitionAlternative struct {
  871. // Confidence: Output only. The confidence estimate between 0.0 and 1.0.
  872. // A higher number
  873. // indicates an estimated greater likelihood that the recognized words
  874. // are
  875. // correct. This field is set only for the top alternative of a
  876. // non-streaming
  877. // result or, of a streaming result where `is_final=true`.
  878. // This field is not guaranteed to be accurate and users should not rely
  879. // on it
  880. // to be always provided.
  881. // The default of 0.0 is a sentinel value indicating `confidence` was
  882. // not set.
  883. Confidence float64 `json:"confidence,omitempty"`
  884. // Transcript: Output only. Transcript text representing the words that
  885. // the user spoke.
  886. Transcript string `json:"transcript,omitempty"`
  887. // Words: Output only. A list of word-specific information for each
  888. // recognized word.
  889. // Note: When `enable_speaker_diarization` is true, you will see all the
  890. // words
  891. // from the beginning of the audio.
  892. Words []*WordInfo `json:"words,omitempty"`
  893. // ForceSendFields is a list of field names (e.g. "Confidence") to
  894. // unconditionally include in API requests. By default, fields with
  895. // empty values are omitted from API requests. However, any non-pointer,
  896. // non-interface field appearing in ForceSendFields will be sent to the
  897. // server regardless of whether the field is empty or not. This may be
  898. // used to include empty fields in Patch requests.
  899. ForceSendFields []string `json:"-"`
  900. // NullFields is a list of field names (e.g. "Confidence") to include in
  901. // API requests with the JSON null value. By default, fields with empty
  902. // values are omitted from API requests. However, any field with an
  903. // empty value appearing in NullFields will be sent to the server as
  904. // null. It is an error if a field in this list has a non-empty value.
  905. // This may be used to include null fields in Patch requests.
  906. NullFields []string `json:"-"`
  907. }
  908. func (s *SpeechRecognitionAlternative) MarshalJSON() ([]byte, error) {
  909. type NoMethod SpeechRecognitionAlternative
  910. raw := NoMethod(*s)
  911. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  912. }
  913. func (s *SpeechRecognitionAlternative) UnmarshalJSON(data []byte) error {
  914. type NoMethod SpeechRecognitionAlternative
  915. var s1 struct {
  916. Confidence gensupport.JSONFloat64 `json:"confidence"`
  917. *NoMethod
  918. }
  919. s1.NoMethod = (*NoMethod)(s)
  920. if err := json.Unmarshal(data, &s1); err != nil {
  921. return err
  922. }
  923. s.Confidence = float64(s1.Confidence)
  924. return nil
  925. }
  926. // SpeechRecognitionResult: A speech recognition result corresponding to
  927. // a portion of the audio.
  928. type SpeechRecognitionResult struct {
  929. // Alternatives: Output only. May contain one or more recognition
  930. // hypotheses (up to the
  931. // maximum specified in `max_alternatives`).
  932. // These alternatives are ordered in terms of accuracy, with the top
  933. // (first)
  934. // alternative being the most probable, as ranked by the recognizer.
  935. Alternatives []*SpeechRecognitionAlternative `json:"alternatives,omitempty"`
  936. // ChannelTag: For multi-channel audio, this is the channel number
  937. // corresponding to the
  938. // recognized result for the audio from that channel.
  939. // For audio_channel_count = N, its output values can range from '1' to
  940. // 'N'.
  941. ChannelTag int64 `json:"channelTag,omitempty"`
  942. // ForceSendFields is a list of field names (e.g. "Alternatives") to
  943. // unconditionally include in API requests. By default, fields with
  944. // empty values are omitted from API requests. However, any non-pointer,
  945. // non-interface field appearing in ForceSendFields will be sent to the
  946. // server regardless of whether the field is empty or not. This may be
  947. // used to include empty fields in Patch requests.
  948. ForceSendFields []string `json:"-"`
  949. // NullFields is a list of field names (e.g. "Alternatives") to include
  950. // in API requests with the JSON null value. By default, fields with
  951. // empty values are omitted from API requests. However, any field with
  952. // an empty value appearing in NullFields will be sent to the server as
  953. // null. It is an error if a field in this list has a non-empty value.
  954. // This may be used to include null fields in Patch requests.
  955. NullFields []string `json:"-"`
  956. }
  957. func (s *SpeechRecognitionResult) MarshalJSON() ([]byte, error) {
  958. type NoMethod SpeechRecognitionResult
  959. raw := NoMethod(*s)
  960. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  961. }
  962. // Status: The `Status` type defines a logical error model that is
  963. // suitable for
  964. // different programming environments, including REST APIs and RPC APIs.
  965. // It is
  966. // used by [gRPC](https://github.com/grpc). The error model is designed
  967. // to be:
  968. //
  969. // - Simple to use and understand for most users
  970. // - Flexible enough to meet unexpected needs
  971. //
  972. // # Overview
  973. //
  974. // The `Status` message contains three pieces of data: error code,
  975. // error
  976. // message, and error details. The error code should be an enum value
  977. // of
  978. // google.rpc.Code, but it may accept additional error codes if needed.
  979. // The
  980. // error message should be a developer-facing English message that
  981. // helps
  982. // developers *understand* and *resolve* the error. If a localized
  983. // user-facing
  984. // error message is needed, put the localized message in the error
  985. // details or
  986. // localize it in the client. The optional error details may contain
  987. // arbitrary
  988. // information about the error. There is a predefined set of error
  989. // detail types
  990. // in the package `google.rpc` that can be used for common error
  991. // conditions.
  992. //
  993. // # Language mapping
  994. //
  995. // The `Status` message is the logical representation of the error
  996. // model, but it
  997. // is not necessarily the actual wire format. When the `Status` message
  998. // is
  999. // exposed in different client libraries and different wire protocols,
  1000. // it can be
  1001. // mapped differently. For example, it will likely be mapped to some
  1002. // exceptions
  1003. // in Java, but more likely mapped to some error codes in C.
  1004. //
  1005. // # Other uses
  1006. //
  1007. // The error model and the `Status` message can be used in a variety
  1008. // of
  1009. // environments, either with or without APIs, to provide a
  1010. // consistent developer experience across different
  1011. // environments.
  1012. //
  1013. // Example uses of this error model include:
  1014. //
  1015. // - Partial errors. If a service needs to return partial errors to the
  1016. // client,
  1017. // it may embed the `Status` in the normal response to indicate the
  1018. // partial
  1019. // errors.
  1020. //
  1021. // - Workflow errors. A typical workflow has multiple steps. Each step
  1022. // may
  1023. // have a `Status` message for error reporting.
  1024. //
  1025. // - Batch operations. If a client uses batch request and batch
  1026. // response, the
  1027. // `Status` message should be used directly inside batch response,
  1028. // one for
  1029. // each error sub-response.
  1030. //
  1031. // - Asynchronous operations. If an API call embeds asynchronous
  1032. // operation
  1033. // results in its response, the status of those operations should
  1034. // be
  1035. // represented directly using the `Status` message.
  1036. //
  1037. // - Logging. If some API errors are stored in logs, the message
  1038. // `Status` could
  1039. // be used directly after any stripping needed for security/privacy
  1040. // reasons.
  1041. type Status struct {
  1042. // Code: The status code, which should be an enum value of
  1043. // google.rpc.Code.
  1044. Code int64 `json:"code,omitempty"`
  1045. // Details: A list of messages that carry the error details. There is a
  1046. // common set of
  1047. // message types for APIs to use.
  1048. Details []googleapi.RawMessage `json:"details,omitempty"`
  1049. // Message: A developer-facing error message, which should be in
  1050. // English. Any
  1051. // user-facing error message should be localized and sent in
  1052. // the
  1053. // google.rpc.Status.details field, or localized by the client.
  1054. Message string `json:"message,omitempty"`
  1055. // ForceSendFields is a list of field names (e.g. "Code") 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. "Code") to include in API
  1063. // requests with the JSON null value. By default, fields with empty
  1064. // values are omitted from API requests. However, any field with an
  1065. // 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 *Status) MarshalJSON() ([]byte, error) {
  1071. type NoMethod Status
  1072. raw := NoMethod(*s)
  1073. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1074. }
  1075. // WordInfo: Word-specific information for recognized words.
  1076. type WordInfo struct {
  1077. // EndTime: Output only. Time offset relative to the beginning of the
  1078. // audio,
  1079. // and corresponding to the end of the spoken word.
  1080. // This field is only set if `enable_word_time_offsets=true` and only
  1081. // in the top hypothesis.
  1082. // This is an experimental feature and the accuracy of the time offset
  1083. // can
  1084. // vary.
  1085. EndTime string `json:"endTime,omitempty"`
  1086. // StartTime: Output only. Time offset relative to the beginning of the
  1087. // audio,
  1088. // and corresponding to the start of the spoken word.
  1089. // This field is only set if `enable_word_time_offsets=true` and only
  1090. // in the top hypothesis.
  1091. // This is an experimental feature and the accuracy of the time offset
  1092. // can
  1093. // vary.
  1094. StartTime string `json:"startTime,omitempty"`
  1095. // Word: Output only. The word corresponding to this set of information.
  1096. Word string `json:"word,omitempty"`
  1097. // ForceSendFields is a list of field names (e.g. "EndTime") to
  1098. // unconditionally include in API requests. By default, fields with
  1099. // empty values are omitted from API requests. However, any non-pointer,
  1100. // non-interface field appearing in ForceSendFields will be sent to the
  1101. // server regardless of whether the field is empty or not. This may be
  1102. // used to include empty fields in Patch requests.
  1103. ForceSendFields []string `json:"-"`
  1104. // NullFields is a list of field names (e.g. "EndTime") to include in
  1105. // API requests with the JSON null value. By default, fields with empty
  1106. // values are omitted from API requests. However, any field with an
  1107. // empty value appearing in NullFields will be sent to the server as
  1108. // null. It is an error if a field in this list has a non-empty value.
  1109. // This may be used to include null fields in Patch requests.
  1110. NullFields []string `json:"-"`
  1111. }
  1112. func (s *WordInfo) MarshalJSON() ([]byte, error) {
  1113. type NoMethod WordInfo
  1114. raw := NoMethod(*s)
  1115. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1116. }
  1117. // method id "speech.operations.get":
  1118. type OperationsGetCall struct {
  1119. s *Service
  1120. name string
  1121. urlParams_ gensupport.URLParams
  1122. ifNoneMatch_ string
  1123. ctx_ context.Context
  1124. header_ http.Header
  1125. }
  1126. // Get: Gets the latest state of a long-running operation. Clients can
  1127. // use this
  1128. // method to poll the operation result at intervals as recommended by
  1129. // the API
  1130. // service.
  1131. func (r *OperationsService) Get(name string) *OperationsGetCall {
  1132. c := &OperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1133. c.name = name
  1134. return c
  1135. }
  1136. // Fields allows partial responses to be retrieved. See
  1137. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1138. // for more information.
  1139. func (c *OperationsGetCall) Fields(s ...googleapi.Field) *OperationsGetCall {
  1140. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1141. return c
  1142. }
  1143. // IfNoneMatch sets the optional parameter which makes the operation
  1144. // fail if the object's ETag matches the given value. This is useful for
  1145. // getting updates only after the object has changed since the last
  1146. // request. Use googleapi.IsNotModified to check whether the response
  1147. // error from Do is the result of In-None-Match.
  1148. func (c *OperationsGetCall) IfNoneMatch(entityTag string) *OperationsGetCall {
  1149. c.ifNoneMatch_ = entityTag
  1150. return c
  1151. }
  1152. // Context sets the context to be used in this call's Do method. Any
  1153. // pending HTTP request will be aborted if the provided context is
  1154. // canceled.
  1155. func (c *OperationsGetCall) Context(ctx context.Context) *OperationsGetCall {
  1156. c.ctx_ = ctx
  1157. return c
  1158. }
  1159. // Header returns an http.Header that can be modified by the caller to
  1160. // add HTTP headers to the request.
  1161. func (c *OperationsGetCall) Header() http.Header {
  1162. if c.header_ == nil {
  1163. c.header_ = make(http.Header)
  1164. }
  1165. return c.header_
  1166. }
  1167. func (c *OperationsGetCall) doRequest(alt string) (*http.Response, error) {
  1168. reqHeaders := make(http.Header)
  1169. for k, v := range c.header_ {
  1170. reqHeaders[k] = v
  1171. }
  1172. reqHeaders.Set("User-Agent", c.s.userAgent())
  1173. if c.ifNoneMatch_ != "" {
  1174. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1175. }
  1176. var body io.Reader = nil
  1177. c.urlParams_.Set("alt", alt)
  1178. c.urlParams_.Set("prettyPrint", "false")
  1179. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/operations/{+name}")
  1180. urls += "?" + c.urlParams_.Encode()
  1181. req, err := http.NewRequest("GET", urls, body)
  1182. if err != nil {
  1183. return nil, err
  1184. }
  1185. req.Header = reqHeaders
  1186. googleapi.Expand(req.URL, map[string]string{
  1187. "name": c.name,
  1188. })
  1189. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1190. }
  1191. // Do executes the "speech.operations.get" call.
  1192. // Exactly one of *Operation or error will be non-nil. Any non-2xx
  1193. // status code is an error. Response headers are in either
  1194. // *Operation.ServerResponse.Header or (if a response was returned at
  1195. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1196. // to check whether the returned error was because
  1197. // http.StatusNotModified was returned.
  1198. func (c *OperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
  1199. gensupport.SetOptions(c.urlParams_, opts...)
  1200. res, err := c.doRequest("json")
  1201. if res != nil && res.StatusCode == http.StatusNotModified {
  1202. if res.Body != nil {
  1203. res.Body.Close()
  1204. }
  1205. return nil, &googleapi.Error{
  1206. Code: res.StatusCode,
  1207. Header: res.Header,
  1208. }
  1209. }
  1210. if err != nil {
  1211. return nil, err
  1212. }
  1213. defer googleapi.CloseBody(res)
  1214. if err := googleapi.CheckResponse(res); err != nil {
  1215. return nil, err
  1216. }
  1217. ret := &Operation{
  1218. ServerResponse: googleapi.ServerResponse{
  1219. Header: res.Header,
  1220. HTTPStatusCode: res.StatusCode,
  1221. },
  1222. }
  1223. target := &ret
  1224. if err := gensupport.DecodeResponse(target, res); err != nil {
  1225. return nil, err
  1226. }
  1227. return ret, nil
  1228. // {
  1229. // "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.",
  1230. // "flatPath": "v1/operations/{operationsId}",
  1231. // "httpMethod": "GET",
  1232. // "id": "speech.operations.get",
  1233. // "parameterOrder": [
  1234. // "name"
  1235. // ],
  1236. // "parameters": {
  1237. // "name": {
  1238. // "description": "The name of the operation resource.",
  1239. // "location": "path",
  1240. // "pattern": "^.+$",
  1241. // "required": true,
  1242. // "type": "string"
  1243. // }
  1244. // },
  1245. // "path": "v1/operations/{+name}",
  1246. // "response": {
  1247. // "$ref": "Operation"
  1248. // },
  1249. // "scopes": [
  1250. // "https://www.googleapis.com/auth/cloud-platform"
  1251. // ]
  1252. // }
  1253. }
  1254. // method id "speech.operations.list":
  1255. type OperationsListCall struct {
  1256. s *Service
  1257. urlParams_ gensupport.URLParams
  1258. ifNoneMatch_ string
  1259. ctx_ context.Context
  1260. header_ http.Header
  1261. }
  1262. // List: Lists operations that match the specified filter in the
  1263. // request. If the
  1264. // server doesn't support this method, it returns
  1265. // `UNIMPLEMENTED`.
  1266. //
  1267. // NOTE: the `name` binding allows API services to override the
  1268. // binding
  1269. // to use different resource name schemes, such as `users/*/operations`.
  1270. // To
  1271. // override the binding, API services can add a binding such
  1272. // as
  1273. // "/v1/{name=users/*}/operations" to their service configuration.
  1274. // For backwards compatibility, the default name includes the
  1275. // operations
  1276. // collection id, however overriding users must ensure the name
  1277. // binding
  1278. // is the parent resource, without the operations collection id.
  1279. func (r *OperationsService) List() *OperationsListCall {
  1280. c := &OperationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1281. return c
  1282. }
  1283. // Filter sets the optional parameter "filter": The standard list
  1284. // filter.
  1285. func (c *OperationsListCall) Filter(filter string) *OperationsListCall {
  1286. c.urlParams_.Set("filter", filter)
  1287. return c
  1288. }
  1289. // Name sets the optional parameter "name": The name of the operation's
  1290. // parent resource.
  1291. func (c *OperationsListCall) Name(name string) *OperationsListCall {
  1292. c.urlParams_.Set("name", name)
  1293. return c
  1294. }
  1295. // PageSize sets the optional parameter "pageSize": The standard list
  1296. // page size.
  1297. func (c *OperationsListCall) PageSize(pageSize int64) *OperationsListCall {
  1298. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  1299. return c
  1300. }
  1301. // PageToken sets the optional parameter "pageToken": The standard list
  1302. // page token.
  1303. func (c *OperationsListCall) PageToken(pageToken string) *OperationsListCall {
  1304. c.urlParams_.Set("pageToken", pageToken)
  1305. return c
  1306. }
  1307. // Fields allows partial responses to be retrieved. See
  1308. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1309. // for more information.
  1310. func (c *OperationsListCall) Fields(s ...googleapi.Field) *OperationsListCall {
  1311. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1312. return c
  1313. }
  1314. // IfNoneMatch sets the optional parameter which makes the operation
  1315. // fail if the object's ETag matches the given value. This is useful for
  1316. // getting updates only after the object has changed since the last
  1317. // request. Use googleapi.IsNotModified to check whether the response
  1318. // error from Do is the result of In-None-Match.
  1319. func (c *OperationsListCall) IfNoneMatch(entityTag string) *OperationsListCall {
  1320. c.ifNoneMatch_ = entityTag
  1321. return c
  1322. }
  1323. // Context sets the context to be used in this call's Do method. Any
  1324. // pending HTTP request will be aborted if the provided context is
  1325. // canceled.
  1326. func (c *OperationsListCall) Context(ctx context.Context) *OperationsListCall {
  1327. c.ctx_ = ctx
  1328. return c
  1329. }
  1330. // Header returns an http.Header that can be modified by the caller to
  1331. // add HTTP headers to the request.
  1332. func (c *OperationsListCall) Header() http.Header {
  1333. if c.header_ == nil {
  1334. c.header_ = make(http.Header)
  1335. }
  1336. return c.header_
  1337. }
  1338. func (c *OperationsListCall) doRequest(alt string) (*http.Response, error) {
  1339. reqHeaders := make(http.Header)
  1340. for k, v := range c.header_ {
  1341. reqHeaders[k] = v
  1342. }
  1343. reqHeaders.Set("User-Agent", c.s.userAgent())
  1344. if c.ifNoneMatch_ != "" {
  1345. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1346. }
  1347. var body io.Reader = nil
  1348. c.urlParams_.Set("alt", alt)
  1349. c.urlParams_.Set("prettyPrint", "false")
  1350. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/operations")
  1351. urls += "?" + c.urlParams_.Encode()
  1352. req, err := http.NewRequest("GET", urls, body)
  1353. if err != nil {
  1354. return nil, err
  1355. }
  1356. req.Header = reqHeaders
  1357. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1358. }
  1359. // Do executes the "speech.operations.list" call.
  1360. // Exactly one of *ListOperationsResponse or error will be non-nil. Any
  1361. // non-2xx status code is an error. Response headers are in either
  1362. // *ListOperationsResponse.ServerResponse.Header or (if a response was
  1363. // returned at all) in error.(*googleapi.Error).Header. Use
  1364. // googleapi.IsNotModified to check whether the returned error was
  1365. // because http.StatusNotModified was returned.
  1366. func (c *OperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsResponse, error) {
  1367. gensupport.SetOptions(c.urlParams_, opts...)
  1368. res, err := c.doRequest("json")
  1369. if res != nil && res.StatusCode == http.StatusNotModified {
  1370. if res.Body != nil {
  1371. res.Body.Close()
  1372. }
  1373. return nil, &googleapi.Error{
  1374. Code: res.StatusCode,
  1375. Header: res.Header,
  1376. }
  1377. }
  1378. if err != nil {
  1379. return nil, err
  1380. }
  1381. defer googleapi.CloseBody(res)
  1382. if err := googleapi.CheckResponse(res); err != nil {
  1383. return nil, err
  1384. }
  1385. ret := &ListOperationsResponse{
  1386. ServerResponse: googleapi.ServerResponse{
  1387. Header: res.Header,
  1388. HTTPStatusCode: res.StatusCode,
  1389. },
  1390. }
  1391. target := &ret
  1392. if err := gensupport.DecodeResponse(target, res); err != nil {
  1393. return nil, err
  1394. }
  1395. return ret, nil
  1396. // {
  1397. // "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.",
  1398. // "flatPath": "v1/operations",
  1399. // "httpMethod": "GET",
  1400. // "id": "speech.operations.list",
  1401. // "parameterOrder": [],
  1402. // "parameters": {
  1403. // "filter": {
  1404. // "description": "The standard list filter.",
  1405. // "location": "query",
  1406. // "type": "string"
  1407. // },
  1408. // "name": {
  1409. // "description": "The name of the operation's parent resource.",
  1410. // "location": "query",
  1411. // "type": "string"
  1412. // },
  1413. // "pageSize": {
  1414. // "description": "The standard list page size.",
  1415. // "format": "int32",
  1416. // "location": "query",
  1417. // "type": "integer"
  1418. // },
  1419. // "pageToken": {
  1420. // "description": "The standard list page token.",
  1421. // "location": "query",
  1422. // "type": "string"
  1423. // }
  1424. // },
  1425. // "path": "v1/operations",
  1426. // "response": {
  1427. // "$ref": "ListOperationsResponse"
  1428. // },
  1429. // "scopes": [
  1430. // "https://www.googleapis.com/auth/cloud-platform"
  1431. // ]
  1432. // }
  1433. }
  1434. // Pages invokes f for each page of results.
  1435. // A non-nil error returned from f will halt the iteration.
  1436. // The provided context supersedes any context provided to the Context method.
  1437. func (c *OperationsListCall) Pages(ctx context.Context, f func(*ListOperationsResponse) error) error {
  1438. c.ctx_ = ctx
  1439. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1440. for {
  1441. x, err := c.Do()
  1442. if err != nil {
  1443. return err
  1444. }
  1445. if err := f(x); err != nil {
  1446. return err
  1447. }
  1448. if x.NextPageToken == "" {
  1449. return nil
  1450. }
  1451. c.PageToken(x.NextPageToken)
  1452. }
  1453. }
  1454. // method id "speech.projects.locations.operations.get":
  1455. type ProjectsLocationsOperationsGetCall struct {
  1456. s *Service
  1457. name string
  1458. urlParams_ gensupport.URLParams
  1459. ifNoneMatch_ string
  1460. ctx_ context.Context
  1461. header_ http.Header
  1462. }
  1463. // Get: Gets the latest state of a long-running operation. Clients can
  1464. // use this
  1465. // method to poll the operation result at intervals as recommended by
  1466. // the API
  1467. // service.
  1468. func (r *ProjectsLocationsOperationsService) Get(name string) *ProjectsLocationsOperationsGetCall {
  1469. c := &ProjectsLocationsOperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1470. c.name = name
  1471. return c
  1472. }
  1473. // Fields allows partial responses to be retrieved. See
  1474. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1475. // for more information.
  1476. func (c *ProjectsLocationsOperationsGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsOperationsGetCall {
  1477. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1478. return c
  1479. }
  1480. // IfNoneMatch sets the optional parameter which makes the operation
  1481. // fail if the object's ETag matches the given value. This is useful for
  1482. // getting updates only after the object has changed since the last
  1483. // request. Use googleapi.IsNotModified to check whether the response
  1484. // error from Do is the result of In-None-Match.
  1485. func (c *ProjectsLocationsOperationsGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsOperationsGetCall {
  1486. c.ifNoneMatch_ = entityTag
  1487. return c
  1488. }
  1489. // Context sets the context to be used in this call's Do method. Any
  1490. // pending HTTP request will be aborted if the provided context is
  1491. // canceled.
  1492. func (c *ProjectsLocationsOperationsGetCall) Context(ctx context.Context) *ProjectsLocationsOperationsGetCall {
  1493. c.ctx_ = ctx
  1494. return c
  1495. }
  1496. // Header returns an http.Header that can be modified by the caller to
  1497. // add HTTP headers to the request.
  1498. func (c *ProjectsLocationsOperationsGetCall) Header() http.Header {
  1499. if c.header_ == nil {
  1500. c.header_ = make(http.Header)
  1501. }
  1502. return c.header_
  1503. }
  1504. func (c *ProjectsLocationsOperationsGetCall) doRequest(alt string) (*http.Response, error) {
  1505. reqHeaders := make(http.Header)
  1506. for k, v := range c.header_ {
  1507. reqHeaders[k] = v
  1508. }
  1509. reqHeaders.Set("User-Agent", c.s.userAgent())
  1510. if c.ifNoneMatch_ != "" {
  1511. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1512. }
  1513. var body io.Reader = nil
  1514. c.urlParams_.Set("alt", alt)
  1515. c.urlParams_.Set("prettyPrint", "false")
  1516. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  1517. urls += "?" + c.urlParams_.Encode()
  1518. req, err := http.NewRequest("GET", urls, body)
  1519. if err != nil {
  1520. return nil, err
  1521. }
  1522. req.Header = reqHeaders
  1523. googleapi.Expand(req.URL, map[string]string{
  1524. "name": c.name,
  1525. })
  1526. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1527. }
  1528. // Do executes the "speech.projects.locations.operations.get" call.
  1529. // Exactly one of *Operation or error will be non-nil. Any non-2xx
  1530. // status code is an error. Response headers are in either
  1531. // *Operation.ServerResponse.Header or (if a response was returned at
  1532. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1533. // to check whether the returned error was because
  1534. // http.StatusNotModified was returned.
  1535. func (c *ProjectsLocationsOperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
  1536. gensupport.SetOptions(c.urlParams_, opts...)
  1537. res, err := c.doRequest("json")
  1538. if res != nil && res.StatusCode == http.StatusNotModified {
  1539. if res.Body != nil {
  1540. res.Body.Close()
  1541. }
  1542. return nil, &googleapi.Error{
  1543. Code: res.StatusCode,
  1544. Header: res.Header,
  1545. }
  1546. }
  1547. if err != nil {
  1548. return nil, err
  1549. }
  1550. defer googleapi.CloseBody(res)
  1551. if err := googleapi.CheckResponse(res); err != nil {
  1552. return nil, err
  1553. }
  1554. ret := &Operation{
  1555. ServerResponse: googleapi.ServerResponse{
  1556. Header: res.Header,
  1557. HTTPStatusCode: res.StatusCode,
  1558. },
  1559. }
  1560. target := &ret
  1561. if err := gensupport.DecodeResponse(target, res); err != nil {
  1562. return nil, err
  1563. }
  1564. return ret, nil
  1565. // {
  1566. // "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.",
  1567. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/operations/{operationsId}",
  1568. // "httpMethod": "GET",
  1569. // "id": "speech.projects.locations.operations.get",
  1570. // "parameterOrder": [
  1571. // "name"
  1572. // ],
  1573. // "parameters": {
  1574. // "name": {
  1575. // "description": "The name of the operation resource.",
  1576. // "location": "path",
  1577. // "pattern": "^projects/[^/]+/locations/[^/]+/operations/[^/]+$",
  1578. // "required": true,
  1579. // "type": "string"
  1580. // }
  1581. // },
  1582. // "path": "v1/{+name}",
  1583. // "response": {
  1584. // "$ref": "Operation"
  1585. // },
  1586. // "scopes": [
  1587. // "https://www.googleapis.com/auth/cloud-platform"
  1588. // ]
  1589. // }
  1590. }
  1591. // method id "speech.projects.locations.operations.list":
  1592. type ProjectsLocationsOperationsListCall struct {
  1593. s *Service
  1594. name string
  1595. urlParams_ gensupport.URLParams
  1596. ifNoneMatch_ string
  1597. ctx_ context.Context
  1598. header_ http.Header
  1599. }
  1600. // List: Lists operations that match the specified filter in the
  1601. // request. If the
  1602. // server doesn't support this method, it returns
  1603. // `UNIMPLEMENTED`.
  1604. //
  1605. // NOTE: the `name` binding allows API services to override the
  1606. // binding
  1607. // to use different resource name schemes, such as `users/*/operations`.
  1608. // To
  1609. // override the binding, API services can add a binding such
  1610. // as
  1611. // "/v1/{name=users/*}/operations" to their service configuration.
  1612. // For backwards compatibility, the default name includes the
  1613. // operations
  1614. // collection id, however overriding users must ensure the name
  1615. // binding
  1616. // is the parent resource, without the operations collection id.
  1617. func (r *ProjectsLocationsOperationsService) List(name string) *ProjectsLocationsOperationsListCall {
  1618. c := &ProjectsLocationsOperationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1619. c.name = name
  1620. return c
  1621. }
  1622. // Filter sets the optional parameter "filter": The standard list
  1623. // filter.
  1624. func (c *ProjectsLocationsOperationsListCall) Filter(filter string) *ProjectsLocationsOperationsListCall {
  1625. c.urlParams_.Set("filter", filter)
  1626. return c
  1627. }
  1628. // PageSize sets the optional parameter "pageSize": The standard list
  1629. // page size.
  1630. func (c *ProjectsLocationsOperationsListCall) PageSize(pageSize int64) *ProjectsLocationsOperationsListCall {
  1631. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  1632. return c
  1633. }
  1634. // PageToken sets the optional parameter "pageToken": The standard list
  1635. // page token.
  1636. func (c *ProjectsLocationsOperationsListCall) PageToken(pageToken string) *ProjectsLocationsOperationsListCall {
  1637. c.urlParams_.Set("pageToken", pageToken)
  1638. return c
  1639. }
  1640. // Fields allows partial responses to be retrieved. See
  1641. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1642. // for more information.
  1643. func (c *ProjectsLocationsOperationsListCall) Fields(s ...googleapi.Field) *ProjectsLocationsOperationsListCall {
  1644. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1645. return c
  1646. }
  1647. // IfNoneMatch sets the optional parameter which makes the operation
  1648. // fail if the object's ETag matches the given value. This is useful for
  1649. // getting updates only after the object has changed since the last
  1650. // request. Use googleapi.IsNotModified to check whether the response
  1651. // error from Do is the result of In-None-Match.
  1652. func (c *ProjectsLocationsOperationsListCall) IfNoneMatch(entityTag string) *ProjectsLocationsOperationsListCall {
  1653. c.ifNoneMatch_ = entityTag
  1654. return c
  1655. }
  1656. // Context sets the context to be used in this call's Do method. Any
  1657. // pending HTTP request will be aborted if the provided context is
  1658. // canceled.
  1659. func (c *ProjectsLocationsOperationsListCall) Context(ctx context.Context) *ProjectsLocationsOperationsListCall {
  1660. c.ctx_ = ctx
  1661. return c
  1662. }
  1663. // Header returns an http.Header that can be modified by the caller to
  1664. // add HTTP headers to the request.
  1665. func (c *ProjectsLocationsOperationsListCall) Header() http.Header {
  1666. if c.header_ == nil {
  1667. c.header_ = make(http.Header)
  1668. }
  1669. return c.header_
  1670. }
  1671. func (c *ProjectsLocationsOperationsListCall) doRequest(alt string) (*http.Response, error) {
  1672. reqHeaders := make(http.Header)
  1673. for k, v := range c.header_ {
  1674. reqHeaders[k] = v
  1675. }
  1676. reqHeaders.Set("User-Agent", c.s.userAgent())
  1677. if c.ifNoneMatch_ != "" {
  1678. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1679. }
  1680. var body io.Reader = nil
  1681. c.urlParams_.Set("alt", alt)
  1682. c.urlParams_.Set("prettyPrint", "false")
  1683. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}/operations")
  1684. urls += "?" + c.urlParams_.Encode()
  1685. req, err := http.NewRequest("GET", urls, body)
  1686. if err != nil {
  1687. return nil, err
  1688. }
  1689. req.Header = reqHeaders
  1690. googleapi.Expand(req.URL, map[string]string{
  1691. "name": c.name,
  1692. })
  1693. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1694. }
  1695. // Do executes the "speech.projects.locations.operations.list" call.
  1696. // Exactly one of *ListOperationsResponse or error will be non-nil. Any
  1697. // non-2xx status code is an error. Response headers are in either
  1698. // *ListOperationsResponse.ServerResponse.Header or (if a response was
  1699. // returned at all) in error.(*googleapi.Error).Header. Use
  1700. // googleapi.IsNotModified to check whether the returned error was
  1701. // because http.StatusNotModified was returned.
  1702. func (c *ProjectsLocationsOperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsResponse, error) {
  1703. gensupport.SetOptions(c.urlParams_, opts...)
  1704. res, err := c.doRequest("json")
  1705. if res != nil && res.StatusCode == http.StatusNotModified {
  1706. if res.Body != nil {
  1707. res.Body.Close()
  1708. }
  1709. return nil, &googleapi.Error{
  1710. Code: res.StatusCode,
  1711. Header: res.Header,
  1712. }
  1713. }
  1714. if err != nil {
  1715. return nil, err
  1716. }
  1717. defer googleapi.CloseBody(res)
  1718. if err := googleapi.CheckResponse(res); err != nil {
  1719. return nil, err
  1720. }
  1721. ret := &ListOperationsResponse{
  1722. ServerResponse: googleapi.ServerResponse{
  1723. Header: res.Header,
  1724. HTTPStatusCode: res.StatusCode,
  1725. },
  1726. }
  1727. target := &ret
  1728. if err := gensupport.DecodeResponse(target, res); err != nil {
  1729. return nil, err
  1730. }
  1731. return ret, nil
  1732. // {
  1733. // "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.",
  1734. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/operations",
  1735. // "httpMethod": "GET",
  1736. // "id": "speech.projects.locations.operations.list",
  1737. // "parameterOrder": [
  1738. // "name"
  1739. // ],
  1740. // "parameters": {
  1741. // "filter": {
  1742. // "description": "The standard list filter.",
  1743. // "location": "query",
  1744. // "type": "string"
  1745. // },
  1746. // "name": {
  1747. // "description": "The name of the operation's parent resource.",
  1748. // "location": "path",
  1749. // "pattern": "^projects/[^/]+/locations/[^/]+$",
  1750. // "required": true,
  1751. // "type": "string"
  1752. // },
  1753. // "pageSize": {
  1754. // "description": "The standard list page size.",
  1755. // "format": "int32",
  1756. // "location": "query",
  1757. // "type": "integer"
  1758. // },
  1759. // "pageToken": {
  1760. // "description": "The standard list page token.",
  1761. // "location": "query",
  1762. // "type": "string"
  1763. // }
  1764. // },
  1765. // "path": "v1/{+name}/operations",
  1766. // "response": {
  1767. // "$ref": "ListOperationsResponse"
  1768. // },
  1769. // "scopes": [
  1770. // "https://www.googleapis.com/auth/cloud-platform"
  1771. // ]
  1772. // }
  1773. }
  1774. // Pages invokes f for each page of results.
  1775. // A non-nil error returned from f will halt the iteration.
  1776. // The provided context supersedes any context provided to the Context method.
  1777. func (c *ProjectsLocationsOperationsListCall) Pages(ctx context.Context, f func(*ListOperationsResponse) error) error {
  1778. c.ctx_ = ctx
  1779. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1780. for {
  1781. x, err := c.Do()
  1782. if err != nil {
  1783. return err
  1784. }
  1785. if err := f(x); err != nil {
  1786. return err
  1787. }
  1788. if x.NextPageToken == "" {
  1789. return nil
  1790. }
  1791. c.PageToken(x.NextPageToken)
  1792. }
  1793. }
  1794. // method id "speech.projects.operations.manualRecognitionTasks.get":
  1795. type ProjectsOperationsManualRecognitionTasksGetCall struct {
  1796. s *Service
  1797. name string
  1798. urlParams_ gensupport.URLParams
  1799. ifNoneMatch_ string
  1800. ctx_ context.Context
  1801. header_ http.Header
  1802. }
  1803. // Get: Gets the latest state of a long-running operation. Clients can
  1804. // use this
  1805. // method to poll the operation result at intervals as recommended by
  1806. // the API
  1807. // service.
  1808. func (r *ProjectsOperationsManualRecognitionTasksService) Get(name string) *ProjectsOperationsManualRecognitionTasksGetCall {
  1809. c := &ProjectsOperationsManualRecognitionTasksGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1810. c.name = name
  1811. return c
  1812. }
  1813. // Fields allows partial responses to be retrieved. See
  1814. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1815. // for more information.
  1816. func (c *ProjectsOperationsManualRecognitionTasksGetCall) Fields(s ...googleapi.Field) *ProjectsOperationsManualRecognitionTasksGetCall {
  1817. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1818. return c
  1819. }
  1820. // IfNoneMatch sets the optional parameter which makes the operation
  1821. // fail if the object's ETag matches the given value. This is useful for
  1822. // getting updates only after the object has changed since the last
  1823. // request. Use googleapi.IsNotModified to check whether the response
  1824. // error from Do is the result of In-None-Match.
  1825. func (c *ProjectsOperationsManualRecognitionTasksGetCall) IfNoneMatch(entityTag string) *ProjectsOperationsManualRecognitionTasksGetCall {
  1826. c.ifNoneMatch_ = entityTag
  1827. return c
  1828. }
  1829. // Context sets the context to be used in this call's Do method. Any
  1830. // pending HTTP request will be aborted if the provided context is
  1831. // canceled.
  1832. func (c *ProjectsOperationsManualRecognitionTasksGetCall) Context(ctx context.Context) *ProjectsOperationsManualRecognitionTasksGetCall {
  1833. c.ctx_ = ctx
  1834. return c
  1835. }
  1836. // Header returns an http.Header that can be modified by the caller to
  1837. // add HTTP headers to the request.
  1838. func (c *ProjectsOperationsManualRecognitionTasksGetCall) Header() http.Header {
  1839. if c.header_ == nil {
  1840. c.header_ = make(http.Header)
  1841. }
  1842. return c.header_
  1843. }
  1844. func (c *ProjectsOperationsManualRecognitionTasksGetCall) doRequest(alt string) (*http.Response, error) {
  1845. reqHeaders := make(http.Header)
  1846. for k, v := range c.header_ {
  1847. reqHeaders[k] = v
  1848. }
  1849. reqHeaders.Set("User-Agent", c.s.userAgent())
  1850. if c.ifNoneMatch_ != "" {
  1851. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1852. }
  1853. var body io.Reader = nil
  1854. c.urlParams_.Set("alt", alt)
  1855. c.urlParams_.Set("prettyPrint", "false")
  1856. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  1857. urls += "?" + c.urlParams_.Encode()
  1858. req, err := http.NewRequest("GET", urls, body)
  1859. if err != nil {
  1860. return nil, err
  1861. }
  1862. req.Header = reqHeaders
  1863. googleapi.Expand(req.URL, map[string]string{
  1864. "name": c.name,
  1865. })
  1866. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1867. }
  1868. // Do executes the "speech.projects.operations.manualRecognitionTasks.get" call.
  1869. // Exactly one of *Operation or error will be non-nil. Any non-2xx
  1870. // status code is an error. Response headers are in either
  1871. // *Operation.ServerResponse.Header or (if a response was returned at
  1872. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1873. // to check whether the returned error was because
  1874. // http.StatusNotModified was returned.
  1875. func (c *ProjectsOperationsManualRecognitionTasksGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
  1876. gensupport.SetOptions(c.urlParams_, opts...)
  1877. res, err := c.doRequest("json")
  1878. if res != nil && res.StatusCode == http.StatusNotModified {
  1879. if res.Body != nil {
  1880. res.Body.Close()
  1881. }
  1882. return nil, &googleapi.Error{
  1883. Code: res.StatusCode,
  1884. Header: res.Header,
  1885. }
  1886. }
  1887. if err != nil {
  1888. return nil, err
  1889. }
  1890. defer googleapi.CloseBody(res)
  1891. if err := googleapi.CheckResponse(res); err != nil {
  1892. return nil, err
  1893. }
  1894. ret := &Operation{
  1895. ServerResponse: googleapi.ServerResponse{
  1896. Header: res.Header,
  1897. HTTPStatusCode: res.StatusCode,
  1898. },
  1899. }
  1900. target := &ret
  1901. if err := gensupport.DecodeResponse(target, res); err != nil {
  1902. return nil, err
  1903. }
  1904. return ret, nil
  1905. // {
  1906. // "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.",
  1907. // "flatPath": "v1/projects/{projectsId}/operations/manualRecognitionTasks/{manualRecognitionTasksId}",
  1908. // "httpMethod": "GET",
  1909. // "id": "speech.projects.operations.manualRecognitionTasks.get",
  1910. // "parameterOrder": [
  1911. // "name"
  1912. // ],
  1913. // "parameters": {
  1914. // "name": {
  1915. // "description": "The name of the operation resource.",
  1916. // "location": "path",
  1917. // "pattern": "^projects/[^/]+/operations/manualRecognitionTasks/[^/]+$",
  1918. // "required": true,
  1919. // "type": "string"
  1920. // }
  1921. // },
  1922. // "path": "v1/{+name}",
  1923. // "response": {
  1924. // "$ref": "Operation"
  1925. // },
  1926. // "scopes": [
  1927. // "https://www.googleapis.com/auth/cloud-platform"
  1928. // ]
  1929. // }
  1930. }
  1931. // method id "speech.speech.longrunningrecognize":
  1932. type SpeechLongrunningrecognizeCall struct {
  1933. s *Service
  1934. longrunningrecognizerequest *LongRunningRecognizeRequest
  1935. urlParams_ gensupport.URLParams
  1936. ctx_ context.Context
  1937. header_ http.Header
  1938. }
  1939. // Longrunningrecognize: Performs asynchronous speech recognition:
  1940. // receive results via the
  1941. // google.longrunning.Operations interface. Returns either
  1942. // an
  1943. // `Operation.error` or an `Operation.response` which contains
  1944. // a `LongRunningRecognizeResponse` message.
  1945. func (r *SpeechService) Longrunningrecognize(longrunningrecognizerequest *LongRunningRecognizeRequest) *SpeechLongrunningrecognizeCall {
  1946. c := &SpeechLongrunningrecognizeCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1947. c.longrunningrecognizerequest = longrunningrecognizerequest
  1948. return c
  1949. }
  1950. // Fields allows partial responses to be retrieved. See
  1951. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1952. // for more information.
  1953. func (c *SpeechLongrunningrecognizeCall) Fields(s ...googleapi.Field) *SpeechLongrunningrecognizeCall {
  1954. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1955. return c
  1956. }
  1957. // Context sets the context to be used in this call's Do method. Any
  1958. // pending HTTP request will be aborted if the provided context is
  1959. // canceled.
  1960. func (c *SpeechLongrunningrecognizeCall) Context(ctx context.Context) *SpeechLongrunningrecognizeCall {
  1961. c.ctx_ = ctx
  1962. return c
  1963. }
  1964. // Header returns an http.Header that can be modified by the caller to
  1965. // add HTTP headers to the request.
  1966. func (c *SpeechLongrunningrecognizeCall) Header() http.Header {
  1967. if c.header_ == nil {
  1968. c.header_ = make(http.Header)
  1969. }
  1970. return c.header_
  1971. }
  1972. func (c *SpeechLongrunningrecognizeCall) doRequest(alt string) (*http.Response, error) {
  1973. reqHeaders := make(http.Header)
  1974. for k, v := range c.header_ {
  1975. reqHeaders[k] = v
  1976. }
  1977. reqHeaders.Set("User-Agent", c.s.userAgent())
  1978. var body io.Reader = nil
  1979. body, err := googleapi.WithoutDataWrapper.JSONReader(c.longrunningrecognizerequest)
  1980. if err != nil {
  1981. return nil, err
  1982. }
  1983. reqHeaders.Set("Content-Type", "application/json")
  1984. c.urlParams_.Set("alt", alt)
  1985. c.urlParams_.Set("prettyPrint", "false")
  1986. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/speech:longrunningrecognize")
  1987. urls += "?" + c.urlParams_.Encode()
  1988. req, err := http.NewRequest("POST", urls, body)
  1989. if err != nil {
  1990. return nil, err
  1991. }
  1992. req.Header = reqHeaders
  1993. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1994. }
  1995. // Do executes the "speech.speech.longrunningrecognize" call.
  1996. // Exactly one of *Operation or error will be non-nil. Any non-2xx
  1997. // status code is an error. Response headers are in either
  1998. // *Operation.ServerResponse.Header or (if a response was returned at
  1999. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  2000. // to check whether the returned error was because
  2001. // http.StatusNotModified was returned.
  2002. func (c *SpeechLongrunningrecognizeCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
  2003. gensupport.SetOptions(c.urlParams_, opts...)
  2004. res, err := c.doRequest("json")
  2005. if res != nil && res.StatusCode == http.StatusNotModified {
  2006. if res.Body != nil {
  2007. res.Body.Close()
  2008. }
  2009. return nil, &googleapi.Error{
  2010. Code: res.StatusCode,
  2011. Header: res.Header,
  2012. }
  2013. }
  2014. if err != nil {
  2015. return nil, err
  2016. }
  2017. defer googleapi.CloseBody(res)
  2018. if err := googleapi.CheckResponse(res); err != nil {
  2019. return nil, err
  2020. }
  2021. ret := &Operation{
  2022. ServerResponse: googleapi.ServerResponse{
  2023. Header: res.Header,
  2024. HTTPStatusCode: res.StatusCode,
  2025. },
  2026. }
  2027. target := &ret
  2028. if err := gensupport.DecodeResponse(target, res); err != nil {
  2029. return nil, err
  2030. }
  2031. return ret, nil
  2032. // {
  2033. // "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.",
  2034. // "flatPath": "v1/speech:longrunningrecognize",
  2035. // "httpMethod": "POST",
  2036. // "id": "speech.speech.longrunningrecognize",
  2037. // "parameterOrder": [],
  2038. // "parameters": {},
  2039. // "path": "v1/speech:longrunningrecognize",
  2040. // "request": {
  2041. // "$ref": "LongRunningRecognizeRequest"
  2042. // },
  2043. // "response": {
  2044. // "$ref": "Operation"
  2045. // },
  2046. // "scopes": [
  2047. // "https://www.googleapis.com/auth/cloud-platform"
  2048. // ]
  2049. // }
  2050. }
  2051. // method id "speech.speech.recognize":
  2052. type SpeechRecognizeCall struct {
  2053. s *Service
  2054. recognizerequest *RecognizeRequest
  2055. urlParams_ gensupport.URLParams
  2056. ctx_ context.Context
  2057. header_ http.Header
  2058. }
  2059. // Recognize: Performs synchronous speech recognition: receive results
  2060. // after all audio
  2061. // has been sent and processed.
  2062. func (r *SpeechService) Recognize(recognizerequest *RecognizeRequest) *SpeechRecognizeCall {
  2063. c := &SpeechRecognizeCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2064. c.recognizerequest = recognizerequest
  2065. return c
  2066. }
  2067. // Fields allows partial responses to be retrieved. See
  2068. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2069. // for more information.
  2070. func (c *SpeechRecognizeCall) Fields(s ...googleapi.Field) *SpeechRecognizeCall {
  2071. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2072. return c
  2073. }
  2074. // Context sets the context to be used in this call's Do method. Any
  2075. // pending HTTP request will be aborted if the provided context is
  2076. // canceled.
  2077. func (c *SpeechRecognizeCall) Context(ctx context.Context) *SpeechRecognizeCall {
  2078. c.ctx_ = ctx
  2079. return c
  2080. }
  2081. // Header returns an http.Header that can be modified by the caller to
  2082. // add HTTP headers to the request.
  2083. func (c *SpeechRecognizeCall) Header() http.Header {
  2084. if c.header_ == nil {
  2085. c.header_ = make(http.Header)
  2086. }
  2087. return c.header_
  2088. }
  2089. func (c *SpeechRecognizeCall) doRequest(alt string) (*http.Response, error) {
  2090. reqHeaders := make(http.Header)
  2091. for k, v := range c.header_ {
  2092. reqHeaders[k] = v
  2093. }
  2094. reqHeaders.Set("User-Agent", c.s.userAgent())
  2095. var body io.Reader = nil
  2096. body, err := googleapi.WithoutDataWrapper.JSONReader(c.recognizerequest)
  2097. if err != nil {
  2098. return nil, err
  2099. }
  2100. reqHeaders.Set("Content-Type", "application/json")
  2101. c.urlParams_.Set("alt", alt)
  2102. c.urlParams_.Set("prettyPrint", "false")
  2103. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/speech:recognize")
  2104. urls += "?" + c.urlParams_.Encode()
  2105. req, err := http.NewRequest("POST", urls, body)
  2106. if err != nil {
  2107. return nil, err
  2108. }
  2109. req.Header = reqHeaders
  2110. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2111. }
  2112. // Do executes the "speech.speech.recognize" call.
  2113. // Exactly one of *RecognizeResponse or error will be non-nil. Any
  2114. // non-2xx status code is an error. Response headers are in either
  2115. // *RecognizeResponse.ServerResponse.Header or (if a response was
  2116. // returned at all) in error.(*googleapi.Error).Header. Use
  2117. // googleapi.IsNotModified to check whether the returned error was
  2118. // because http.StatusNotModified was returned.
  2119. func (c *SpeechRecognizeCall) Do(opts ...googleapi.CallOption) (*RecognizeResponse, error) {
  2120. gensupport.SetOptions(c.urlParams_, opts...)
  2121. res, err := c.doRequest("json")
  2122. if res != nil && res.StatusCode == http.StatusNotModified {
  2123. if res.Body != nil {
  2124. res.Body.Close()
  2125. }
  2126. return nil, &googleapi.Error{
  2127. Code: res.StatusCode,
  2128. Header: res.Header,
  2129. }
  2130. }
  2131. if err != nil {
  2132. return nil, err
  2133. }
  2134. defer googleapi.CloseBody(res)
  2135. if err := googleapi.CheckResponse(res); err != nil {
  2136. return nil, err
  2137. }
  2138. ret := &RecognizeResponse{
  2139. ServerResponse: googleapi.ServerResponse{
  2140. Header: res.Header,
  2141. HTTPStatusCode: res.StatusCode,
  2142. },
  2143. }
  2144. target := &ret
  2145. if err := gensupport.DecodeResponse(target, res); err != nil {
  2146. return nil, err
  2147. }
  2148. return ret, nil
  2149. // {
  2150. // "description": "Performs synchronous speech recognition: receive results after all audio\nhas been sent and processed.",
  2151. // "flatPath": "v1/speech:recognize",
  2152. // "httpMethod": "POST",
  2153. // "id": "speech.speech.recognize",
  2154. // "parameterOrder": [],
  2155. // "parameters": {},
  2156. // "path": "v1/speech:recognize",
  2157. // "request": {
  2158. // "$ref": "RecognizeRequest"
  2159. // },
  2160. // "response": {
  2161. // "$ref": "RecognizeResponse"
  2162. // },
  2163. // "scopes": [
  2164. // "https://www.googleapis.com/auth/cloud-platform"
  2165. // ]
  2166. // }
  2167. }