Commit d7b7b200 authored by evliu's avatar evliu Committed by Commit Bot

Update SODA to take in a path to the language pack directory

This CL updates SODA to take in a path to the language pack direcotry
instead of a path to the dictation.ascii_proto config file. SODA will
instead choose the appropriate config file to use within the language
pack directory.

Google3-side changes: cl/326259391

Bug: 1124367
Change-Id: I3ec52682a1d22afe9077a9ddfdb02c054319fa14
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391283Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Commit-Queue: Evan Liu <evliu@google.com>
Cr-Commit-Position: refs/heads/master@{#804122}
parent 4b8556b8
...@@ -29,7 +29,7 @@ namespace { ...@@ -29,7 +29,7 @@ namespace {
// The SHA256 of the SubjectPublicKeyInfo used to sign the component. // The SHA256 of the SubjectPublicKeyInfo used to sign the component.
// The component id is: icnkogojpkfjeajonkmlplionaamopkf // The component id is: icnkogojpkfjeajonkmlplionaamopkf
const uint8_t kSODAPublicKeySHA256[32] = { constexpr uint8_t kSODAPublicKeySHA256[32] = {
0x82, 0xda, 0xe6, 0xe9, 0xfa, 0x59, 0x40, 0x9e, 0xda, 0xcb, 0xfb, 0x82, 0xda, 0xe6, 0xe9, 0xfa, 0x59, 0x40, 0x9e, 0xda, 0xcb, 0xfb,
0x8e, 0xd0, 0x0c, 0xef, 0xa5, 0xc0, 0x97, 0x00, 0x84, 0x1c, 0x21, 0x8e, 0xd0, 0x0c, 0xef, 0xa5, 0xc0, 0x97, 0x00, 0x84, 0x1c, 0x21,
0xa6, 0xae, 0xc8, 0x1b, 0x87, 0xfb, 0x12, 0x27, 0x28, 0xb1}; 0xa6, 0xae, 0xc8, 0x1b, 0x87, 0xfb, 0x12, 0x27, 0x28, 0xb1};
...@@ -37,7 +37,7 @@ const uint8_t kSODAPublicKeySHA256[32] = { ...@@ -37,7 +37,7 @@ const uint8_t kSODAPublicKeySHA256[32] = {
static_assert(base::size(kSODAPublicKeySHA256) == crypto::kSHA256Length, static_assert(base::size(kSODAPublicKeySHA256) == crypto::kSHA256Length,
"Wrong hash length"); "Wrong hash length");
const char kSODAManifestName[] = "SODA Library"; constexpr char kSODAManifestName[] = "SODA Library";
} // namespace } // namespace
......
...@@ -27,7 +27,7 @@ namespace { ...@@ -27,7 +27,7 @@ namespace {
// The SHA256 of the SubjectPublicKeyInfo used to sign the component. // The SHA256 of the SubjectPublicKeyInfo used to sign the component.
// The component id is: oegebmmcimckjhkhbggblnkjloogjdfg // The component id is: oegebmmcimckjhkhbggblnkjloogjdfg
const uint8_t kSodaEnUsPublicKeySHA256[32] = { constexpr uint8_t kSodaEnUsPublicKeySHA256[32] = {
0xe4, 0x64, 0x1c, 0xc2, 0x8c, 0x2a, 0x97, 0xa7, 0x16, 0x61, 0xbd, 0xe4, 0x64, 0x1c, 0xc2, 0x8c, 0x2a, 0x97, 0xa7, 0x16, 0x61, 0xbd,
0xa9, 0xbe, 0xe6, 0x93, 0x56, 0xf5, 0x05, 0x33, 0x9b, 0x8b, 0x0b, 0xa9, 0xbe, 0xe6, 0x93, 0x56, 0xf5, 0x05, 0x33, 0x9b, 0x8b, 0x0b,
0x02, 0xe2, 0x6b, 0x7e, 0x6c, 0x40, 0xa1, 0xd2, 0x7e, 0x18}; 0x02, 0xe2, 0x6b, 0x7e, 0x6c, 0x40, 0xa1, 0xd2, 0x7e, 0x18};
...@@ -35,10 +35,7 @@ const uint8_t kSodaEnUsPublicKeySHA256[32] = { ...@@ -35,10 +35,7 @@ const uint8_t kSodaEnUsPublicKeySHA256[32] = {
static_assert(base::size(kSodaEnUsPublicKeySHA256) == crypto::kSHA256Length, static_assert(base::size(kSodaEnUsPublicKeySHA256) == crypto::kSHA256Length,
"Wrong hash length"); "Wrong hash length");
const char kSodaEnUsManifestName[] = "SODA en-US Models"; constexpr char kSodaEnUsManifestName[] = "SODA en-US Models";
constexpr base::FilePath::CharType kSodaEnUsConfigFileRelativePath[] =
FILE_PATH_LITERAL("SODAModels/dictation.ascii_proto");
} // namespace } // namespace
...@@ -70,7 +67,8 @@ void SodaEnUsComponentInstallerPolicy::UpdateSodaEnUsComponentOnDemand() { ...@@ -70,7 +67,8 @@ void SodaEnUsComponentInstallerPolicy::UpdateSodaEnUsComponentOnDemand() {
bool SodaEnUsComponentInstallerPolicy::VerifyInstallation( bool SodaEnUsComponentInstallerPolicy::VerifyInstallation(
const base::DictionaryValue& manifest, const base::DictionaryValue& manifest,
const base::FilePath& install_dir) const { const base::FilePath& install_dir) const {
return base::PathExists(install_dir.Append(kSodaEnUsConfigFileRelativePath)); return base::PathExists(
install_dir.Append(speech::kSodaLanguagePackDirectoryRelativePath));
} }
bool SodaEnUsComponentInstallerPolicy:: bool SodaEnUsComponentInstallerPolicy::
...@@ -128,8 +126,9 @@ std::vector<std::string> SodaEnUsComponentInstallerPolicy::GetMimeTypes() ...@@ -128,8 +126,9 @@ std::vector<std::string> SodaEnUsComponentInstallerPolicy::GetMimeTypes()
void UpdateSodaEnUsInstallDirPref(PrefService* prefs, void UpdateSodaEnUsInstallDirPref(PrefService* prefs,
const base::FilePath& install_dir) { const base::FilePath& install_dir) {
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
prefs->SetFilePath(prefs::kSodaEnUsConfigPath, prefs->SetFilePath(
install_dir.Append(kSodaEnUsConfigFileRelativePath)); prefs::kSodaEnUsConfigPath,
install_dir.Append(speech::kSodaLanguagePackDirectoryRelativePath));
#endif #endif
} }
......
...@@ -27,7 +27,7 @@ namespace { ...@@ -27,7 +27,7 @@ namespace {
// The SHA256 of the SubjectPublicKeyInfo used to sign the component. // The SHA256 of the SubjectPublicKeyInfo used to sign the component.
// The component id is: onhpjgkfgajmkkeniaoflicgokpaebfa // The component id is: onhpjgkfgajmkkeniaoflicgokpaebfa
const uint8_t kSodaJaJpPublicKeySHA256[32] = { constexpr uint8_t kSodaJaJpPublicKeySHA256[32] = {
0xed, 0x7f, 0x96, 0xa5, 0x60, 0x9c, 0xaa, 0x4d, 0x80, 0xe5, 0xb8, 0xed, 0x7f, 0x96, 0xa5, 0x60, 0x9c, 0xaa, 0x4d, 0x80, 0xe5, 0xb8,
0x26, 0xea, 0xf0, 0x41, 0x50, 0x09, 0x52, 0xa4, 0xb3, 0x1e, 0x6a, 0x26, 0xea, 0xf0, 0x41, 0x50, 0x09, 0x52, 0xa4, 0xb3, 0x1e, 0x6a,
0x8e, 0x24, 0x99, 0xde, 0x51, 0x14, 0xc4, 0x3c, 0xfa, 0x48}; 0x8e, 0x24, 0x99, 0xde, 0x51, 0x14, 0xc4, 0x3c, 0xfa, 0x48};
...@@ -35,10 +35,7 @@ const uint8_t kSodaJaJpPublicKeySHA256[32] = { ...@@ -35,10 +35,7 @@ const uint8_t kSodaJaJpPublicKeySHA256[32] = {
static_assert(base::size(kSodaJaJpPublicKeySHA256) == crypto::kSHA256Length, static_assert(base::size(kSodaJaJpPublicKeySHA256) == crypto::kSHA256Length,
"Wrong hash length"); "Wrong hash length");
const char kSodaJaJpManifestName[] = "SODA ja-JP Models"; constexpr char kSodaJaJpManifestName[] = "SODA ja-JP Models";
constexpr base::FilePath::CharType kSodaJaJpConfigFileRelativePath[] =
FILE_PATH_LITERAL("SODAModels/dictation.ascii_proto");
} // namespace } // namespace
...@@ -70,7 +67,8 @@ void SodaJaJpComponentInstallerPolicy::UpdateSodaJaJpComponentOnDemand() { ...@@ -70,7 +67,8 @@ void SodaJaJpComponentInstallerPolicy::UpdateSodaJaJpComponentOnDemand() {
bool SodaJaJpComponentInstallerPolicy::VerifyInstallation( bool SodaJaJpComponentInstallerPolicy::VerifyInstallation(
const base::DictionaryValue& manifest, const base::DictionaryValue& manifest,
const base::FilePath& install_dir) const { const base::FilePath& install_dir) const {
return base::PathExists(install_dir.Append(kSodaJaJpConfigFileRelativePath)); return base::PathExists(
install_dir.Append(speech::kSodaLanguagePackDirectoryRelativePath));
} }
bool SodaJaJpComponentInstallerPolicy:: bool SodaJaJpComponentInstallerPolicy::
...@@ -128,8 +126,9 @@ std::vector<std::string> SodaJaJpComponentInstallerPolicy::GetMimeTypes() ...@@ -128,8 +126,9 @@ std::vector<std::string> SodaJaJpComponentInstallerPolicy::GetMimeTypes()
void UpdateSodaJaJpInstallDirPref(PrefService* prefs, void UpdateSodaJaJpInstallDirPref(PrefService* prefs,
const base::FilePath& install_dir) { const base::FilePath& install_dir) {
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
prefs->SetFilePath(prefs::kSodaJaJpConfigPath, prefs->SetFilePath(
install_dir.Append(kSodaJaJpConfigFileRelativePath)); prefs::kSodaJaJpConfigPath,
install_dir.Append(speech::kSodaLanguagePackDirectoryRelativePath));
#endif #endif
} }
......
...@@ -131,11 +131,11 @@ void SpeechRecognitionRecognizerImpl::SendAudioToSpeechRecognitionService( ...@@ -131,11 +131,11 @@ void SpeechRecognitionRecognizerImpl::SendAudioToSpeechRecognitionService(
soda_client_->DidAudioPropertyChange(sample_rate, channel_count)) { soda_client_->DidAudioPropertyChange(sample_rate, channel_count)) {
// Initialize the SODA instance. // Initialize the SODA instance.
auto api_key = google_apis::GetSodaAPIKey(); auto api_key = google_apis::GetSodaAPIKey();
std::string config_file_path = config_path_.AsUTF8Unsafe(); std::string language_pack_directory = config_path_.AsUTF8Unsafe();
SodaConfig config; SodaConfig config;
config.channel_count = channel_count; config.channel_count = channel_count;
config.sample_rate = sample_rate; config.sample_rate = sample_rate;
config.config_file = config_file_path.c_str(); config.language_pack_directory = language_pack_directory.c_str();
config.callback = RecognitionCallback; config.callback = RecognitionCallback;
config.callback_handle = this; config.callback_handle = this;
config.api_key = api_key.c_str(); config.api_key = api_key.c_str();
......
...@@ -32,6 +32,9 @@ constexpr base::FilePath::CharType kSodaEnUsInstallationRelativePath[] = ...@@ -32,6 +32,9 @@ constexpr base::FilePath::CharType kSodaEnUsInstallationRelativePath[] =
constexpr base::FilePath::CharType kSodaJaJpInstallationRelativePath[] = constexpr base::FilePath::CharType kSodaJaJpInstallationRelativePath[] =
FILE_PATH_LITERAL("SODALanguagePacks/ja-JP"); FILE_PATH_LITERAL("SODALanguagePacks/ja-JP");
constexpr base::FilePath::CharType kSodaLanguagePackDirectoryRelativePath[] =
FILE_PATH_LITERAL("SODAModels");
const base::FilePath GetSodaDirectory() { const base::FilePath GetSodaDirectory() {
base::FilePath components_dir; base::FilePath components_dir;
base::PathService::Get(component_updater::DIR_COMPONENT_USER, base::PathService::Get(component_updater::DIR_COMPONENT_USER,
......
...@@ -15,6 +15,9 @@ enum class LanguageCode { ...@@ -15,6 +15,9 @@ enum class LanguageCode {
kJaJp = 2, kJaJp = 2,
}; };
// Location of the libsoda binary within the SODA installation directory.
extern const base::FilePath::CharType kSodaBinaryRelativePath[];
// Location of the SODA component relative to the components directory. // Location of the SODA component relative to the components directory.
extern const base::FilePath::CharType kSodaInstallationRelativePath[]; extern const base::FilePath::CharType kSodaInstallationRelativePath[];
...@@ -30,15 +33,9 @@ extern const base::FilePath::CharType kSodaEnUsInstallationRelativePath[]; ...@@ -30,15 +33,9 @@ extern const base::FilePath::CharType kSodaEnUsInstallationRelativePath[];
// directory. // directory.
extern const base::FilePath::CharType kSodaJaJpInstallationRelativePath[]; extern const base::FilePath::CharType kSodaJaJpInstallationRelativePath[];
// Location of the libsoda binary within the SODA installation directory. // Location of the SODA models directory relative to the language pack
extern const base::FilePath::CharType kSodaBinaryRelativePath[]; // installation directory.
extern const base::FilePath::CharType kSodaLanguagePackDirectoryRelativePath[];
// Location of the en-US SODA config file within the SODA installation
// directory. Note: SODA is currently only available in English.
extern const base::FilePath::CharType kSodaEnUsConfigFileRelativePath[];
// Location of the ja-JP SODA config file within the SODA installation
extern const base::FilePath::CharType kSodaJaJpConfigFileRelativePath[];
// Get the absolute path of the SODA component directory. // Get the absolute path of the SODA component directory.
const base::FilePath GetSodaDirectory(); const base::FilePath GetSodaDirectory();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment