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

feat(speech): generate speech v2 #10228

Merged
merged 5 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ci/etc/expected_install_directories
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@
./include/google/cloud/speech/internal
./include/google/cloud/speech/mocks
./include/google/cloud/speech/v1
./include/google/cloud/speech/v2
./include/google/cloud/speech/v2/internal
./include/google/cloud/speech/v2/mocks
./include/google/cloud/storage
./include/google/cloud/storage/internal
./include/google/cloud/storagetransfer
Expand Down
14 changes: 10 additions & 4 deletions cmake/GoogleCloudCppCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ function (google_cloud_cpp_add_executable target prefix source)
PARENT_SCOPE)
endfunction ()

# google_cloud_cpp_add_samples : adds rules to compile and test generated
# samples
function (google_cloud_cpp_add_samples library)
# google_cloud_cpp_add_samples_relative : adds rules to compile and test
# generated samples for $library found in the relative $path.
function (google_cloud_cpp_add_samples_relative library path)
file(
GLOB sample_files
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"*.cc")
"${path}*.cc")
foreach (source IN LISTS sample_files)
google_cloud_cpp_add_executable(target "${library}" "${source}")
if (TARGET google-cloud-cpp::${library})
Expand All @@ -269,3 +269,9 @@ function (google_cloud_cpp_add_samples library)
set_tests_properties("${target}" PROPERTIES LABELS "integration-test")
endforeach ()
endfunction ()

# google_cloud_cpp_add_samples : adds rules to compile and test generated
# samples
function (google_cloud_cpp_add_samples library)
google_cloud_cpp_add_samples_relative("${library}" "")
endfunction ()
1 change: 1 addition & 0 deletions external/googleapis/protolists/speech.list
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@com_google_googleapis//google/cloud/speech/v1:cloud_speech.proto
@com_google_googleapis//google/cloud/speech/v1:cloud_speech_adaptation.proto
@com_google_googleapis//google/cloud/speech/v1:resource.proto
@com_google_googleapis//google/cloud/speech/v2:cloud_speech.proto
6 changes: 5 additions & 1 deletion external/googleapis/update_libraries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,11 @@ declare -A -r LIBRARIES=(
"@com_google_googleapis//google/spanner/admin/instance/v1:instance_cc_grpc" \
"@com_google_googleapis//google/spanner/admin/database/v1:database_cc_grpc"
)"
["speech"]="@com_google_googleapis//google/cloud/speech/v1:speech_cc_grpc"
["speech"]="$(
printf ",%s" \
"@com_google_googleapis//google/cloud/speech/v1:speech_cc_grpc" \
"@com_google_googleapis//google/cloud/speech/v2:speech_cc_grpc"
)"
["storage"]="@com_google_googleapis//google/storage/v2:storage_cc_grpc"
["storagetransfer"]="@com_google_googleapis//google/storagetransfer/v1:storagetransfer_cc_grpc"
["talent"]="@com_google_googleapis//google/cloud/talent/v4:talent_cc_grpc"
Expand Down
7 changes: 7 additions & 0 deletions generator/generator_config.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,13 @@ service {
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/speech/v2/cloud_speech.proto"
product_path: "google/cloud/speech/v2"
initial_copyright_year: "2022"
retryable_status_codes: ["kUnavailable"]
}

# Storage
service {
service_proto_path: "google/storage/v2/storage.proto"
Expand Down
35 changes: 26 additions & 9 deletions google/cloud/speech/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,31 @@ package(default_visibility = ["//visibility:private"])

licenses(["notice"]) # Apache 2.0

service_dirs = [
"",
"v2/",
]

internal_dirs = [
"",
"internal/",
]

src_dirs = [s + i for s in service_dirs for i in internal_dirs]

filegroup(
name = "srcs",
srcs = glob([
"*.cc",
"internal/*.cc",
]),
srcs = glob([d + "*.cc" for d in src_dirs]),
)

filegroup(
name = "hdrs",
srcs = glob([
"*.h",
"internal/*.h",
]),
srcs = glob([d + "*.h" for d in src_dirs]),
)

filegroup(
name = "mocks",
srcs = glob(["mocks/*.h"]),
srcs = glob([s + "mocks/*.h" for s in service_dirs]),
)

cc_library(
Expand All @@ -46,6 +52,7 @@ cc_library(
"//:common",
"//:grpc_utils",
"@com_google_googleapis//google/cloud/speech/v1:speech_cc_grpc",
"@com_google_googleapis//google/cloud/speech/v2:speech_cc_grpc",
],
)

Expand All @@ -58,3 +65,13 @@ cc_library(
"@com_google_googletest//:gtest",
],
)

[cc_test(
name = sample.replace("/", "_").replace(".cc", ""),
srcs = [sample],
tags = ["integration-test"],
deps = [
"//:speech",
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
],
) for sample in glob([s + "samples/*.cc" for s in service_dirs])]
29 changes: 23 additions & 6 deletions google/cloud/speech/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,20 @@ set(DOXYGEN_PROJECT_NAME "Cloud Speech-to-Text API C++ Client")
set(DOXYGEN_PROJECT_BRIEF
"A C++ Client Library for the Cloud Speech-to-Text API")
set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION}")
set(DOXYGEN_EXCLUDE_SYMBOLS "internal" "speech_internal" "speech_testing"
"examples")
set(DOXYGEN_EXAMPLE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/samples
${CMAKE_CURRENT_SOURCE_DIR}/quickstart)
set(DOXYGEN_EXCLUDE_SYMBOLS "internal")
set(DOXYGEN_EXAMPLE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/quickstart")

unset(mocks_globs)
unset(source_globs)
set(service_dirs "" "v2/")
foreach (dir IN LISTS service_dirs)
string(REPLACE "/" "_" ns "${dir}")
list(APPEND source_globs "${dir}*.h" "${dir}*.cc" "${dir}internal/*")
list(APPEND mocks_globs "${dir}mocks/*.h")
list(APPEND DOXYGEN_EXAMPLE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/${dir}samples")
list(APPEND DOXYGEN_EXCLUDE_SYMBOLS "speech_${ns}internal")
endforeach ()

# Creates the proto headers needed by doxygen.
set(GOOGLE_CLOUD_CPP_DOXYGEN_DEPS google-cloud-cpp::speech_protos)
Expand Down Expand Up @@ -53,7 +63,7 @@ target_link_libraries(google_cloud_cpp_speech_protos PUBLIC ${proto_deps})
file(
GLOB source_files
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"*.h" "*.cc" "internal/*.h" "internal/*.cc")
${source_globs})
list(SORT source_files)
add_library(google_cloud_cpp_speech ${source_files})
target_include_directories(
Expand Down Expand Up @@ -83,7 +93,7 @@ add_library(google-cloud-cpp::speech ALIAS google_cloud_cpp_speech)
file(
GLOB relative_mock_files
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"mocks/*.h")
${mocks_globs})
list(SORT relative_mock_files)
set(mock_files)
foreach (file IN LISTS relative_mock_files)
Expand Down Expand Up @@ -184,3 +194,10 @@ install(
COMPONENT google_cloud_cpp_development)

external_googleapis_install_pc("google_cloud_cpp_speech_protos")

# google-cloud-cpp::speech must be defined before we can add the samples.
foreach (dir IN LISTS service_dirs)
if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_ENABLE_CXX_EXCEPTIONS)
google_cloud_cpp_add_samples_relative("speech" "${dir}samples/")
endif ()
endforeach ()
24 changes: 24 additions & 0 deletions google/cloud/speech/doc/main.dox
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ which should give you a taste of the Cloud Speech-to-Text API C++ client library

<!-- inject-endpoint-env-vars-start -->

- `GOOGLE_CLOUD_CPP_SPEECH_ENDPOINT=...` overrides the
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like some sort of sort -u would be useful in the script that updates these things?

Copy link
Member Author

Choose a reason for hiding this comment

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

I lean more towards including the namespace, such as: speech_v2::MakeSpeechConnection()

`EndpointOption` (which defaults to "speech.googleapis.com")
used by `MakeSpeechConnection()`.

- `GOOGLE_CLOUD_CPP_SPEECH_ENDPOINT=...` overrides the
`EndpointOption` (which defaults to "speech.googleapis.com")
used by `MakeSpeechConnection()`.
Expand Down Expand Up @@ -96,6 +100,10 @@ For example, this will override the default endpoint for `speech::SpeechClient`:

@snippet speech_client_samples.cc set-client-endpoint

Follow these links to find examples for other \c *Client classes:
[speech::SpeechClient](@ref speech::SpeechClient-endpoint-snippet)
[speech_v2::SpeechClient](@ref speech_v2::SpeechClient-endpoint-snippet)

<!-- inject-endpoint-snippet-end -->

## Override the authentication configuration
Expand All @@ -108,6 +116,10 @@ to explicitly load a service account key file.
<!-- inject-service-account-snippet-start -->
@snippet speech_client_samples.cc with-service-account

Follow these links to find examples for other \c *Client classes:
[speech::SpeechClient](@ref speech::SpeechClient-service-account-snippet)
[speech_v2::SpeechClient](@ref speech_v2::SpeechClient-service-account-snippet)

<!-- inject-service-account-snippet-end -->

Keep in mind that we chose this as an example because it is relatively easy to
Expand Down Expand Up @@ -147,5 +159,17 @@ can override the default policies.

@snippet google/cloud/speech/samples/speech_client_samples.cc with-service-account

*/

/*! @page speech_v2::SpeechClient-endpoint-snippet Override speech_v2::SpeechClient Endpoint Configuration

@snippet google/cloud/speech/v2/samples/speech_client_samples.cc set-client-endpoint

*/

/*! @page speech_v2::SpeechClient-service-account-snippet Override speech_v2::SpeechClient Authentication Defaults

@snippet google/cloud/speech/v2/samples/speech_client_samples.cc with-service-account

*/
// <!-- inject-endpoint-pages-end -->
27 changes: 0 additions & 27 deletions google/cloud/speech/samples/BUILD.bazel

This file was deleted.

19 changes: 0 additions & 19 deletions google/cloud/speech/samples/CMakeLists.txt

This file was deleted.

Loading