Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

1339 righe
47 KiB

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