1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 package texttospeech
54
55 import (
56 "bytes"
57 "context"
58 "encoding/json"
59 "errors"
60 "fmt"
61 "io"
62 "net/http"
63 "net/url"
64 "strconv"
65 "strings"
66
67 googleapi "google.golang.org/api/googleapi"
68 internal "google.golang.org/api/internal"
69 gensupport "google.golang.org/api/internal/gensupport"
70 option "google.golang.org/api/option"
71 internaloption "google.golang.org/api/option/internaloption"
72 htransport "google.golang.org/api/transport/http"
73 )
74
75
76
77 var _ = bytes.NewBuffer
78 var _ = strconv.Itoa
79 var _ = fmt.Sprintf
80 var _ = json.NewDecoder
81 var _ = io.Copy
82 var _ = url.Parse
83 var _ = gensupport.MarshalJSON
84 var _ = googleapi.Version
85 var _ = errors.New
86 var _ = strings.Replace
87 var _ = context.Canceled
88 var _ = internaloption.WithDefaultEndpoint
89 var _ = internal.Version
90
91 const apiId = "texttospeech:v1beta1"
92 const apiName = "texttospeech"
93 const apiVersion = "v1beta1"
94 const basePath = "https://texttospeech.googleapis.com/"
95 const basePathTemplate = "https://texttospeech.UNIVERSE_DOMAIN/"
96 const mtlsBasePath = "https://texttospeech.mtls.googleapis.com/"
97
98
99 const (
100
101
102 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
103 )
104
105
106 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
107 scopesOption := internaloption.WithDefaultScopes(
108 "https://www.googleapis.com/auth/cloud-platform",
109 )
110
111 opts = append([]option.ClientOption{scopesOption}, opts...)
112 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
113 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
114 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
115 opts = append(opts, internaloption.EnableNewAuthLibrary())
116 client, endpoint, err := htransport.NewClient(ctx, opts...)
117 if err != nil {
118 return nil, err
119 }
120 s, err := New(client)
121 if err != nil {
122 return nil, err
123 }
124 if endpoint != "" {
125 s.BasePath = endpoint
126 }
127 return s, nil
128 }
129
130
131
132
133
134
135 func New(client *http.Client) (*Service, error) {
136 if client == nil {
137 return nil, errors.New("client is nil")
138 }
139 s := &Service{client: client, BasePath: basePath}
140 s.Projects = NewProjectsService(s)
141 s.Text = NewTextService(s)
142 s.Voices = NewVoicesService(s)
143 return s, nil
144 }
145
146 type Service struct {
147 client *http.Client
148 BasePath string
149 UserAgent string
150
151 Projects *ProjectsService
152
153 Text *TextService
154
155 Voices *VoicesService
156 }
157
158 func (s *Service) userAgent() string {
159 if s.UserAgent == "" {
160 return googleapi.UserAgent
161 }
162 return googleapi.UserAgent + " " + s.UserAgent
163 }
164
165 func NewProjectsService(s *Service) *ProjectsService {
166 rs := &ProjectsService{s: s}
167 rs.Locations = NewProjectsLocationsService(s)
168 return rs
169 }
170
171 type ProjectsService struct {
172 s *Service
173
174 Locations *ProjectsLocationsService
175 }
176
177 func NewProjectsLocationsService(s *Service) *ProjectsLocationsService {
178 rs := &ProjectsLocationsService{s: s}
179 rs.Operations = NewProjectsLocationsOperationsService(s)
180 return rs
181 }
182
183 type ProjectsLocationsService struct {
184 s *Service
185
186 Operations *ProjectsLocationsOperationsService
187 }
188
189 func NewProjectsLocationsOperationsService(s *Service) *ProjectsLocationsOperationsService {
190 rs := &ProjectsLocationsOperationsService{s: s}
191 return rs
192 }
193
194 type ProjectsLocationsOperationsService struct {
195 s *Service
196 }
197
198 func NewTextService(s *Service) *TextService {
199 rs := &TextService{s: s}
200 return rs
201 }
202
203 type TextService struct {
204 s *Service
205 }
206
207 func NewVoicesService(s *Service) *VoicesService {
208 rs := &VoicesService{s: s}
209 return rs
210 }
211
212 type VoicesService struct {
213 s *Service
214 }
215
216
217 type AudioConfig struct {
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235 AudioEncoding string `json:"audioEncoding,omitempty"`
236
237
238
239
240
241 EffectsProfileId []string `json:"effectsProfileId,omitempty"`
242
243
244
245 Pitch float64 `json:"pitch,omitempty"`
246
247
248
249
250
251
252
253 SampleRateHertz int64 `json:"sampleRateHertz,omitempty"`
254
255
256
257
258 SpeakingRate float64 `json:"speakingRate,omitempty"`
259
260
261
262
263
264
265
266
267 VolumeGainDb float64 `json:"volumeGainDb,omitempty"`
268
269
270
271
272
273 ForceSendFields []string `json:"-"`
274
275
276
277
278 NullFields []string `json:"-"`
279 }
280
281 func (s *AudioConfig) MarshalJSON() ([]byte, error) {
282 type NoMethod AudioConfig
283 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
284 }
285
286 func (s *AudioConfig) UnmarshalJSON(data []byte) error {
287 type NoMethod AudioConfig
288 var s1 struct {
289 Pitch gensupport.JSONFloat64 `json:"pitch"`
290 SpeakingRate gensupport.JSONFloat64 `json:"speakingRate"`
291 VolumeGainDb gensupport.JSONFloat64 `json:"volumeGainDb"`
292 *NoMethod
293 }
294 s1.NoMethod = (*NoMethod)(s)
295 if err := json.Unmarshal(data, &s1); err != nil {
296 return err
297 }
298 s.Pitch = float64(s1.Pitch)
299 s.SpeakingRate = float64(s1.SpeakingRate)
300 s.VolumeGainDb = float64(s1.VolumeGainDb)
301 return nil
302 }
303
304
305 type CustomVoiceParams struct {
306
307
308 Model string `json:"model,omitempty"`
309
310
311
312
313
314
315
316
317
318
319
320 ReportedUsage string `json:"reportedUsage,omitempty"`
321
322
323
324
325
326 ForceSendFields []string `json:"-"`
327
328
329
330
331 NullFields []string `json:"-"`
332 }
333
334 func (s *CustomVoiceParams) MarshalJSON() ([]byte, error) {
335 type NoMethod CustomVoiceParams
336 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
337 }
338
339
340
341 type GoogleCloudTexttospeechV1beta1SynthesizeLongAudioMetadata struct {
342
343 LastUpdateTime string `json:"lastUpdateTime,omitempty"`
344
345
346 ProgressPercentage float64 `json:"progressPercentage,omitempty"`
347
348 StartTime string `json:"startTime,omitempty"`
349
350
351
352
353
354 ForceSendFields []string `json:"-"`
355
356
357
358
359 NullFields []string `json:"-"`
360 }
361
362 func (s *GoogleCloudTexttospeechV1beta1SynthesizeLongAudioMetadata) MarshalJSON() ([]byte, error) {
363 type NoMethod GoogleCloudTexttospeechV1beta1SynthesizeLongAudioMetadata
364 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
365 }
366
367 func (s *GoogleCloudTexttospeechV1beta1SynthesizeLongAudioMetadata) UnmarshalJSON(data []byte) error {
368 type NoMethod GoogleCloudTexttospeechV1beta1SynthesizeLongAudioMetadata
369 var s1 struct {
370 ProgressPercentage gensupport.JSONFloat64 `json:"progressPercentage"`
371 *NoMethod
372 }
373 s1.NoMethod = (*NoMethod)(s)
374 if err := json.Unmarshal(data, &s1); err != nil {
375 return err
376 }
377 s.ProgressPercentage = float64(s1.ProgressPercentage)
378 return nil
379 }
380
381
382 type ListOperationsResponse struct {
383
384 NextPageToken string `json:"nextPageToken,omitempty"`
385
386
387 Operations []*Operation `json:"operations,omitempty"`
388
389
390 googleapi.ServerResponse `json:"-"`
391
392
393
394
395
396 ForceSendFields []string `json:"-"`
397
398
399
400
401 NullFields []string `json:"-"`
402 }
403
404 func (s *ListOperationsResponse) MarshalJSON() ([]byte, error) {
405 type NoMethod ListOperationsResponse
406 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
407 }
408
409
410
411 type ListVoicesResponse struct {
412
413 Voices []*Voice `json:"voices,omitempty"`
414
415
416 googleapi.ServerResponse `json:"-"`
417
418
419
420
421
422 ForceSendFields []string `json:"-"`
423
424
425
426
427 NullFields []string `json:"-"`
428 }
429
430 func (s *ListVoicesResponse) MarshalJSON() ([]byte, error) {
431 type NoMethod ListVoicesResponse
432 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
433 }
434
435
436
437 type Operation struct {
438
439
440
441 Done bool `json:"done,omitempty"`
442
443 Error *Status `json:"error,omitempty"`
444
445
446
447
448 Metadata googleapi.RawMessage `json:"metadata,omitempty"`
449
450
451
452 Name string `json:"name,omitempty"`
453
454
455
456
457
458
459
460 Response googleapi.RawMessage `json:"response,omitempty"`
461
462
463 googleapi.ServerResponse `json:"-"`
464
465
466
467
468
469 ForceSendFields []string `json:"-"`
470
471
472
473
474 NullFields []string `json:"-"`
475 }
476
477 func (s *Operation) MarshalJSON() ([]byte, error) {
478 type NoMethod Operation
479 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
480 }
481
482
483
484
485
486
487
488 type Status struct {
489
490 Code int64 `json:"code,omitempty"`
491
492
493 Details []googleapi.RawMessage `json:"details,omitempty"`
494
495
496
497 Message string `json:"message,omitempty"`
498
499
500
501
502
503 ForceSendFields []string `json:"-"`
504
505
506
507
508 NullFields []string `json:"-"`
509 }
510
511 func (s *Status) MarshalJSON() ([]byte, error) {
512 type NoMethod Status
513 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
514 }
515
516
517
518
519 type SynthesisInput struct {
520
521
522
523
524 Ssml string `json:"ssml,omitempty"`
525
526 Text string `json:"text,omitempty"`
527
528
529
530
531
532 ForceSendFields []string `json:"-"`
533
534
535
536
537 NullFields []string `json:"-"`
538 }
539
540 func (s *SynthesisInput) MarshalJSON() ([]byte, error) {
541 type NoMethod SynthesisInput
542 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
543 }
544
545
546
547 type SynthesizeLongAudioMetadata struct {
548
549 LastUpdateTime string `json:"lastUpdateTime,omitempty"`
550
551
552 ProgressPercentage float64 `json:"progressPercentage,omitempty"`
553
554 StartTime string `json:"startTime,omitempty"`
555
556
557
558
559
560 ForceSendFields []string `json:"-"`
561
562
563
564
565 NullFields []string `json:"-"`
566 }
567
568 func (s *SynthesizeLongAudioMetadata) MarshalJSON() ([]byte, error) {
569 type NoMethod SynthesizeLongAudioMetadata
570 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
571 }
572
573 func (s *SynthesizeLongAudioMetadata) UnmarshalJSON(data []byte) error {
574 type NoMethod SynthesizeLongAudioMetadata
575 var s1 struct {
576 ProgressPercentage gensupport.JSONFloat64 `json:"progressPercentage"`
577 *NoMethod
578 }
579 s1.NoMethod = (*NoMethod)(s)
580 if err := json.Unmarshal(data, &s1); err != nil {
581 return err
582 }
583 s.ProgressPercentage = float64(s1.ProgressPercentage)
584 return nil
585 }
586
587
588
589 type SynthesizeLongAudioRequest struct {
590
591 AudioConfig *AudioConfig `json:"audioConfig,omitempty"`
592
593
594 Input *SynthesisInput `json:"input,omitempty"`
595
596
597
598 OutputGcsUri string `json:"outputGcsUri,omitempty"`
599
600 Voice *VoiceSelectionParams `json:"voice,omitempty"`
601
602
603
604
605
606 ForceSendFields []string `json:"-"`
607
608
609
610
611 NullFields []string `json:"-"`
612 }
613
614 func (s *SynthesizeLongAudioRequest) MarshalJSON() ([]byte, error) {
615 type NoMethod SynthesizeLongAudioRequest
616 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
617 }
618
619
620
621 type SynthesizeSpeechRequest struct {
622
623 AudioConfig *AudioConfig `json:"audioConfig,omitempty"`
624
625
626
627
628
629
630
631
632 EnableTimePointing []string `json:"enableTimePointing,omitempty"`
633
634
635 Input *SynthesisInput `json:"input,omitempty"`
636
637 Voice *VoiceSelectionParams `json:"voice,omitempty"`
638
639
640
641
642
643 ForceSendFields []string `json:"-"`
644
645
646
647
648 NullFields []string `json:"-"`
649 }
650
651 func (s *SynthesizeSpeechRequest) MarshalJSON() ([]byte, error) {
652 type NoMethod SynthesizeSpeechRequest
653 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
654 }
655
656
657
658 type SynthesizeSpeechResponse struct {
659
660 AudioConfig *AudioConfig `json:"audioConfig,omitempty"`
661
662
663
664
665
666 AudioContent string `json:"audioContent,omitempty"`
667
668
669
670 Timepoints []*Timepoint `json:"timepoints,omitempty"`
671
672
673 googleapi.ServerResponse `json:"-"`
674
675
676
677
678
679 ForceSendFields []string `json:"-"`
680
681
682
683
684 NullFields []string `json:"-"`
685 }
686
687 func (s *SynthesizeSpeechResponse) MarshalJSON() ([]byte, error) {
688 type NoMethod SynthesizeSpeechResponse
689 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
690 }
691
692
693
694 type Timepoint struct {
695
696 MarkName string `json:"markName,omitempty"`
697
698 TimeSeconds float64 `json:"timeSeconds,omitempty"`
699
700
701
702
703
704 ForceSendFields []string `json:"-"`
705
706
707
708
709 NullFields []string `json:"-"`
710 }
711
712 func (s *Timepoint) MarshalJSON() ([]byte, error) {
713 type NoMethod Timepoint
714 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
715 }
716
717 func (s *Timepoint) UnmarshalJSON(data []byte) error {
718 type NoMethod Timepoint
719 var s1 struct {
720 TimeSeconds gensupport.JSONFloat64 `json:"timeSeconds"`
721 *NoMethod
722 }
723 s1.NoMethod = (*NoMethod)(s)
724 if err := json.Unmarshal(data, &s1); err != nil {
725 return err
726 }
727 s.TimeSeconds = float64(s1.TimeSeconds)
728 return nil
729 }
730
731
732 type Voice struct {
733
734
735
736 LanguageCodes []string `json:"languageCodes,omitempty"`
737
738 Name string `json:"name,omitempty"`
739
740 NaturalSampleRateHertz int64 `json:"naturalSampleRateHertz,omitempty"`
741
742
743
744
745
746
747
748
749
750
751
752 SsmlGender string `json:"ssmlGender,omitempty"`
753
754
755
756
757
758 ForceSendFields []string `json:"-"`
759
760
761
762
763 NullFields []string `json:"-"`
764 }
765
766 func (s *Voice) MarshalJSON() ([]byte, error) {
767 type NoMethod Voice
768 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
769 }
770
771
772
773 type VoiceSelectionParams struct {
774
775
776
777 CustomVoice *CustomVoiceParams `json:"customVoice,omitempty"`
778
779
780
781
782
783
784
785
786
787
788
789 LanguageCode string `json:"languageCode,omitempty"`
790
791
792
793 Name string `json:"name,omitempty"`
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809 SsmlGender string `json:"ssmlGender,omitempty"`
810
811
812
813
814
815 ForceSendFields []string `json:"-"`
816
817
818
819
820 NullFields []string `json:"-"`
821 }
822
823 func (s *VoiceSelectionParams) MarshalJSON() ([]byte, error) {
824 type NoMethod VoiceSelectionParams
825 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
826 }
827
828 type ProjectsLocationsSynthesizeLongAudioCall struct {
829 s *Service
830 parent string
831 synthesizelongaudiorequest *SynthesizeLongAudioRequest
832 urlParams_ gensupport.URLParams
833 ctx_ context.Context
834 header_ http.Header
835 }
836
837
838
839
840
841 func (r *ProjectsLocationsService) SynthesizeLongAudio(parent string, synthesizelongaudiorequest *SynthesizeLongAudioRequest) *ProjectsLocationsSynthesizeLongAudioCall {
842 c := &ProjectsLocationsSynthesizeLongAudioCall{s: r.s, urlParams_: make(gensupport.URLParams)}
843 c.parent = parent
844 c.synthesizelongaudiorequest = synthesizelongaudiorequest
845 return c
846 }
847
848
849
850
851 func (c *ProjectsLocationsSynthesizeLongAudioCall) Fields(s ...googleapi.Field) *ProjectsLocationsSynthesizeLongAudioCall {
852 c.urlParams_.Set("fields", googleapi.CombineFields(s))
853 return c
854 }
855
856
857 func (c *ProjectsLocationsSynthesizeLongAudioCall) Context(ctx context.Context) *ProjectsLocationsSynthesizeLongAudioCall {
858 c.ctx_ = ctx
859 return c
860 }
861
862
863
864 func (c *ProjectsLocationsSynthesizeLongAudioCall) Header() http.Header {
865 if c.header_ == nil {
866 c.header_ = make(http.Header)
867 }
868 return c.header_
869 }
870
871 func (c *ProjectsLocationsSynthesizeLongAudioCall) doRequest(alt string) (*http.Response, error) {
872 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
873 var body io.Reader = nil
874 body, err := googleapi.WithoutDataWrapper.JSONReader(c.synthesizelongaudiorequest)
875 if err != nil {
876 return nil, err
877 }
878 c.urlParams_.Set("alt", alt)
879 c.urlParams_.Set("prettyPrint", "false")
880 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+parent}:synthesizeLongAudio")
881 urls += "?" + c.urlParams_.Encode()
882 req, err := http.NewRequest("POST", urls, body)
883 if err != nil {
884 return nil, err
885 }
886 req.Header = reqHeaders
887 googleapi.Expand(req.URL, map[string]string{
888 "parent": c.parent,
889 })
890 return gensupport.SendRequest(c.ctx_, c.s.client, req)
891 }
892
893
894
895
896
897
898 func (c *ProjectsLocationsSynthesizeLongAudioCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
899 gensupport.SetOptions(c.urlParams_, opts...)
900 res, err := c.doRequest("json")
901 if res != nil && res.StatusCode == http.StatusNotModified {
902 if res.Body != nil {
903 res.Body.Close()
904 }
905 return nil, gensupport.WrapError(&googleapi.Error{
906 Code: res.StatusCode,
907 Header: res.Header,
908 })
909 }
910 if err != nil {
911 return nil, err
912 }
913 defer googleapi.CloseBody(res)
914 if err := googleapi.CheckResponse(res); err != nil {
915 return nil, gensupport.WrapError(err)
916 }
917 ret := &Operation{
918 ServerResponse: googleapi.ServerResponse{
919 Header: res.Header,
920 HTTPStatusCode: res.StatusCode,
921 },
922 }
923 target := &ret
924 if err := gensupport.DecodeResponse(target, res); err != nil {
925 return nil, err
926 }
927 return ret, nil
928 }
929
930 type ProjectsLocationsOperationsGetCall struct {
931 s *Service
932 name string
933 urlParams_ gensupport.URLParams
934 ifNoneMatch_ string
935 ctx_ context.Context
936 header_ http.Header
937 }
938
939
940
941
942
943
944 func (r *ProjectsLocationsOperationsService) Get(name string) *ProjectsLocationsOperationsGetCall {
945 c := &ProjectsLocationsOperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
946 c.name = name
947 return c
948 }
949
950
951
952
953 func (c *ProjectsLocationsOperationsGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsOperationsGetCall {
954 c.urlParams_.Set("fields", googleapi.CombineFields(s))
955 return c
956 }
957
958
959
960
961 func (c *ProjectsLocationsOperationsGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsOperationsGetCall {
962 c.ifNoneMatch_ = entityTag
963 return c
964 }
965
966
967 func (c *ProjectsLocationsOperationsGetCall) Context(ctx context.Context) *ProjectsLocationsOperationsGetCall {
968 c.ctx_ = ctx
969 return c
970 }
971
972
973
974 func (c *ProjectsLocationsOperationsGetCall) Header() http.Header {
975 if c.header_ == nil {
976 c.header_ = make(http.Header)
977 }
978 return c.header_
979 }
980
981 func (c *ProjectsLocationsOperationsGetCall) doRequest(alt string) (*http.Response, error) {
982 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
983 if c.ifNoneMatch_ != "" {
984 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
985 }
986 var body io.Reader = nil
987 c.urlParams_.Set("alt", alt)
988 c.urlParams_.Set("prettyPrint", "false")
989 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+name}")
990 urls += "?" + c.urlParams_.Encode()
991 req, err := http.NewRequest("GET", urls, body)
992 if err != nil {
993 return nil, err
994 }
995 req.Header = reqHeaders
996 googleapi.Expand(req.URL, map[string]string{
997 "name": c.name,
998 })
999 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1000 }
1001
1002
1003
1004
1005
1006
1007 func (c *ProjectsLocationsOperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
1008 gensupport.SetOptions(c.urlParams_, opts...)
1009 res, err := c.doRequest("json")
1010 if res != nil && res.StatusCode == http.StatusNotModified {
1011 if res.Body != nil {
1012 res.Body.Close()
1013 }
1014 return nil, gensupport.WrapError(&googleapi.Error{
1015 Code: res.StatusCode,
1016 Header: res.Header,
1017 })
1018 }
1019 if err != nil {
1020 return nil, err
1021 }
1022 defer googleapi.CloseBody(res)
1023 if err := googleapi.CheckResponse(res); err != nil {
1024 return nil, gensupport.WrapError(err)
1025 }
1026 ret := &Operation{
1027 ServerResponse: googleapi.ServerResponse{
1028 Header: res.Header,
1029 HTTPStatusCode: res.StatusCode,
1030 },
1031 }
1032 target := &ret
1033 if err := gensupport.DecodeResponse(target, res); err != nil {
1034 return nil, err
1035 }
1036 return ret, nil
1037 }
1038
1039 type ProjectsLocationsOperationsListCall struct {
1040 s *Service
1041 name string
1042 urlParams_ gensupport.URLParams
1043 ifNoneMatch_ string
1044 ctx_ context.Context
1045 header_ http.Header
1046 }
1047
1048
1049
1050
1051
1052 func (r *ProjectsLocationsOperationsService) List(name string) *ProjectsLocationsOperationsListCall {
1053 c := &ProjectsLocationsOperationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1054 c.name = name
1055 return c
1056 }
1057
1058
1059 func (c *ProjectsLocationsOperationsListCall) Filter(filter string) *ProjectsLocationsOperationsListCall {
1060 c.urlParams_.Set("filter", filter)
1061 return c
1062 }
1063
1064
1065
1066 func (c *ProjectsLocationsOperationsListCall) PageSize(pageSize int64) *ProjectsLocationsOperationsListCall {
1067 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
1068 return c
1069 }
1070
1071
1072
1073 func (c *ProjectsLocationsOperationsListCall) PageToken(pageToken string) *ProjectsLocationsOperationsListCall {
1074 c.urlParams_.Set("pageToken", pageToken)
1075 return c
1076 }
1077
1078
1079
1080
1081 func (c *ProjectsLocationsOperationsListCall) Fields(s ...googleapi.Field) *ProjectsLocationsOperationsListCall {
1082 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1083 return c
1084 }
1085
1086
1087
1088
1089 func (c *ProjectsLocationsOperationsListCall) IfNoneMatch(entityTag string) *ProjectsLocationsOperationsListCall {
1090 c.ifNoneMatch_ = entityTag
1091 return c
1092 }
1093
1094
1095 func (c *ProjectsLocationsOperationsListCall) Context(ctx context.Context) *ProjectsLocationsOperationsListCall {
1096 c.ctx_ = ctx
1097 return c
1098 }
1099
1100
1101
1102 func (c *ProjectsLocationsOperationsListCall) Header() http.Header {
1103 if c.header_ == nil {
1104 c.header_ = make(http.Header)
1105 }
1106 return c.header_
1107 }
1108
1109 func (c *ProjectsLocationsOperationsListCall) doRequest(alt string) (*http.Response, error) {
1110 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1111 if c.ifNoneMatch_ != "" {
1112 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1113 }
1114 var body io.Reader = nil
1115 c.urlParams_.Set("alt", alt)
1116 c.urlParams_.Set("prettyPrint", "false")
1117 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+name}/operations")
1118 urls += "?" + c.urlParams_.Encode()
1119 req, err := http.NewRequest("GET", urls, body)
1120 if err != nil {
1121 return nil, err
1122 }
1123 req.Header = reqHeaders
1124 googleapi.Expand(req.URL, map[string]string{
1125 "name": c.name,
1126 })
1127 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1128 }
1129
1130
1131
1132
1133
1134
1135
1136 func (c *ProjectsLocationsOperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsResponse, error) {
1137 gensupport.SetOptions(c.urlParams_, opts...)
1138 res, err := c.doRequest("json")
1139 if res != nil && res.StatusCode == http.StatusNotModified {
1140 if res.Body != nil {
1141 res.Body.Close()
1142 }
1143 return nil, gensupport.WrapError(&googleapi.Error{
1144 Code: res.StatusCode,
1145 Header: res.Header,
1146 })
1147 }
1148 if err != nil {
1149 return nil, err
1150 }
1151 defer googleapi.CloseBody(res)
1152 if err := googleapi.CheckResponse(res); err != nil {
1153 return nil, gensupport.WrapError(err)
1154 }
1155 ret := &ListOperationsResponse{
1156 ServerResponse: googleapi.ServerResponse{
1157 Header: res.Header,
1158 HTTPStatusCode: res.StatusCode,
1159 },
1160 }
1161 target := &ret
1162 if err := gensupport.DecodeResponse(target, res); err != nil {
1163 return nil, err
1164 }
1165 return ret, nil
1166 }
1167
1168
1169
1170
1171 func (c *ProjectsLocationsOperationsListCall) Pages(ctx context.Context, f func(*ListOperationsResponse) error) error {
1172 c.ctx_ = ctx
1173 defer c.PageToken(c.urlParams_.Get("pageToken"))
1174 for {
1175 x, err := c.Do()
1176 if err != nil {
1177 return err
1178 }
1179 if err := f(x); err != nil {
1180 return err
1181 }
1182 if x.NextPageToken == "" {
1183 return nil
1184 }
1185 c.PageToken(x.NextPageToken)
1186 }
1187 }
1188
1189 type TextSynthesizeCall struct {
1190 s *Service
1191 synthesizespeechrequest *SynthesizeSpeechRequest
1192 urlParams_ gensupport.URLParams
1193 ctx_ context.Context
1194 header_ http.Header
1195 }
1196
1197
1198
1199 func (r *TextService) Synthesize(synthesizespeechrequest *SynthesizeSpeechRequest) *TextSynthesizeCall {
1200 c := &TextSynthesizeCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1201 c.synthesizespeechrequest = synthesizespeechrequest
1202 return c
1203 }
1204
1205
1206
1207
1208 func (c *TextSynthesizeCall) Fields(s ...googleapi.Field) *TextSynthesizeCall {
1209 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1210 return c
1211 }
1212
1213
1214 func (c *TextSynthesizeCall) Context(ctx context.Context) *TextSynthesizeCall {
1215 c.ctx_ = ctx
1216 return c
1217 }
1218
1219
1220
1221 func (c *TextSynthesizeCall) Header() http.Header {
1222 if c.header_ == nil {
1223 c.header_ = make(http.Header)
1224 }
1225 return c.header_
1226 }
1227
1228 func (c *TextSynthesizeCall) doRequest(alt string) (*http.Response, error) {
1229 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1230 var body io.Reader = nil
1231 body, err := googleapi.WithoutDataWrapper.JSONReader(c.synthesizespeechrequest)
1232 if err != nil {
1233 return nil, err
1234 }
1235 c.urlParams_.Set("alt", alt)
1236 c.urlParams_.Set("prettyPrint", "false")
1237 urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/text:synthesize")
1238 urls += "?" + c.urlParams_.Encode()
1239 req, err := http.NewRequest("POST", urls, body)
1240 if err != nil {
1241 return nil, err
1242 }
1243 req.Header = reqHeaders
1244 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1245 }
1246
1247
1248
1249
1250
1251
1252
1253 func (c *TextSynthesizeCall) Do(opts ...googleapi.CallOption) (*SynthesizeSpeechResponse, error) {
1254 gensupport.SetOptions(c.urlParams_, opts...)
1255 res, err := c.doRequest("json")
1256 if res != nil && res.StatusCode == http.StatusNotModified {
1257 if res.Body != nil {
1258 res.Body.Close()
1259 }
1260 return nil, gensupport.WrapError(&googleapi.Error{
1261 Code: res.StatusCode,
1262 Header: res.Header,
1263 })
1264 }
1265 if err != nil {
1266 return nil, err
1267 }
1268 defer googleapi.CloseBody(res)
1269 if err := googleapi.CheckResponse(res); err != nil {
1270 return nil, gensupport.WrapError(err)
1271 }
1272 ret := &SynthesizeSpeechResponse{
1273 ServerResponse: googleapi.ServerResponse{
1274 Header: res.Header,
1275 HTTPStatusCode: res.StatusCode,
1276 },
1277 }
1278 target := &ret
1279 if err := gensupport.DecodeResponse(target, res); err != nil {
1280 return nil, err
1281 }
1282 return ret, nil
1283 }
1284
1285 type VoicesListCall struct {
1286 s *Service
1287 urlParams_ gensupport.URLParams
1288 ifNoneMatch_ string
1289 ctx_ context.Context
1290 header_ http.Header
1291 }
1292
1293
1294 func (r *VoicesService) List() *VoicesListCall {
1295 c := &VoicesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1296 return c
1297 }
1298
1299
1300
1301
1302
1303
1304
1305
1306 func (c *VoicesListCall) LanguageCode(languageCode string) *VoicesListCall {
1307 c.urlParams_.Set("languageCode", languageCode)
1308 return c
1309 }
1310
1311
1312
1313
1314 func (c *VoicesListCall) Fields(s ...googleapi.Field) *VoicesListCall {
1315 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1316 return c
1317 }
1318
1319
1320
1321
1322 func (c *VoicesListCall) IfNoneMatch(entityTag string) *VoicesListCall {
1323 c.ifNoneMatch_ = entityTag
1324 return c
1325 }
1326
1327
1328 func (c *VoicesListCall) Context(ctx context.Context) *VoicesListCall {
1329 c.ctx_ = ctx
1330 return c
1331 }
1332
1333
1334
1335 func (c *VoicesListCall) Header() http.Header {
1336 if c.header_ == nil {
1337 c.header_ = make(http.Header)
1338 }
1339 return c.header_
1340 }
1341
1342 func (c *VoicesListCall) doRequest(alt string) (*http.Response, error) {
1343 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
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, "v1beta1/voices")
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
1360
1361
1362
1363
1364
1365
1366 func (c *VoicesListCall) Do(opts ...googleapi.CallOption) (*ListVoicesResponse, 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, gensupport.WrapError(&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, gensupport.WrapError(err)
1384 }
1385 ret := &ListVoicesResponse{
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
View as plain text