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:v1"
92 const apiName = "texttospeech"
93 const apiVersion = "v1"
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.Operations = NewOperationsService(s)
141 s.Projects = NewProjectsService(s)
142 s.Text = NewTextService(s)
143 s.Voices = NewVoicesService(s)
144 return s, nil
145 }
146
147 type Service struct {
148 client *http.Client
149 BasePath string
150 UserAgent string
151
152 Operations *OperationsService
153
154 Projects *ProjectsService
155
156 Text *TextService
157
158 Voices *VoicesService
159 }
160
161 func (s *Service) userAgent() string {
162 if s.UserAgent == "" {
163 return googleapi.UserAgent
164 }
165 return googleapi.UserAgent + " " + s.UserAgent
166 }
167
168 func NewOperationsService(s *Service) *OperationsService {
169 rs := &OperationsService{s: s}
170 return rs
171 }
172
173 type OperationsService struct {
174 s *Service
175 }
176
177 func NewProjectsService(s *Service) *ProjectsService {
178 rs := &ProjectsService{s: s}
179 rs.Locations = NewProjectsLocationsService(s)
180 return rs
181 }
182
183 type ProjectsService struct {
184 s *Service
185
186 Locations *ProjectsLocationsService
187 }
188
189 func NewProjectsLocationsService(s *Service) *ProjectsLocationsService {
190 rs := &ProjectsLocationsService{s: s}
191 rs.Operations = NewProjectsLocationsOperationsService(s)
192 return rs
193 }
194
195 type ProjectsLocationsService struct {
196 s *Service
197
198 Operations *ProjectsLocationsOperationsService
199 }
200
201 func NewProjectsLocationsOperationsService(s *Service) *ProjectsLocationsOperationsService {
202 rs := &ProjectsLocationsOperationsService{s: s}
203 return rs
204 }
205
206 type ProjectsLocationsOperationsService struct {
207 s *Service
208 }
209
210 func NewTextService(s *Service) *TextService {
211 rs := &TextService{s: s}
212 return rs
213 }
214
215 type TextService struct {
216 s *Service
217 }
218
219 func NewVoicesService(s *Service) *VoicesService {
220 rs := &VoicesService{s: s}
221 return rs
222 }
223
224 type VoicesService struct {
225 s *Service
226 }
227
228
229 type AudioConfig struct {
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246 AudioEncoding string `json:"audioEncoding,omitempty"`
247
248
249
250
251
252 EffectsProfileId []string `json:"effectsProfileId,omitempty"`
253
254
255
256 Pitch float64 `json:"pitch,omitempty"`
257
258
259
260
261
262
263
264 SampleRateHertz int64 `json:"sampleRateHertz,omitempty"`
265
266
267
268
269 SpeakingRate float64 `json:"speakingRate,omitempty"`
270
271
272
273
274
275
276
277
278 VolumeGainDb float64 `json:"volumeGainDb,omitempty"`
279
280
281
282
283
284 ForceSendFields []string `json:"-"`
285
286
287
288
289 NullFields []string `json:"-"`
290 }
291
292 func (s *AudioConfig) MarshalJSON() ([]byte, error) {
293 type NoMethod AudioConfig
294 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
295 }
296
297 func (s *AudioConfig) UnmarshalJSON(data []byte) error {
298 type NoMethod AudioConfig
299 var s1 struct {
300 Pitch gensupport.JSONFloat64 `json:"pitch"`
301 SpeakingRate gensupport.JSONFloat64 `json:"speakingRate"`
302 VolumeGainDb gensupport.JSONFloat64 `json:"volumeGainDb"`
303 *NoMethod
304 }
305 s1.NoMethod = (*NoMethod)(s)
306 if err := json.Unmarshal(data, &s1); err != nil {
307 return err
308 }
309 s.Pitch = float64(s1.Pitch)
310 s.SpeakingRate = float64(s1.SpeakingRate)
311 s.VolumeGainDb = float64(s1.VolumeGainDb)
312 return nil
313 }
314
315
316 type CancelOperationRequest struct {
317 }
318
319
320 type CustomVoiceParams struct {
321
322
323 Model string `json:"model,omitempty"`
324
325
326
327
328
329
330
331
332
333
334
335 ReportedUsage string `json:"reportedUsage,omitempty"`
336
337
338
339
340
341 ForceSendFields []string `json:"-"`
342
343
344
345
346 NullFields []string `json:"-"`
347 }
348
349 func (s *CustomVoiceParams) MarshalJSON() ([]byte, error) {
350 type NoMethod CustomVoiceParams
351 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
352 }
353
354
355
356
357
358 type Empty struct {
359
360 googleapi.ServerResponse `json:"-"`
361 }
362
363
364
365 type GoogleCloudTexttospeechV1SynthesizeLongAudioMetadata struct {
366
367 LastUpdateTime string `json:"lastUpdateTime,omitempty"`
368
369
370 ProgressPercentage float64 `json:"progressPercentage,omitempty"`
371
372 StartTime string `json:"startTime,omitempty"`
373
374
375
376
377
378 ForceSendFields []string `json:"-"`
379
380
381
382
383 NullFields []string `json:"-"`
384 }
385
386 func (s *GoogleCloudTexttospeechV1SynthesizeLongAudioMetadata) MarshalJSON() ([]byte, error) {
387 type NoMethod GoogleCloudTexttospeechV1SynthesizeLongAudioMetadata
388 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
389 }
390
391 func (s *GoogleCloudTexttospeechV1SynthesizeLongAudioMetadata) UnmarshalJSON(data []byte) error {
392 type NoMethod GoogleCloudTexttospeechV1SynthesizeLongAudioMetadata
393 var s1 struct {
394 ProgressPercentage gensupport.JSONFloat64 `json:"progressPercentage"`
395 *NoMethod
396 }
397 s1.NoMethod = (*NoMethod)(s)
398 if err := json.Unmarshal(data, &s1); err != nil {
399 return err
400 }
401 s.ProgressPercentage = float64(s1.ProgressPercentage)
402 return nil
403 }
404
405
406 type ListOperationsResponse struct {
407
408 NextPageToken string `json:"nextPageToken,omitempty"`
409
410
411 Operations []*Operation `json:"operations,omitempty"`
412
413
414 googleapi.ServerResponse `json:"-"`
415
416
417
418
419
420 ForceSendFields []string `json:"-"`
421
422
423
424
425 NullFields []string `json:"-"`
426 }
427
428 func (s *ListOperationsResponse) MarshalJSON() ([]byte, error) {
429 type NoMethod ListOperationsResponse
430 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
431 }
432
433
434
435 type ListVoicesResponse struct {
436
437 Voices []*Voice `json:"voices,omitempty"`
438
439
440 googleapi.ServerResponse `json:"-"`
441
442
443
444
445
446 ForceSendFields []string `json:"-"`
447
448
449
450
451 NullFields []string `json:"-"`
452 }
453
454 func (s *ListVoicesResponse) MarshalJSON() ([]byte, error) {
455 type NoMethod ListVoicesResponse
456 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
457 }
458
459
460
461 type Operation struct {
462
463
464
465 Done bool `json:"done,omitempty"`
466
467 Error *Status `json:"error,omitempty"`
468
469
470
471
472 Metadata googleapi.RawMessage `json:"metadata,omitempty"`
473
474
475
476 Name string `json:"name,omitempty"`
477
478
479
480
481
482
483
484 Response googleapi.RawMessage `json:"response,omitempty"`
485
486
487 googleapi.ServerResponse `json:"-"`
488
489
490
491
492
493 ForceSendFields []string `json:"-"`
494
495
496
497
498 NullFields []string `json:"-"`
499 }
500
501 func (s *Operation) MarshalJSON() ([]byte, error) {
502 type NoMethod Operation
503 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
504 }
505
506
507
508
509
510
511
512 type Status struct {
513
514 Code int64 `json:"code,omitempty"`
515
516
517 Details []googleapi.RawMessage `json:"details,omitempty"`
518
519
520
521 Message string `json:"message,omitempty"`
522
523
524
525
526
527 ForceSendFields []string `json:"-"`
528
529
530
531
532 NullFields []string `json:"-"`
533 }
534
535 func (s *Status) MarshalJSON() ([]byte, error) {
536 type NoMethod Status
537 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
538 }
539
540
541
542
543 type SynthesisInput struct {
544
545
546
547
548 Ssml string `json:"ssml,omitempty"`
549
550 Text string `json:"text,omitempty"`
551
552
553
554
555
556 ForceSendFields []string `json:"-"`
557
558
559
560
561 NullFields []string `json:"-"`
562 }
563
564 func (s *SynthesisInput) MarshalJSON() ([]byte, error) {
565 type NoMethod SynthesisInput
566 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
567 }
568
569
570
571 type SynthesizeLongAudioMetadata struct {
572
573 LastUpdateTime string `json:"lastUpdateTime,omitempty"`
574
575
576 ProgressPercentage float64 `json:"progressPercentage,omitempty"`
577
578 StartTime string `json:"startTime,omitempty"`
579
580
581
582
583
584 ForceSendFields []string `json:"-"`
585
586
587
588
589 NullFields []string `json:"-"`
590 }
591
592 func (s *SynthesizeLongAudioMetadata) MarshalJSON() ([]byte, error) {
593 type NoMethod SynthesizeLongAudioMetadata
594 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
595 }
596
597 func (s *SynthesizeLongAudioMetadata) UnmarshalJSON(data []byte) error {
598 type NoMethod SynthesizeLongAudioMetadata
599 var s1 struct {
600 ProgressPercentage gensupport.JSONFloat64 `json:"progressPercentage"`
601 *NoMethod
602 }
603 s1.NoMethod = (*NoMethod)(s)
604 if err := json.Unmarshal(data, &s1); err != nil {
605 return err
606 }
607 s.ProgressPercentage = float64(s1.ProgressPercentage)
608 return nil
609 }
610
611
612
613 type SynthesizeLongAudioRequest struct {
614
615 AudioConfig *AudioConfig `json:"audioConfig,omitempty"`
616
617
618 Input *SynthesisInput `json:"input,omitempty"`
619
620
621
622 OutputGcsUri string `json:"outputGcsUri,omitempty"`
623
624 Voice *VoiceSelectionParams `json:"voice,omitempty"`
625
626
627
628
629
630 ForceSendFields []string `json:"-"`
631
632
633
634
635 NullFields []string `json:"-"`
636 }
637
638 func (s *SynthesizeLongAudioRequest) MarshalJSON() ([]byte, error) {
639 type NoMethod SynthesizeLongAudioRequest
640 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
641 }
642
643
644
645 type SynthesizeSpeechRequest struct {
646
647 AudioConfig *AudioConfig `json:"audioConfig,omitempty"`
648
649
650 Input *SynthesisInput `json:"input,omitempty"`
651
652 Voice *VoiceSelectionParams `json:"voice,omitempty"`
653
654
655
656
657
658 ForceSendFields []string `json:"-"`
659
660
661
662
663 NullFields []string `json:"-"`
664 }
665
666 func (s *SynthesizeSpeechRequest) MarshalJSON() ([]byte, error) {
667 type NoMethod SynthesizeSpeechRequest
668 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
669 }
670
671
672
673 type SynthesizeSpeechResponse struct {
674
675
676
677
678
679 AudioContent string `json:"audioContent,omitempty"`
680
681
682 googleapi.ServerResponse `json:"-"`
683
684
685
686
687
688 ForceSendFields []string `json:"-"`
689
690
691
692
693 NullFields []string `json:"-"`
694 }
695
696 func (s *SynthesizeSpeechResponse) MarshalJSON() ([]byte, error) {
697 type NoMethod SynthesizeSpeechResponse
698 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
699 }
700
701
702 type Voice struct {
703
704
705
706 LanguageCodes []string `json:"languageCodes,omitempty"`
707
708 Name string `json:"name,omitempty"`
709
710 NaturalSampleRateHertz int64 `json:"naturalSampleRateHertz,omitempty"`
711
712
713
714
715
716
717
718
719
720
721
722 SsmlGender string `json:"ssmlGender,omitempty"`
723
724
725
726
727
728 ForceSendFields []string `json:"-"`
729
730
731
732
733 NullFields []string `json:"-"`
734 }
735
736 func (s *Voice) MarshalJSON() ([]byte, error) {
737 type NoMethod Voice
738 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
739 }
740
741
742
743 type VoiceSelectionParams struct {
744
745
746
747 CustomVoice *CustomVoiceParams `json:"customVoice,omitempty"`
748
749
750
751
752
753
754
755
756
757
758
759 LanguageCode string `json:"languageCode,omitempty"`
760
761
762
763 Name string `json:"name,omitempty"`
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779 SsmlGender string `json:"ssmlGender,omitempty"`
780
781
782
783
784
785 ForceSendFields []string `json:"-"`
786
787
788
789
790 NullFields []string `json:"-"`
791 }
792
793 func (s *VoiceSelectionParams) MarshalJSON() ([]byte, error) {
794 type NoMethod VoiceSelectionParams
795 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields)
796 }
797
798 type OperationsCancelCall struct {
799 s *Service
800 name string
801 canceloperationrequest *CancelOperationRequest
802 urlParams_ gensupport.URLParams
803 ctx_ context.Context
804 header_ http.Header
805 }
806
807
808
809
810
811
812
813
814
815
816
817
818 func (r *OperationsService) Cancel(name string, canceloperationrequest *CancelOperationRequest) *OperationsCancelCall {
819 c := &OperationsCancelCall{s: r.s, urlParams_: make(gensupport.URLParams)}
820 c.name = name
821 c.canceloperationrequest = canceloperationrequest
822 return c
823 }
824
825
826
827
828 func (c *OperationsCancelCall) Fields(s ...googleapi.Field) *OperationsCancelCall {
829 c.urlParams_.Set("fields", googleapi.CombineFields(s))
830 return c
831 }
832
833
834 func (c *OperationsCancelCall) Context(ctx context.Context) *OperationsCancelCall {
835 c.ctx_ = ctx
836 return c
837 }
838
839
840
841 func (c *OperationsCancelCall) Header() http.Header {
842 if c.header_ == nil {
843 c.header_ = make(http.Header)
844 }
845 return c.header_
846 }
847
848 func (c *OperationsCancelCall) doRequest(alt string) (*http.Response, error) {
849 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
850 var body io.Reader = nil
851 body, err := googleapi.WithoutDataWrapper.JSONReader(c.canceloperationrequest)
852 if err != nil {
853 return nil, err
854 }
855 c.urlParams_.Set("alt", alt)
856 c.urlParams_.Set("prettyPrint", "false")
857 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:cancel")
858 urls += "?" + c.urlParams_.Encode()
859 req, err := http.NewRequest("POST", urls, body)
860 if err != nil {
861 return nil, err
862 }
863 req.Header = reqHeaders
864 googleapi.Expand(req.URL, map[string]string{
865 "name": c.name,
866 })
867 return gensupport.SendRequest(c.ctx_, c.s.client, req)
868 }
869
870
871
872
873
874
875 func (c *OperationsCancelCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
876 gensupport.SetOptions(c.urlParams_, opts...)
877 res, err := c.doRequest("json")
878 if res != nil && res.StatusCode == http.StatusNotModified {
879 if res.Body != nil {
880 res.Body.Close()
881 }
882 return nil, gensupport.WrapError(&googleapi.Error{
883 Code: res.StatusCode,
884 Header: res.Header,
885 })
886 }
887 if err != nil {
888 return nil, err
889 }
890 defer googleapi.CloseBody(res)
891 if err := googleapi.CheckResponse(res); err != nil {
892 return nil, gensupport.WrapError(err)
893 }
894 ret := &Empty{
895 ServerResponse: googleapi.ServerResponse{
896 Header: res.Header,
897 HTTPStatusCode: res.StatusCode,
898 },
899 }
900 target := &ret
901 if err := gensupport.DecodeResponse(target, res); err != nil {
902 return nil, err
903 }
904 return ret, nil
905 }
906
907 type OperationsDeleteCall struct {
908 s *Service
909 name string
910 urlParams_ gensupport.URLParams
911 ctx_ context.Context
912 header_ http.Header
913 }
914
915
916
917
918
919
920
921 func (r *OperationsService) Delete(name string) *OperationsDeleteCall {
922 c := &OperationsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
923 c.name = name
924 return c
925 }
926
927
928
929
930 func (c *OperationsDeleteCall) Fields(s ...googleapi.Field) *OperationsDeleteCall {
931 c.urlParams_.Set("fields", googleapi.CombineFields(s))
932 return c
933 }
934
935
936 func (c *OperationsDeleteCall) Context(ctx context.Context) *OperationsDeleteCall {
937 c.ctx_ = ctx
938 return c
939 }
940
941
942
943 func (c *OperationsDeleteCall) Header() http.Header {
944 if c.header_ == nil {
945 c.header_ = make(http.Header)
946 }
947 return c.header_
948 }
949
950 func (c *OperationsDeleteCall) doRequest(alt string) (*http.Response, error) {
951 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
952 var body io.Reader = nil
953 c.urlParams_.Set("alt", alt)
954 c.urlParams_.Set("prettyPrint", "false")
955 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
956 urls += "?" + c.urlParams_.Encode()
957 req, err := http.NewRequest("DELETE", urls, body)
958 if err != nil {
959 return nil, err
960 }
961 req.Header = reqHeaders
962 googleapi.Expand(req.URL, map[string]string{
963 "name": c.name,
964 })
965 return gensupport.SendRequest(c.ctx_, c.s.client, req)
966 }
967
968
969
970
971
972
973 func (c *OperationsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
974 gensupport.SetOptions(c.urlParams_, opts...)
975 res, err := c.doRequest("json")
976 if res != nil && res.StatusCode == http.StatusNotModified {
977 if res.Body != nil {
978 res.Body.Close()
979 }
980 return nil, gensupport.WrapError(&googleapi.Error{
981 Code: res.StatusCode,
982 Header: res.Header,
983 })
984 }
985 if err != nil {
986 return nil, err
987 }
988 defer googleapi.CloseBody(res)
989 if err := googleapi.CheckResponse(res); err != nil {
990 return nil, gensupport.WrapError(err)
991 }
992 ret := &Empty{
993 ServerResponse: googleapi.ServerResponse{
994 Header: res.Header,
995 HTTPStatusCode: res.StatusCode,
996 },
997 }
998 target := &ret
999 if err := gensupport.DecodeResponse(target, res); err != nil {
1000 return nil, err
1001 }
1002 return ret, nil
1003 }
1004
1005 type ProjectsLocationsSynthesizeLongAudioCall struct {
1006 s *Service
1007 parent string
1008 synthesizelongaudiorequest *SynthesizeLongAudioRequest
1009 urlParams_ gensupport.URLParams
1010 ctx_ context.Context
1011 header_ http.Header
1012 }
1013
1014
1015
1016
1017
1018 func (r *ProjectsLocationsService) SynthesizeLongAudio(parent string, synthesizelongaudiorequest *SynthesizeLongAudioRequest) *ProjectsLocationsSynthesizeLongAudioCall {
1019 c := &ProjectsLocationsSynthesizeLongAudioCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1020 c.parent = parent
1021 c.synthesizelongaudiorequest = synthesizelongaudiorequest
1022 return c
1023 }
1024
1025
1026
1027
1028 func (c *ProjectsLocationsSynthesizeLongAudioCall) Fields(s ...googleapi.Field) *ProjectsLocationsSynthesizeLongAudioCall {
1029 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1030 return c
1031 }
1032
1033
1034 func (c *ProjectsLocationsSynthesizeLongAudioCall) Context(ctx context.Context) *ProjectsLocationsSynthesizeLongAudioCall {
1035 c.ctx_ = ctx
1036 return c
1037 }
1038
1039
1040
1041 func (c *ProjectsLocationsSynthesizeLongAudioCall) Header() http.Header {
1042 if c.header_ == nil {
1043 c.header_ = make(http.Header)
1044 }
1045 return c.header_
1046 }
1047
1048 func (c *ProjectsLocationsSynthesizeLongAudioCall) doRequest(alt string) (*http.Response, error) {
1049 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1050 var body io.Reader = nil
1051 body, err := googleapi.WithoutDataWrapper.JSONReader(c.synthesizelongaudiorequest)
1052 if err != nil {
1053 return nil, err
1054 }
1055 c.urlParams_.Set("alt", alt)
1056 c.urlParams_.Set("prettyPrint", "false")
1057 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}:synthesizeLongAudio")
1058 urls += "?" + c.urlParams_.Encode()
1059 req, err := http.NewRequest("POST", urls, body)
1060 if err != nil {
1061 return nil, err
1062 }
1063 req.Header = reqHeaders
1064 googleapi.Expand(req.URL, map[string]string{
1065 "parent": c.parent,
1066 })
1067 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1068 }
1069
1070
1071
1072
1073
1074
1075 func (c *ProjectsLocationsSynthesizeLongAudioCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
1076 gensupport.SetOptions(c.urlParams_, opts...)
1077 res, err := c.doRequest("json")
1078 if res != nil && res.StatusCode == http.StatusNotModified {
1079 if res.Body != nil {
1080 res.Body.Close()
1081 }
1082 return nil, gensupport.WrapError(&googleapi.Error{
1083 Code: res.StatusCode,
1084 Header: res.Header,
1085 })
1086 }
1087 if err != nil {
1088 return nil, err
1089 }
1090 defer googleapi.CloseBody(res)
1091 if err := googleapi.CheckResponse(res); err != nil {
1092 return nil, gensupport.WrapError(err)
1093 }
1094 ret := &Operation{
1095 ServerResponse: googleapi.ServerResponse{
1096 Header: res.Header,
1097 HTTPStatusCode: res.StatusCode,
1098 },
1099 }
1100 target := &ret
1101 if err := gensupport.DecodeResponse(target, res); err != nil {
1102 return nil, err
1103 }
1104 return ret, nil
1105 }
1106
1107 type ProjectsLocationsOperationsGetCall struct {
1108 s *Service
1109 name string
1110 urlParams_ gensupport.URLParams
1111 ifNoneMatch_ string
1112 ctx_ context.Context
1113 header_ http.Header
1114 }
1115
1116
1117
1118
1119
1120
1121 func (r *ProjectsLocationsOperationsService) Get(name string) *ProjectsLocationsOperationsGetCall {
1122 c := &ProjectsLocationsOperationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1123 c.name = name
1124 return c
1125 }
1126
1127
1128
1129
1130 func (c *ProjectsLocationsOperationsGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsOperationsGetCall {
1131 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1132 return c
1133 }
1134
1135
1136
1137
1138 func (c *ProjectsLocationsOperationsGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsOperationsGetCall {
1139 c.ifNoneMatch_ = entityTag
1140 return c
1141 }
1142
1143
1144 func (c *ProjectsLocationsOperationsGetCall) Context(ctx context.Context) *ProjectsLocationsOperationsGetCall {
1145 c.ctx_ = ctx
1146 return c
1147 }
1148
1149
1150
1151 func (c *ProjectsLocationsOperationsGetCall) Header() http.Header {
1152 if c.header_ == nil {
1153 c.header_ = make(http.Header)
1154 }
1155 return c.header_
1156 }
1157
1158 func (c *ProjectsLocationsOperationsGetCall) doRequest(alt string) (*http.Response, error) {
1159 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1160 if c.ifNoneMatch_ != "" {
1161 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1162 }
1163 var body io.Reader = nil
1164 c.urlParams_.Set("alt", alt)
1165 c.urlParams_.Set("prettyPrint", "false")
1166 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
1167 urls += "?" + c.urlParams_.Encode()
1168 req, err := http.NewRequest("GET", urls, body)
1169 if err != nil {
1170 return nil, err
1171 }
1172 req.Header = reqHeaders
1173 googleapi.Expand(req.URL, map[string]string{
1174 "name": c.name,
1175 })
1176 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1177 }
1178
1179
1180
1181
1182
1183
1184 func (c *ProjectsLocationsOperationsGetCall) Do(opts ...googleapi.CallOption) (*Operation, error) {
1185 gensupport.SetOptions(c.urlParams_, opts...)
1186 res, err := c.doRequest("json")
1187 if res != nil && res.StatusCode == http.StatusNotModified {
1188 if res.Body != nil {
1189 res.Body.Close()
1190 }
1191 return nil, gensupport.WrapError(&googleapi.Error{
1192 Code: res.StatusCode,
1193 Header: res.Header,
1194 })
1195 }
1196 if err != nil {
1197 return nil, err
1198 }
1199 defer googleapi.CloseBody(res)
1200 if err := googleapi.CheckResponse(res); err != nil {
1201 return nil, gensupport.WrapError(err)
1202 }
1203 ret := &Operation{
1204 ServerResponse: googleapi.ServerResponse{
1205 Header: res.Header,
1206 HTTPStatusCode: res.StatusCode,
1207 },
1208 }
1209 target := &ret
1210 if err := gensupport.DecodeResponse(target, res); err != nil {
1211 return nil, err
1212 }
1213 return ret, nil
1214 }
1215
1216 type ProjectsLocationsOperationsListCall struct {
1217 s *Service
1218 name string
1219 urlParams_ gensupport.URLParams
1220 ifNoneMatch_ string
1221 ctx_ context.Context
1222 header_ http.Header
1223 }
1224
1225
1226
1227
1228
1229 func (r *ProjectsLocationsOperationsService) List(name string) *ProjectsLocationsOperationsListCall {
1230 c := &ProjectsLocationsOperationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1231 c.name = name
1232 return c
1233 }
1234
1235
1236 func (c *ProjectsLocationsOperationsListCall) Filter(filter string) *ProjectsLocationsOperationsListCall {
1237 c.urlParams_.Set("filter", filter)
1238 return c
1239 }
1240
1241
1242
1243 func (c *ProjectsLocationsOperationsListCall) PageSize(pageSize int64) *ProjectsLocationsOperationsListCall {
1244 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
1245 return c
1246 }
1247
1248
1249
1250 func (c *ProjectsLocationsOperationsListCall) PageToken(pageToken string) *ProjectsLocationsOperationsListCall {
1251 c.urlParams_.Set("pageToken", pageToken)
1252 return c
1253 }
1254
1255
1256
1257
1258 func (c *ProjectsLocationsOperationsListCall) Fields(s ...googleapi.Field) *ProjectsLocationsOperationsListCall {
1259 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1260 return c
1261 }
1262
1263
1264
1265
1266 func (c *ProjectsLocationsOperationsListCall) IfNoneMatch(entityTag string) *ProjectsLocationsOperationsListCall {
1267 c.ifNoneMatch_ = entityTag
1268 return c
1269 }
1270
1271
1272 func (c *ProjectsLocationsOperationsListCall) Context(ctx context.Context) *ProjectsLocationsOperationsListCall {
1273 c.ctx_ = ctx
1274 return c
1275 }
1276
1277
1278
1279 func (c *ProjectsLocationsOperationsListCall) Header() http.Header {
1280 if c.header_ == nil {
1281 c.header_ = make(http.Header)
1282 }
1283 return c.header_
1284 }
1285
1286 func (c *ProjectsLocationsOperationsListCall) doRequest(alt string) (*http.Response, error) {
1287 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1288 if c.ifNoneMatch_ != "" {
1289 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1290 }
1291 var body io.Reader = nil
1292 c.urlParams_.Set("alt", alt)
1293 c.urlParams_.Set("prettyPrint", "false")
1294 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}/operations")
1295 urls += "?" + c.urlParams_.Encode()
1296 req, err := http.NewRequest("GET", urls, body)
1297 if err != nil {
1298 return nil, err
1299 }
1300 req.Header = reqHeaders
1301 googleapi.Expand(req.URL, map[string]string{
1302 "name": c.name,
1303 })
1304 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1305 }
1306
1307
1308
1309
1310
1311
1312
1313 func (c *ProjectsLocationsOperationsListCall) Do(opts ...googleapi.CallOption) (*ListOperationsResponse, error) {
1314 gensupport.SetOptions(c.urlParams_, opts...)
1315 res, err := c.doRequest("json")
1316 if res != nil && res.StatusCode == http.StatusNotModified {
1317 if res.Body != nil {
1318 res.Body.Close()
1319 }
1320 return nil, gensupport.WrapError(&googleapi.Error{
1321 Code: res.StatusCode,
1322 Header: res.Header,
1323 })
1324 }
1325 if err != nil {
1326 return nil, err
1327 }
1328 defer googleapi.CloseBody(res)
1329 if err := googleapi.CheckResponse(res); err != nil {
1330 return nil, gensupport.WrapError(err)
1331 }
1332 ret := &ListOperationsResponse{
1333 ServerResponse: googleapi.ServerResponse{
1334 Header: res.Header,
1335 HTTPStatusCode: res.StatusCode,
1336 },
1337 }
1338 target := &ret
1339 if err := gensupport.DecodeResponse(target, res); err != nil {
1340 return nil, err
1341 }
1342 return ret, nil
1343 }
1344
1345
1346
1347
1348 func (c *ProjectsLocationsOperationsListCall) Pages(ctx context.Context, f func(*ListOperationsResponse) error) error {
1349 c.ctx_ = ctx
1350 defer c.PageToken(c.urlParams_.Get("pageToken"))
1351 for {
1352 x, err := c.Do()
1353 if err != nil {
1354 return err
1355 }
1356 if err := f(x); err != nil {
1357 return err
1358 }
1359 if x.NextPageToken == "" {
1360 return nil
1361 }
1362 c.PageToken(x.NextPageToken)
1363 }
1364 }
1365
1366 type TextSynthesizeCall struct {
1367 s *Service
1368 synthesizespeechrequest *SynthesizeSpeechRequest
1369 urlParams_ gensupport.URLParams
1370 ctx_ context.Context
1371 header_ http.Header
1372 }
1373
1374
1375
1376 func (r *TextService) Synthesize(synthesizespeechrequest *SynthesizeSpeechRequest) *TextSynthesizeCall {
1377 c := &TextSynthesizeCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1378 c.synthesizespeechrequest = synthesizespeechrequest
1379 return c
1380 }
1381
1382
1383
1384
1385 func (c *TextSynthesizeCall) Fields(s ...googleapi.Field) *TextSynthesizeCall {
1386 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1387 return c
1388 }
1389
1390
1391 func (c *TextSynthesizeCall) Context(ctx context.Context) *TextSynthesizeCall {
1392 c.ctx_ = ctx
1393 return c
1394 }
1395
1396
1397
1398 func (c *TextSynthesizeCall) Header() http.Header {
1399 if c.header_ == nil {
1400 c.header_ = make(http.Header)
1401 }
1402 return c.header_
1403 }
1404
1405 func (c *TextSynthesizeCall) doRequest(alt string) (*http.Response, error) {
1406 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1407 var body io.Reader = nil
1408 body, err := googleapi.WithoutDataWrapper.JSONReader(c.synthesizespeechrequest)
1409 if err != nil {
1410 return nil, err
1411 }
1412 c.urlParams_.Set("alt", alt)
1413 c.urlParams_.Set("prettyPrint", "false")
1414 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/text:synthesize")
1415 urls += "?" + c.urlParams_.Encode()
1416 req, err := http.NewRequest("POST", urls, body)
1417 if err != nil {
1418 return nil, err
1419 }
1420 req.Header = reqHeaders
1421 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1422 }
1423
1424
1425
1426
1427
1428
1429
1430 func (c *TextSynthesizeCall) Do(opts ...googleapi.CallOption) (*SynthesizeSpeechResponse, error) {
1431 gensupport.SetOptions(c.urlParams_, opts...)
1432 res, err := c.doRequest("json")
1433 if res != nil && res.StatusCode == http.StatusNotModified {
1434 if res.Body != nil {
1435 res.Body.Close()
1436 }
1437 return nil, gensupport.WrapError(&googleapi.Error{
1438 Code: res.StatusCode,
1439 Header: res.Header,
1440 })
1441 }
1442 if err != nil {
1443 return nil, err
1444 }
1445 defer googleapi.CloseBody(res)
1446 if err := googleapi.CheckResponse(res); err != nil {
1447 return nil, gensupport.WrapError(err)
1448 }
1449 ret := &SynthesizeSpeechResponse{
1450 ServerResponse: googleapi.ServerResponse{
1451 Header: res.Header,
1452 HTTPStatusCode: res.StatusCode,
1453 },
1454 }
1455 target := &ret
1456 if err := gensupport.DecodeResponse(target, res); err != nil {
1457 return nil, err
1458 }
1459 return ret, nil
1460 }
1461
1462 type VoicesListCall struct {
1463 s *Service
1464 urlParams_ gensupport.URLParams
1465 ifNoneMatch_ string
1466 ctx_ context.Context
1467 header_ http.Header
1468 }
1469
1470
1471 func (r *VoicesService) List() *VoicesListCall {
1472 c := &VoicesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1473 return c
1474 }
1475
1476
1477
1478
1479
1480
1481
1482
1483 func (c *VoicesListCall) LanguageCode(languageCode string) *VoicesListCall {
1484 c.urlParams_.Set("languageCode", languageCode)
1485 return c
1486 }
1487
1488
1489
1490
1491 func (c *VoicesListCall) Fields(s ...googleapi.Field) *VoicesListCall {
1492 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1493 return c
1494 }
1495
1496
1497
1498
1499 func (c *VoicesListCall) IfNoneMatch(entityTag string) *VoicesListCall {
1500 c.ifNoneMatch_ = entityTag
1501 return c
1502 }
1503
1504
1505 func (c *VoicesListCall) Context(ctx context.Context) *VoicesListCall {
1506 c.ctx_ = ctx
1507 return c
1508 }
1509
1510
1511
1512 func (c *VoicesListCall) Header() http.Header {
1513 if c.header_ == nil {
1514 c.header_ = make(http.Header)
1515 }
1516 return c.header_
1517 }
1518
1519 func (c *VoicesListCall) doRequest(alt string) (*http.Response, error) {
1520 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1521 if c.ifNoneMatch_ != "" {
1522 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1523 }
1524 var body io.Reader = nil
1525 c.urlParams_.Set("alt", alt)
1526 c.urlParams_.Set("prettyPrint", "false")
1527 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/voices")
1528 urls += "?" + c.urlParams_.Encode()
1529 req, err := http.NewRequest("GET", urls, body)
1530 if err != nil {
1531 return nil, err
1532 }
1533 req.Header = reqHeaders
1534 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1535 }
1536
1537
1538
1539
1540
1541
1542
1543 func (c *VoicesListCall) Do(opts ...googleapi.CallOption) (*ListVoicesResponse, error) {
1544 gensupport.SetOptions(c.urlParams_, opts...)
1545 res, err := c.doRequest("json")
1546 if res != nil && res.StatusCode == http.StatusNotModified {
1547 if res.Body != nil {
1548 res.Body.Close()
1549 }
1550 return nil, gensupport.WrapError(&googleapi.Error{
1551 Code: res.StatusCode,
1552 Header: res.Header,
1553 })
1554 }
1555 if err != nil {
1556 return nil, err
1557 }
1558 defer googleapi.CloseBody(res)
1559 if err := googleapi.CheckResponse(res); err != nil {
1560 return nil, gensupport.WrapError(err)
1561 }
1562 ret := &ListVoicesResponse{
1563 ServerResponse: googleapi.ServerResponse{
1564 Header: res.Header,
1565 HTTPStatusCode: res.StatusCode,
1566 },
1567 }
1568 target := &ret
1569 if err := gensupport.DecodeResponse(target, res); err != nil {
1570 return nil, err
1571 }
1572 return ret, nil
1573 }
1574
View as plain text