Commit e97ff163 authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Add support for language in Linux platform voices

This CL is keeping track of the language returned by the speak
synthetizer. The language attribute is used by the TTS controller
GetMatchingVoice(...) to choose the most suitable voices.


For an empty test that do:
  speechSyntheizer.speak(...)

My local computer is choosing:
  Afrikaans espeak-ng
which is the first alphabetical entry.

With the patch, it is choosing:
  English (America) espeak-ng
since my app-locale are taken into account by the TTS controller.

Bug: 1133813
Change-Id: Ie04657dec7f947ddd91c9e672bcb36a54863d88e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2493021Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820324}
parent b190fc6f
...@@ -33,6 +33,7 @@ namespace { ...@@ -33,6 +33,7 @@ namespace {
struct SPDChromeVoice { struct SPDChromeVoice {
std::string name; std::string name;
std::string module; std::string module;
std::string language;
}; };
using PlatformVoices = std::map<std::string, SPDChromeVoice>; using PlatformVoices = std::map<std::string, SPDChromeVoice>;
...@@ -264,6 +265,7 @@ void TtsPlatformImplBackgroundWorker::InitializeVoices(PlatformVoices* voices) { ...@@ -264,6 +265,7 @@ void TtsPlatformImplBackgroundWorker::InitializeVoices(PlatformVoices* voices) {
SPDChromeVoice spd_data; SPDChromeVoice spd_data;
spd_data.name = spd_voice->name; spd_data.name = spd_voice->name;
spd_data.module = module; spd_data.module = module;
spd_data.language = spd_voice->language;
std::string key; std::string key;
key.append(spd_data.name); key.append(spd_data.name);
key.append(" "); key.append(" ");
...@@ -488,6 +490,7 @@ void TtsPlatformImplLinux::GetVoices(std::vector<VoiceData>* out_voices) { ...@@ -488,6 +490,7 @@ void TtsPlatformImplLinux::GetVoices(std::vector<VoiceData>* out_voices) {
VoiceData& voice = out_voices->back(); VoiceData& voice = out_voices->back();
voice.native = true; voice.native = true;
voice.name = it->first; voice.name = it->first;
voice.lang = it->second.language;
voice.events.insert(TTS_EVENT_START); voice.events.insert(TTS_EVENT_START);
voice.events.insert(TTS_EVENT_END); voice.events.insert(TTS_EVENT_END);
voice.events.insert(TTS_EVENT_CANCELLED); voice.events.insert(TTS_EVENT_CANCELLED);
......
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