25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

111 lines
2.3 KiB

  1. // Copyright 2019 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Code generated by gapic-generator. DO NOT EDIT.
  15. package speech_test
  16. import (
  17. "context"
  18. "io"
  19. speech "cloud.google.com/go/speech/apiv1p1beta1"
  20. speechpb "google.golang.org/genproto/googleapis/cloud/speech/v1p1beta1"
  21. )
  22. func ExampleNewClient() {
  23. ctx := context.Background()
  24. c, err := speech.NewClient(ctx)
  25. if err != nil {
  26. // TODO: Handle error.
  27. }
  28. // TODO: Use client.
  29. _ = c
  30. }
  31. func ExampleClient_Recognize() {
  32. ctx := context.Background()
  33. c, err := speech.NewClient(ctx)
  34. if err != nil {
  35. // TODO: Handle error.
  36. }
  37. req := &speechpb.RecognizeRequest{
  38. // TODO: Fill request struct fields.
  39. }
  40. resp, err := c.Recognize(ctx, req)
  41. if err != nil {
  42. // TODO: Handle error.
  43. }
  44. // TODO: Use resp.
  45. _ = resp
  46. }
  47. func ExampleClient_LongRunningRecognize() {
  48. ctx := context.Background()
  49. c, err := speech.NewClient(ctx)
  50. if err != nil {
  51. // TODO: Handle error.
  52. }
  53. req := &speechpb.LongRunningRecognizeRequest{
  54. // TODO: Fill request struct fields.
  55. }
  56. op, err := c.LongRunningRecognize(ctx, req)
  57. if err != nil {
  58. // TODO: Handle error.
  59. }
  60. resp, err := op.Wait(ctx)
  61. if err != nil {
  62. // TODO: Handle error.
  63. }
  64. // TODO: Use resp.
  65. _ = resp
  66. }
  67. func ExampleClient_StreamingRecognize() {
  68. ctx := context.Background()
  69. c, err := speech.NewClient(ctx)
  70. if err != nil {
  71. // TODO: Handle error.
  72. }
  73. stream, err := c.StreamingRecognize(ctx)
  74. if err != nil {
  75. // TODO: Handle error.
  76. }
  77. go func() {
  78. reqs := []*speechpb.StreamingRecognizeRequest{
  79. // TODO: Create requests.
  80. }
  81. for _, req := range reqs {
  82. if err := stream.Send(req); err != nil {
  83. // TODO: Handle error.
  84. }
  85. }
  86. stream.CloseSend()
  87. }()
  88. for {
  89. resp, err := stream.Recv()
  90. if err == io.EOF {
  91. break
  92. }
  93. if err != nil {
  94. // TODO: handle error.
  95. }
  96. // TODO: Use resp.
  97. _ = resp
  98. }
  99. }