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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
handwritten updates
  • Loading branch information
dbolduc committed Nov 15, 2022

Verified

This commit was signed with the committer’s verified signature.
drashna Drashna Jaelre
commit 248062f04f32a515fde332a59b8f315783463987
25 changes: 16 additions & 9 deletions google/cloud/speech/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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(
@@ -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",
],
)

18 changes: 16 additions & 2 deletions google/cloud/speech/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -50,10 +50,24 @@ google_cloud_cpp_grpcpp_library(
external_googleapis_set_version_and_alias(speech_protos)
target_link_libraries(google_cloud_cpp_speech_protos PUBLIC ${proto_deps})

unset(mocks_globs)
unset(source_globs)
set(service_dirs ";v2/")
Copy link
Contributor

Choose a reason for hiding this comment

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

if you are planning to use something like a list, then do so:

set(service_dirs "" "v2/")
set(internal_dirs "" "internal/")
set(extensions "*.h" ".cc")

But all of this seems overly complicated, I think something like

file(GLOB source_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
       "*.h" "*.cc" "internal/*.h" "intermal/*.cc"
       "v2/*.h" "v2/*.cc" "v2/internal/*.h" "v2/intermal/*.cc")

Is easier to read.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack, I unrolled the internal_dirs and extensions, but I left the service_dirs loop. I think it offers a general solution that we can use in other libraries. e.g. bigquery might (eventually) look like:

set(service_dirs "analyticshub/v1/" "connection/v1/"
                 "datatransfer/v1/" "migration/v2/"
                 "reservation/v1/" "storage/v1/" "v2/")

set(internal_dirs ";internal/")
set(extensions "*.h;*.cc")
foreach (s IN LISTS service_dirs)
foreach (i IN LISTS internal_dirs)
foreach (e IN LISTS extensions)
list(APPEND source_globs "${s}${i}${e}")
endforeach ()
endforeach ()
list(APPEND mocks_globs "${s}mocks/*.h")
endforeach ()

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(
@@ -83,7 +97,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)
34 changes: 34 additions & 0 deletions google/cloud/speech/v2/streaming.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "google/cloud/speech/v2/internal/speech_connection_impl.h"
#include <memory>

namespace google {
namespace cloud {
namespace speech_v2_internal {
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN

std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc<
google::cloud::speech::v2::StreamingRecognizeRequest,
google::cloud::speech::v2::StreamingRecognizeResponse>>
SpeechConnectionImpl::AsyncStreamingRecognize(ExperimentalTag) {
return stub_->AsyncStreamingRecognize(
background_->cq(), absl::make_unique<grpc::ClientContext>());
}

GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
} // namespace speech_v2_internal
} // namespace cloud
} // namespace google