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

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