diff options
Diffstat (limited to 'chromium/chromeos/services/tts')
-rw-r--r-- | chromium/chromeos/services/tts/BUILD.gn | 58 | ||||
-rw-r--r-- | chromium/chromeos/services/tts/public/mojom/BUILD.gn | 9 | ||||
-rw-r--r-- | chromium/chromeos/services/tts/public/mojom/tts_service.mojom | 85 |
3 files changed, 152 insertions, 0 deletions
diff --git a/chromium/chromeos/services/tts/BUILD.gn b/chromium/chromeos/services/tts/BUILD.gn new file mode 100644 index 00000000000..e2feb37c081 --- /dev/null +++ b/chromium/chromeos/services/tts/BUILD.gn @@ -0,0 +1,58 @@ +# Copyright 2020 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//tools/generate_library_loader/generate_library_loader.gni") + +source_set("tts") { + sources = [ + "constants.cc", + "constants.h", + "tts_service.cc", + "tts_service.h", + ] + + deps = [ + ":libchrometts", + "//base", + "//chromeos/services/tts/public/mojom", + ] +} + +source_set("sandbox_hook") { + sources = [ + "tts_sandbox_hook.cc", + "tts_sandbox_hook.h", + ] + + deps = [ + ":libchrometts", + ":tts", + "//base", + "//sandbox/linux:sandbox_services", + "//services/service_manager/sandbox:sandbox", + ] +} + +generate_library_loader("libchrometts") { + name = "LibChromeTtsLoader" + output_h = "libchrometts.h" + output_cc = "libchrometts_loader.cc" + header = "<chrome_tts.h>" + bundled_header = "\"chromeos/services/tts/chrome_tts.h\"" + + functions = [ + "GoogleTtsSetLogger", + "GoogleTtsInit", + "GoogleTtsShutdown", + "GoogleTtsInstallVoice", + "GoogleTtsInitBuffered", + "GoogleTtsReadBuffered", + "GoogleTtsFinalizeBuffered", + "GoogleTtsGetEventBufferPtr", + "GoogleTtsGetEventBufferLen", + "GoogleTtsGetTimepointsCount", + "GoogleTtsGetTimepointsTimeInSecsAtIndex", + "GoogleTtsGetTimepointsCharIndexAtIndex", + ] +} diff --git a/chromium/chromeos/services/tts/public/mojom/BUILD.gn b/chromium/chromeos/services/tts/public/mojom/BUILD.gn new file mode 100644 index 00000000000..b677781871c --- /dev/null +++ b/chromium/chromeos/services/tts/public/mojom/BUILD.gn @@ -0,0 +1,9 @@ +# Copyright 2020 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//mojo/public/tools/bindings/mojom.gni") + +mojom("mojom") { + sources = [ "tts_service.mojom" ] +} diff --git a/chromium/chromeos/services/tts/public/mojom/tts_service.mojom b/chromium/chromeos/services/tts/public/mojom/tts_service.mojom new file mode 100644 index 00000000000..a8fd1cdb6cf --- /dev/null +++ b/chromium/chromeos/services/tts/public/mojom/tts_service.mojom @@ -0,0 +1,85 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module chromeos.tts.mojom; + +// Structure describing a point in time during speech synthesis. +struct Timepoint { + // The time, in seconds. + float time_sec; + + // The index in the text being spoken. + int32 char_index; +}; + +// A TTS event and associated metadata within a TTS stream. +struct TtsStreamItem { + // An internal serialized proto.speech.tts.TtsControllerEvent proto. + array<uint8> event_buffer_bytes; + + // Whether streaming is complete. + bool done; + + // A list of timepoints associated with the event above. + array<Timepoint> timepoints; +}; + +// The main interface to the TTS engine on Chrome OS. Only used by and private +// to the Chrome OS Google TTS engine component extension. TtsService lives in a +// tts-sandboxed process. TtsEngineExtensionObserver, the other end of this +// interface, in the browser process, brokers a connection between TtsService +// and the Google TTS engine component extension through a TtsStream, but does +// not participate otherwise. +interface TtsService { + // Binds a TtsStream to this service. + BindTtsStream(pending_receiver<TtsStream> receiver); +}; + +// Interface for the Google component TTS engine to control and consume a stream +// of TtsStreamItems produced by TtsService. There is only ever one TtsStream +// owned by the TtsService. +// +// The component extension sets up the stream's voice by doing: +// InstallVoice(data, "voice") +// InstallVoice(other_data, "other_voice") +// SelectVoice("other_voice") +// +// After reading from the stream (see below), the component extension can do: +// SelectVoice("voice") +// to change voices. +// +// The component extension calls the following three methods repeatedly, in +// order to read from the stream given text. For example, +// +// Init(<a proto containing text "Hello there.">) +// Read() +// Read() +// ... +// Finalize() +// Init(<proto containing text "Testing 1, 2, 3.") +// Read() +// Read() +// ... +// Finalize() +// +// Note that the component extension may call Finalize() early, if the TTS api +// wants to, for example, stop speech. +interface TtsStream { + // Forward and install the |voice_name| encoded by |voice_bytes|. + InstallVoice(string voice_name, array<uint8> voice_bytes) + => (bool success); + + // Selects a voice for streaming given a |voice_name|. + SelectVoice(string voice_name) => (bool success); + + // Initialize a new TTS stream given a serialized proto.speech.tts.Text proto. + Init(array<uint8> text_jspb) + => (bool success); + + // Read the next stream item. + Read() => (TtsStreamItem item); + + // Clean up and finish the current TTS stream. + Finalize(); +}; |