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 15// Code generated by gapic-generator. DO NOT EDIT. 16 17package speech 18 19import ( 20 "context" 21 "fmt" 22 "strconv" 23 "testing" 24 "time" 25 26 "cloud.google.com/go/internal/testutil" 27 "google.golang.org/api/iterator" 28 "google.golang.org/api/option" 29 speechpb "google.golang.org/genproto/googleapis/cloud/speech/v1" 30) 31 32var _ = fmt.Sprintf 33var _ = iterator.Done 34var _ = strconv.FormatUint 35var _ = time.Now 36 37func TestSpeechSmoke(t *testing.T) { 38 if testing.Short() { 39 t.Skip("skipping smoke test in short mode") 40 } 41 ctx := context.Background() 42 ts := testutil.TokenSource(ctx, DefaultAuthScopes()...) 43 if ts == nil { 44 t.Skip("Integration tests skipped. See CONTRIBUTING.md for details") 45 } 46 47 projectId := testutil.ProjID() 48 _ = projectId 49 50 c, err := NewClient(ctx, option.WithTokenSource(ts)) 51 if err != nil { 52 t.Fatal(err) 53 } 54 55 var languageCode string = "en-US" 56 var sampleRateHertz int32 = 44100 57 var encoding speechpb.RecognitionConfig_AudioEncoding = speechpb.RecognitionConfig_FLAC 58 var config = &speechpb.RecognitionConfig{ 59 LanguageCode: languageCode, 60 SampleRateHertz: sampleRateHertz, 61 Encoding: encoding, 62 AudioChannelCount: 2, 63 } 64 var uri string = "gs://cloud-samples-data/speech/hello.flac" 65 var audio = &speechpb.RecognitionAudio{ 66 AudioSource: &speechpb.RecognitionAudio_Uri{ 67 Uri: uri, 68 }, 69 } 70 var request = &speechpb.RecognizeRequest{ 71 Config: config, 72 Audio: audio, 73 } 74 75 if _, err := c.Recognize(ctx, request); err != nil { 76 t.Error(err) 77 } 78} 79