
./: overview docs R=katie@chromium.org platform-specific accessibility browser: docs pertaining to Chrome browser e.g. web contents and os: docs pertaining to Chrome OS Change-Id: I8b0423503d3199b10c8038e6cb45435558db1461 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3255169 Commit-Queue: David Tseng <dtseng@chromium.org> Reviewed-by: Katie Dektar <katie@chromium.org> Cr-Commit-Position: refs/heads/main@{#936992}
79 lines
2.9 KiB
Markdown
79 lines
2.9 KiB
Markdown
# Text to Speech in Chrome and Chrome OS
|
|
|
|
Chrome and Chrome OS allow developers to produce synthesized speech. This
|
|
document is an overview of the relevant code and code structure around
|
|
synthesized speech.
|
|
|
|
## Code structure
|
|
|
|
A brief outline of the flow from speech request to the resulting speech on any
|
|
platform.
|
|
|
|
### Input
|
|
|
|
- chrome.tts extension API
|
|
|
|
- The [chrome.tts extension API](https://developer.chrome.com/apps/tts)
|
|
allows extensions to request speech across Windows, Mac or Chrome OS, using
|
|
native speech synthesis.
|
|
|
|
- Input to the extension is first processed in the
|
|
[TtsExtensionApi](https://cs.chromium.org/chromium/src/chrome/browser/speech/extension_api/tts_extension_api.h).
|
|
|
|
- The extension is passed an [Options object](https://developer.chrome.com/apps/tts#method-speak)
|
|
in chrome.tts.speak, which is translated into a
|
|
[tts_controller Utterance](https://cs.chromium.org/chromium/src/content/public/browser/tts_controller.h?dr=CSs&l=120).
|
|
|
|
- Web Speech API
|
|
|
|
- Chrome implements
|
|
[Window.SpeechSynthesis](https://developer.mozilla.org/en-US/docs/Web/API/Window/speechSynthesis)
|
|
from the [Web Speech API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API).
|
|
This allows web apps to do text-to-speech via the device's speech
|
|
synthesizer.
|
|
|
|
- A [WebSpeechSynthesisUtterance](https://cs.chromium.org/chromium/src/third_party/blink/public/platform/web_speech_synthesis_utterance.h)
|
|
is created by window.SpeechSynthesis
|
|
|
|
### Processing
|
|
|
|
- The [TtsControllerImpl](https://cs.chromium.org/chromium/src/content/browser/speech/tts_controller_impl.h)
|
|
(in content/) processes utterances and sends them to the correct output engine.
|
|
|
|
- The [TtsControllerDelegateImpl](https://cs.chromium.org/chromium/src/chrome/browser/speech/tts_controller_delegate_impl.h)
|
|
(in chrome/) provides chrome OS specific functionality.
|
|
|
|
### Output
|
|
|
|
- May differ by system, including Mac, Wind, Android, Arc++, and Chrome OS
|
|
|
|
- Platform APIs are in [content/browser/speech](https://cs.chromium.org/chromium/src/content/browser/speech/), expect for
|
|
Chrome OS's, which is in [chrome/browser/speech](https://cs.chromium.org/chromium/src/chrome/browser/speech/).
|
|
|
|
- In Chrome OS:
|
|
|
|
- [TtsEngineExtensionAPI](https://cs.chromium.org/chromium/src/chrome/browser/speech/extension_api/tts_engine_extension_api.h)
|
|
forwards speech events to PATTS, or the network speech engine, or,
|
|
coming soon, third-party speech engines.
|
|
|
|
- [PATTS](../os/patts.md) is the built-in Chrome OS text-to-speech engine.
|
|
|
|
### Testing
|
|
|
|
- Unit tests
|
|
|
|
- TtsControllerUnittest in content/browser/speech
|
|
|
|
- TtsControllerDelegateImplUnittest in chrome/browser/speech
|
|
|
|
- ArcTtsServiceUnittest for ARC++ voices
|
|
|
|
- Browser tests
|
|
|
|
- TtsApiTest tests Chrome TTS extension APIs
|
|
|
|
- Fuzzer
|
|
|
|
- In content_unittests, content/browser/speech/tts_platform_fuzzer.cc
|
|
(currently Windows only).
|