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

ci(speech): update quickstart to V2 demonstrating regional endpoints #13760

Merged
merged 6 commits into from
Apr 29, 2024

Conversation

scotthart
Copy link
Member

@scotthart scotthart commented Mar 11, 2024

While we need to wait until after the next release to commit these changes, for our own CI purposes, this quickstart shows how to use the API available at HEAD to direct the speech client to use regional endpoints and reocgnizers.

part of the work for #13729

blocked on microsoft/vcpkg#38204


This change is Reviewable

@product-auto-label product-auto-label bot added the api: speech Issues related to the Speech-to-Text API. label Mar 11, 2024
Copy link

codecov bot commented Mar 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.78%. Comparing base (cb500d5) to head (aba30e7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13760      +/-   ##
==========================================
+ Coverage   93.23%   93.78%   +0.55%     
==========================================
  Files        2197     2284      +87     
  Lines      188700   199141   +10441     
==========================================
+ Hits       175929   186762   +10833     
+ Misses      12771    12379     -392     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member Author

@scotthart scotthart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 4 files reviewed, 2 unresolved discussions (waiting on @devbww)


google/cloud/speech/quickstart/quickstart.cc line 37 at r1 (raw file):

Previously, devbww (Bradley White) wrote…

What if argc is 0, 1, or 2?

Added additional argc usage condition.


google/cloud/speech/quickstart/quickstart.cc line 54 at r1 (raw file):

Previously, devbww (Bradley White) wrote…

Factor out the set_recognizer.

[Then the MakeSpeechConnection() can be turned into a conditional expression and become the connection initializer.]

Moved set recognizer out of the conditional.

int main(int argc, char* argv[]) try {
auto constexpr kDefaultUri = "gs://cloud-samples-data/speech/hello.wav";
if (argc > 2) {
std::cerr << "Usage: " << argv[0] << " [gcs-uri]\n"
if (argc < 3 || argc > 4) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: (argc != 3 && argc != 4) would be the clearer exposition, methinks.

Comment on lines 58 to 62
if (location == "global") {
connection = speech::MakeSpeechConnection();
} else {
connection = speech::MakeSpeechConnection(location);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opt: Perhaps MakeXxxConnection("global") should mean the same thing as MakeXxxConnection()?

Copy link
Member Author

@scotthart scotthart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 4 files reviewed, 3 unresolved discussions (waiting on @devbww)


google/cloud/speech/README.md line 39 at r2 (raw file):

Previously, devbww (Bradley White) wrote…

Nit: (argc != 3 && argc != 4) would be the clearer exposition, methinks.

Done.


google/cloud/speech/README.md line 62 at r2 (raw file):

Previously, devbww (Bradley White) wrote…

Opt: Perhaps MakeXxxConnection("global") should mean the same thing as MakeXxxConnection()?

I'd rather have the overload than introduce a sentinel value.

Copy link
Contributor

@devbww devbww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @scotthart)


google/cloud/speech/README.md line 62 at r2 (raw file):

Previously, scotthart (Scott Hart) wrote…

I'd rather have the overload than introduce a sentinel value.

Note that we already have a sentinel of an empty location.

absl::StrCat(location, location.empty() ? "" : "-",

And we'd still have the overload for the "compat" part.

@alevenberg alevenberg added do not merge Indicates a pull request not ready for merge, due to either quality or timing. and removed do not merge Indicates a pull request not ready for merge, due to either quality or timing. labels Apr 15, 2024
@scotthart scotthart force-pushed the speech_v2_update_quickstart branch from 4e283d8 to 9ac2f7b Compare April 19, 2024 17:30
@scotthart scotthart force-pushed the speech_v2_update_quickstart branch from 9ac2f7b to 69410ae Compare April 24, 2024 15:42
@scotthart scotthart force-pushed the speech_v2_update_quickstart branch from 69410ae to f665ff2 Compare April 25, 2024 17:33
@scotthart scotthart marked this pull request as ready for review April 26, 2024 14:34
@scotthart scotthart requested a review from a team as a code owner April 26, 2024 14:34
Copy link
Member Author

@scotthart scotthart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @devbww)


google/cloud/speech/README.md line 62 at r2 (raw file):

Previously, devbww (Bradley White) wrote…

Note that we already have a sentinel of an empty location.

absl::StrCat(location, location.empty() ? "" : "-",

And we'd still have the overload for the "compat" part.

Use the non-deprecated MakeConnection function with the existing sentinel value.

Comment on lines +37 to +38
# Some tests and quickstarts need to specify a location as "global".
export GOOGLE_CLOUD_CPP_TEST_GLOBAL="global"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can only ever have one value ("global") so I don't think having a variable makes sense. Let's just hardcode "global" in the quickstart runner.

Comment on lines 54 to 55
connection = speech::MakeSpeechConnection(location);
auto client = speech::SpeechClient(connection);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 99% of the quickstarts squash this into one line.

auto client = speech::SpeechClient(speech::MakeSpeechConnection(location));

@@ -26,12 +26,20 @@ if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_ENABLE_CXX_EXCEPTIONS)
target_link_libraries(speech_quickstart PRIVATE google-cloud-cpp::speech)
google_cloud_cpp_add_common_options(speech_quickstart)
add_test(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is cool. good idea to have multiple tests for the quickstart

Copy link
Member Author

@scotthart scotthart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 4 files reviewed, 4 unresolved discussions (waiting on @dbolduc and @devbww)


google/cloud/speech/CMakeLists.txt line 28 at r4 (raw file):

Previously, dbolduc (Darren Bolduc) wrote…

this is cool. good idea to have multiple tests for the quickstart

Done.


google/cloud/speech/quickstart/quickstart.cc line 55 at r4 (raw file):

Previously, dbolduc (Darren Bolduc) wrote…

I think 99% of the quickstarts squash this into one line.

auto client = speech::SpeechClient(speech::MakeSpeechConnection(location));

Done.


ci/etc/integration-tests-config.sh line 38 at r4 (raw file):

Previously, dbolduc (Darren Bolduc) wrote…

This can only ever have one value ("global") so I don't think having a variable makes sense. Let's just hardcode "global" in the quickstart runner.

Done.

@scotthart scotthart force-pushed the speech_v2_update_quickstart branch from e50c2b9 to 0dcce9b Compare April 29, 2024 16:22
@scotthart scotthart enabled auto-merge (squash) April 29, 2024 17:59
@scotthart scotthart merged commit 226c607 into googleapis:main Apr 29, 2024
63 of 64 checks passed
devbww pushed a commit to devbww/google-cloud-cpp that referenced this pull request May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: speech Issues related to the Speech-to-Text API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants