Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inability to Modify SpeechClient Endpoint in C++ Client Leads to Global Region Lock #13729

Closed
jiahansu opened this issue Mar 5, 2024 · 2 comments
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@jiahansu
Copy link

jiahansu commented Mar 5, 2024

Does this issue affect the google-cloud-cpp project?
Yes, the same operations execute successfully in the Python and Node.js clients, yet they encounter failure when attempted with the C++ client

What component of google-cloud-cpp is this related to?
google/cloud/speech/v2

Describe the bug
When using the Google Cloud Speech-to-Text C++ client, it appears impossible to modify the SpeechClient endpoint to use a specific region, resulting in the client defaulting to the global region. This limitation does not exist in the Python and Node.js clients, where modifying the endpoint to target a specific region works as expected.

To Reproduce Steps to reproduce the behavior:

  1. Attempt to set the endpoint option for the SpeechClient to a non-global region, such as "asia-southeast1-speech.googleapis.com", using the C++ client library.
  2. Configure and execute a Recognize request using the modified client.
    e.g.,
    request.set_recognizer("projects/{project_id}/locations/asia-southeast1/recognizers/_");
  3. Observe the error response indicating an expected global resource location rather than the specified regional endpoint.
Expected resource location to be global, but found asia-southeast1 in resource name.
auto options = google::cloud::Options{}.set<google::cloud::EndpointOption>(
  "asia-southeast1-speech.googleapis.com");
auto connection = google::cloud::speech_v2::MakeSpeechConnection(options);
auto client = google::cloud::speech_v2::SpeechClient(connection, options);
// Parse command line arguments.
auto args = ParseArguments(argc, argv);
auto const file_path = args.path;
speech_v2::RecognizeRequest request;

request.set_allocated_config(new speech_v2::RecognitionConfig(args.config));
request.set_recognizer("projects/{project_id}/locations/asia-southeast1/recognizers/_");
request.set_uri("gs://musevision/audio/audio-files/out.wav");

auto response = client.Recognize(request, options);

if (response.status().code() != google::cloud::StatusCode::kOk) {
  //Output: expected resource location to be global, but found asia-southeast1 in resource name.
  std::cerr << "Recognize failed: " << response.status().message() << "\n";
  return 1;
}

Expected behavior
Successfully transcribed the audio file without any errors reported.

Operating system:
macOS 14.3.1

What compiler and version are you using?
Homebrew clang version 17.0.6

What version of google-cloud-cpp are you using?
2.21.0

Additional context Add any other context about the problem here.

@jiahansu jiahansu added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 5, 2024
@scotthart
Copy link
Member

Can you try also setting the google::cloud::AuthorityOption to the same value as your EndpointOption?

auto options = google::cloud::Options{}
    .set<google::cloud::EndpointOption>("asia-southeast1-speech.googleapis.com")
    .set<google::cloud::AuthorityOption>("asia-southeast1-speech.googleapis.com");

And see if that resolves the issue?

@scotthart
Copy link
Member

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants