Skip to content

Commit

Permalink
Plumb through API key for ReadAloud service.
Browse files Browse the repository at this point in the history
API key will be used by integration with remote ReadAloud service to provide enhanced text-to-speech synthesis to Select-to-speak.

go/wavenet-chromeos-dd

Bug: 1215291
Change-Id: Ib6263369a15329d9f129273698e009fc0d6c1b69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2930784
Reviewed-by: David Roger <droger@chromium.org>
Commit-Queue: Joel Riley <joelriley@google.com>
Cr-Commit-Position: refs/heads/master@{#889428}
  • Loading branch information
j0000el authored and Chromium LUCI CQ committed Jun 4, 2021
1 parent 701b1a3 commit 43ccd76
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions google_apis/google_api_keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@
#define GOOGLE_API_KEY_SODA DUMMY_API_TOKEN
#endif

// API key for the ReadAloud API.
#if !defined(GOOGLE_API_KEY_READ_ALOUD)
#define GOOGLE_API_KEY_READ_ALOUD DUMMY_API_TOKEN
#endif

// These are used as shortcuts for developers and users providing
// OAuth credentials via preprocessor defines or environment
// variables. If set, they will be used to replace any of the client
Expand Down Expand Up @@ -147,6 +152,10 @@ class APIKeyCache {
GOOGLE_API_KEY_SODA, STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_SODA),
nullptr, std::string(), environment.get(), command_line, gaia_config);

api_key_read_aloud_ = CalculateKeyValue(
GOOGLE_API_KEY_SODA, STRINGIZE_NO_EXPANSION(GOOGLE_API_KEY_READ_ALOUD),
nullptr, std::string(), environment.get(), command_line, gaia_config);

metrics_key_ = CalculateKeyValue(
GOOGLE_METRICS_SIGNING_KEY,
STRINGIZE_NO_EXPANSION(GOOGLE_METRICS_SIGNING_KEY), nullptr,
Expand Down Expand Up @@ -213,6 +222,7 @@ class APIKeyCache {
std::string api_key_remoting() const { return api_key_remoting_; }
std::string api_key_sharing() const { return api_key_sharing_; }
std::string api_key_soda() const { return api_key_soda_; }
std::string api_key_read_aloud() const { return api_key_read_aloud_; }

std::string metrics_key() const { return metrics_key_; }

Expand Down Expand Up @@ -326,6 +336,7 @@ class APIKeyCache {
std::string api_key_remoting_;
std::string api_key_sharing_;
std::string api_key_soda_;
std::string api_key_read_aloud_;
std::string metrics_key_;
std::string client_ids_[CLIENT_NUM_ITEMS];
std::string client_secrets_[CLIENT_NUM_ITEMS];
Expand Down Expand Up @@ -358,6 +369,10 @@ std::string GetSodaAPIKey() {
return g_api_key_cache.Get().api_key_soda();
}

std::string GetReadAloudAPIKey() {
return g_api_key_cache.Get().api_key_read_aloud();
}

#if defined(OS_IOS) || defined(OS_FUCHSIA)
void SetAPIKey(const std::string& api_key) {
g_api_key_cache.Get().set_api_key(api_key);
Expand Down
3 changes: 3 additions & 0 deletions google_apis/google_api_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ std::string GetSharingAPIKey();
// Retrieves the Speech On-Device API (SODA) API Key.
std::string GetSodaAPIKey();

// Retrieves the ReadAloud API Key.
std::string GetReadAloudAPIKey();

#if defined(OS_IOS) || defined(OS_FUCHSIA)
// Sets the API key. This should be called as early as possible before this
// API key is even accessed. It must be called before GetAPIKey.
Expand Down

0 comments on commit 43ccd76

Please sign in to comment.