Commit c096295e authored by evliu's avatar evliu Committed by Chromium LUCI CQ

Destroy the speech recognition service if launched before the SODA files have finished downloading

This CL adds a check when binding the speech recognition recognizer to destroy the speech recognition service if the Speech On-Device API (SODA) binary or model files don't exist on the device. This scenario can occur if a user manually deletes the SODA files from their device and triggers the Live caption feature before the files are redownloaded. The speech recognition service will not be launched in the first place if the SODA components have never been installed before because the local prefs containing the paths to the files will be empty.

Bug: 1152915
Change-Id: I92d5abccf0ecd6c9fa5f1f80deda650f2344e879
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2561641Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: Evan Liu <evliu@google.com>
Cr-Commit-Position: refs/heads/master@{#831983}
parent bc9ea1a8
......@@ -4,7 +4,9 @@
#include "chrome/services/speech/speech_recognition_service_impl.h"
#include "base/files/file_util.h"
#include "chrome/services/speech/speech_recognition_recognizer_impl.h"
#include "media/base/media_switches.h"
namespace speech {
......@@ -54,6 +56,15 @@ void SpeechRecognitionServiceImpl::BindRecognizer(
mojo::PendingReceiver<media::mojom::SpeechRecognitionRecognizer> receiver,
mojo::PendingRemote<media::mojom::SpeechRecognitionRecognizerClient> client,
BindRecognizerCallback callback) {
// Destroy the speech recognition service if the SODA files haven't been
// downloaded yet.
if (base::FeatureList::IsEnabled(media::kUseSodaForLiveCaption) &&
(!base::PathExists(binary_path_) || !base::PathExists(config_path_))) {
speech_recognition_contexts_.Clear();
receiver_.reset();
return;
}
SpeechRecognitionRecognizerImpl::Create(
std::move(receiver), std::move(client), weak_factory_.GetWeakPtr(),
binary_path_, config_path_);
......
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