Commit adfe3021 authored by Tim Volodine's avatar Tim Volodine Committed by Commit Bot

[Web Speech API] Make it possible to enable speech-to-text separately from text-to-speech.

Web Speech API [1] consists of two parts:
1. speech recognition (speech-to-text, STT)
2. speech synthesis (text-to-speech, TTS)

Currently Web Speech API can be either enabled or disabled completely,
by means of "disable-speech-api" command line flag. However we want to
be able to enable STT and TTS functionality separately. This has to do
with some security/privacy concerns regarding speech synthesis.

In particular we want to enable STT functionality in Android WebView,
but not TTS (at least until all concerns are addressed).

In this patch the ScriptedSpeech runtime blink flag is split into two:
ScriptedSpeechRecognition and ScriptedSpeechSynthesis. An additional
"disable-speech-synthesis-api" command line flag is added to control
how much of the Web Speech API we want to expose.

[1] https://w3c.github.io/speech-api/

BUG=487255

Change-Id: I959b73600bb8e7a0542661bfb997ceae1aa144ed
Reviewed-on: https://chromium-review.googlesource.com/c/1329150
Commit-Queue: Tim Volodine <timvolodine@chromium.org>
Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608374}
parent e9dca2f2
...@@ -148,8 +148,14 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( ...@@ -148,8 +148,14 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
if (command_line.HasSwitch(switches::kDisableSharedWorkers)) if (command_line.HasSwitch(switches::kDisableSharedWorkers))
WebRuntimeFeatures::EnableSharedWorker(false); WebRuntimeFeatures::EnableSharedWorker(false);
if (command_line.HasSwitch(switches::kDisableSpeechAPI)) if (command_line.HasSwitch(switches::kDisableSpeechAPI)) {
WebRuntimeFeatures::EnableScriptedSpeech(false); WebRuntimeFeatures::EnableScriptedSpeechRecognition(false);
WebRuntimeFeatures::EnableScriptedSpeechSynthesis(false);
}
if (command_line.HasSwitch(switches::kDisableSpeechSynthesisAPI)) {
WebRuntimeFeatures::EnableScriptedSpeechSynthesis(false);
}
if (command_line.HasSwitch(switches::kDisableFileSystem)) if (command_line.HasSwitch(switches::kDisableFileSystem))
WebRuntimeFeatures::EnableFileSystem(false); WebRuntimeFeatures::EnableFileSystem(false);
......
...@@ -267,14 +267,17 @@ const char kDisableSmoothScrolling[] = "disable-smooth-scrolling"; ...@@ -267,14 +267,17 @@ const char kDisableSmoothScrolling[] = "disable-smooth-scrolling";
// Disables the use of a 3D software rasterizer. // Disables the use of a 3D software rasterizer.
const char kDisableSoftwareRasterizer[] = "disable-software-rasterizer"; const char kDisableSoftwareRasterizer[] = "disable-software-rasterizer";
// Disables the Web Speech API. // Disables the Web Speech API (both speech recognition and synthesis).
const char kDisableSpeechAPI[] = "disable-speech-api"; const char kDisableSpeechAPI[] = "disable-speech-api";
// Disables the speech synthesis part of Web Speech API.
const char kDisableSpeechSynthesisAPI[] = "disable-speech-synthesis-api";
// Disables adding the test certs in the network process. // Disables adding the test certs in the network process.
const char kDisableTestCerts[] = "disable-test-root-certs"; const char kDisableTestCerts[] = "disable-test-root-certs";
// Disable multithreaded GPU compositing of web content. // Disable multithreaded GPU compositing of web content.
const char kDisableThreadedCompositing[] = "disable-threaded-compositing"; const char kDisableThreadedCompositing[] = "disable-threaded-compositing";
// Disable multithreaded, compositor scrolling of web content. // Disable multithreaded, compositor scrolling of web content.
const char kDisableThreadedScrolling[] = "disable-threaded-scrolling"; const char kDisableThreadedScrolling[] = "disable-threaded-scrolling";
......
...@@ -92,6 +92,7 @@ CONTENT_EXPORT extern const char kDisableSkiaRuntimeOpts[]; ...@@ -92,6 +92,7 @@ CONTENT_EXPORT extern const char kDisableSkiaRuntimeOpts[];
CONTENT_EXPORT extern const char kDisableSmoothScrolling[]; CONTENT_EXPORT extern const char kDisableSmoothScrolling[];
CONTENT_EXPORT extern const char kDisableSoftwareRasterizer[]; CONTENT_EXPORT extern const char kDisableSoftwareRasterizer[];
CONTENT_EXPORT extern const char kDisableSpeechAPI[]; CONTENT_EXPORT extern const char kDisableSpeechAPI[];
CONTENT_EXPORT extern const char kDisableSpeechSynthesisAPI[];
CONTENT_EXPORT extern const char kDisableTestCerts[]; CONTENT_EXPORT extern const char kDisableTestCerts[];
CONTENT_EXPORT extern const char kDisableThreadedCompositing[]; CONTENT_EXPORT extern const char kDisableThreadedCompositing[];
CONTENT_EXPORT extern const char kDisableThreadedScrolling[]; CONTENT_EXPORT extern const char kDisableThreadedScrolling[];
......
...@@ -152,7 +152,8 @@ class WebRuntimeFeatures { ...@@ -152,7 +152,8 @@ class WebRuntimeFeatures {
BLINK_PLATFORM_EXPORT static void EnableRemotePlaybackAPI(bool); BLINK_PLATFORM_EXPORT static void EnableRemotePlaybackAPI(bool);
BLINK_PLATFORM_EXPORT static void EnableRenderingPipelineThrottling(bool); BLINK_PLATFORM_EXPORT static void EnableRenderingPipelineThrottling(bool);
BLINK_PLATFORM_EXPORT static void EnableResourceLoadScheduler(bool); BLINK_PLATFORM_EXPORT static void EnableResourceLoadScheduler(bool);
BLINK_PLATFORM_EXPORT static void EnableScriptedSpeech(bool); BLINK_PLATFORM_EXPORT static void EnableScriptedSpeechRecognition(bool);
BLINK_PLATFORM_EXPORT static void EnableScriptedSpeechSynthesis(bool);
BLINK_PLATFORM_EXPORT static void EnableScrollAnchorSerialization(bool); BLINK_PLATFORM_EXPORT static void EnableScrollAnchorSerialization(bool);
BLINK_PLATFORM_EXPORT static void EnableSecMetadata(bool); BLINK_PLATFORM_EXPORT static void EnableSecMetadata(bool);
BLINK_PLATFORM_EXPORT static void EnableSharedArrayBuffer(bool); BLINK_PLATFORM_EXPORT static void EnableSharedArrayBuffer(bool);
......
...@@ -22,7 +22,7 @@ enum SpeechSynthesisErrorCode { ...@@ -22,7 +22,7 @@ enum SpeechSynthesisErrorCode {
[ [
Exposed=Window, Exposed=Window,
Constructor(DOMString type, SpeechSynthesisErrorEventInit eventInitDict), Constructor(DOMString type, SpeechSynthesisErrorEventInit eventInitDict),
RuntimeEnabled=ScriptedSpeech RuntimeEnabled=ScriptedSpeechSynthesis
] interface SpeechSynthesisErrorEvent : SpeechSynthesisEvent { ] interface SpeechSynthesisErrorEvent : SpeechSynthesisEvent {
readonly attribute SpeechSynthesisErrorCode error; readonly attribute SpeechSynthesisErrorCode error;
}; };
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// https://w3c.github.io/speech-api/#speechsynthesisevent // https://w3c.github.io/speech-api/#speechsynthesisevent
[ [
RuntimeEnabled=ScriptedSpeech, RuntimeEnabled=ScriptedSpeechSynthesis,
Constructor(DOMString type, SpeechSynthesisEventInit eventInitDict) Constructor(DOMString type, SpeechSynthesisEventInit eventInitDict)
] interface SpeechSynthesisEvent : Event { ] interface SpeechSynthesisEvent : Event {
readonly attribute SpeechSynthesisUtterance utterance; readonly attribute SpeechSynthesisUtterance utterance;
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
[ [
Constructor(optional DOMString text = null), Constructor(optional DOMString text = null),
ConstructorCallWith=ExecutionContext, ConstructorCallWith=ExecutionContext,
RuntimeEnabled=ScriptedSpeech RuntimeEnabled=ScriptedSpeechSynthesis
] interface SpeechSynthesisUtterance : EventTarget { ] interface SpeechSynthesisUtterance : EventTarget {
attribute DOMString text; attribute DOMString text;
attribute DOMString lang; attribute DOMString lang;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
[ [
ImplementedAs=DOMWindowSpeech, ImplementedAs=DOMWindowSpeech,
RuntimeEnabled=ScriptedSpeech RuntimeEnabled=ScriptedSpeechRecognition
] partial interface Window { ] partial interface Window {
[Measure] attribute SpeechGrammarConstructor webkitSpeechGrammar; [Measure] attribute SpeechGrammarConstructor webkitSpeechGrammar;
[Measure] attribute SpeechGrammarListConstructor webkitSpeechGrammarList; [Measure] attribute SpeechGrammarListConstructor webkitSpeechGrammarList;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
[ [
ImplementedAs=DOMWindowSpeechSynthesis, ImplementedAs=DOMWindowSpeechSynthesis,
RuntimeEnabled=ScriptedSpeech RuntimeEnabled=ScriptedSpeechSynthesis
] partial interface Window { ] partial interface Window {
[Measure, CallWith=ScriptState] readonly attribute SpeechSynthesis speechSynthesis; [Measure, CallWith=ScriptState] readonly attribute SpeechSynthesis speechSynthesis;
}; };
...@@ -332,8 +332,12 @@ void WebRuntimeFeatures::EnableRasterInducingScroll(bool enable) { ...@@ -332,8 +332,12 @@ void WebRuntimeFeatures::EnableRasterInducingScroll(bool enable) {
RuntimeEnabledFeatures::SetRasterInducingScrollEnabled(enable); RuntimeEnabledFeatures::SetRasterInducingScrollEnabled(enable);
} }
void WebRuntimeFeatures::EnableScriptedSpeech(bool enable) { void WebRuntimeFeatures::EnableScriptedSpeechRecognition(bool enable) {
RuntimeEnabledFeatures::SetScriptedSpeechEnabled(enable); RuntimeEnabledFeatures::SetScriptedSpeechRecognitionEnabled(enable);
}
void WebRuntimeFeatures::EnableScriptedSpeechSynthesis(bool enable) {
RuntimeEnabledFeatures::SetScriptedSpeechSynthesisEnabled(enable);
} }
bool WebRuntimeFeatures::IsSlimmingPaintV2Enabled() { bool WebRuntimeFeatures::IsSlimmingPaintV2Enabled() {
......
...@@ -1071,8 +1071,14 @@ ...@@ -1071,8 +1071,14 @@
{ {
name: "ScheduledScriptStreaming", name: "ScheduledScriptStreaming",
}, },
// WebSpeech API with both speech recognition and synthesis functionality
// is not fully enabled on all platforms.
{ {
name: "ScriptedSpeech", name: "ScriptedSpeechRecognition",
status: "stable",
},
{
name: "ScriptedSpeechSynthesis",
status: "stable", status: "stable",
}, },
// Serialize and restore scroll anchors. // Serialize and restore scroll anchors.
......
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