dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 1 | # The Chrome OS PATTS speech synthesis engine |
| 2 | |
| 3 | Chrome OS comes with a speech synthesis engine developed internally at Google |
| 4 | called PATTS. It's based on the same engine that ships with all Android devices. |
| 5 | |
David Tseng | 7f8ddfb | 2021-11-01 19:32:59 | [diff] [blame] | 6 | [Read more about Text-to-Speech in Chrome](../browser/tts.md). |
Katie D | ed1a997 | 2018-04-17 16:22:18 | [diff] [blame] | 7 | |
Dominic Mazzoni | fd246a0 | 2018-10-26 18:33:12 | [diff] [blame] | 8 | [See also the eSpeak engine](espeak.md). |
| 9 | |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 10 | ## Building from source |
| 11 | |
| 12 | This is for Googlers only. |
| 13 | |
Anastasia Helfinstein | 2ac2efb | 2022-01-19 17:38:11 | [diff] [blame] | 14 | Visit [http://go/google-tts-web-ports](http://go/google-tts-web-ports) |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 15 | for instructions on how to build the engine from source and get the |
| 16 | latest voice files. |
| 17 | |
| 18 | When debugging, start Chrome from the command-line and set the |
| 19 | NACL_PLUGIN_DEBUG environment variable to 1 to print log messages to stdout. |
| 20 | |
Katie D | 602acdef | 2018-01-18 19:38:02 | [diff] [blame] | 21 | If running on Chrome OS on desktop Linux, you can put the unpacked extension in |
| 22 | your downloads directory, and hide the existing TTS extension by temporarily |
| 23 | renaming /usr/share/chromeos-assets to something else. Then in |
| 24 | chrome://extensions you can enable developer mode and "load unpacked extension". |
| 25 | You must hide the existing TTS extension because extension keys must not be |
| 26 | duplicated, and ChromeOS will crash if you try to load the unpacked extension |
| 27 | while the built-in one is already loaded. |
| 28 | |
Katie D | 5da1390 | 2018-03-08 22:54:22 | [diff] [blame] | 29 | To test, use the [TTS Demo extension](https://chrome.google.com/webstore/detail/tts-demo/chhkejkkcghanjclmhhpncachhgejoel) |
Katie D | 602acdef | 2018-01-18 19:38:02 | [diff] [blame] | 30 | in Chromeos. This should automatically recognize the unpacked TTS extension |
| 31 | based on its manifest key. You can also use any site that uses a web speech API |
| 32 | demo. In addition, the Chrome Accessibility team has a |
Katie D | 5da1390 | 2018-03-08 22:54:22 | [diff] [blame] | 33 | [TTS Debug extension](https://chrome.google.com/webstore/detail/idllbaaoaldabjncnbfokacibfehkemd) |
Katie D | 602acdef | 2018-01-18 19:38:02 | [diff] [blame] | 34 | which can run several automated tests. |
| 35 | |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 36 | ## Updating |
| 37 | |
| 38 | First, follow the public |
| 39 | [Chromium OS Developer Guide](http://www.chromium.org/chromium-os/developer-guide) to check out the source. |
Katie D | 602acdef | 2018-01-18 19:38:02 | [diff] [blame] | 40 | At a minimum you'll need to create a chroot and initialize the build for your board. |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 41 | You do not need to build everything from source. |
| 42 | You do need to start the devserver. |
| 43 | |
| 44 | Next, flash your device to a very recent test build. Internally at Google |
| 45 | you can do this with the following command when the dev server is running, |
| 46 | where CHROMEBOOK_IP_ADDRESS is the IP address of your Chromebook already |
| 47 | in developer mode, and $BOARD is your Chromebook's board name. |
| 48 | |
| 49 | ```cros flash ssh://CHROMEBOOK_IP_ADDRESS xbuddy://remote/$BOARD/latest-dev/test``` |
| 50 | |
| 51 | Before you can make changes to PATTS, the first thing you need to run |
| 52 | (from the chroot) is call cros_workon with two relevant ebuilds: |
| 53 | |
| 54 | ``` |
wez | 0334393 | 2017-02-25 02:01:42 | [diff] [blame] | 55 | cros_workon --board=$BOARD start chromiumos-assets |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 56 | cros_workon --board=$BOARD start common-assets |
| 57 | ``` |
| 58 | |
wez | 0334393 | 2017-02-25 02:01:42 | [diff] [blame] | 59 | From outside the root, from anywhere under your top-level ```<repo-dir>```, pull down the relevant sources: |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 60 | |
| 61 | ``` |
wez | 0334393 | 2017-02-25 02:01:42 | [diff] [blame] | 62 | repo sync |
| 63 | ``` |
| 64 | |
| 65 | Again, outside the root, make sure you're in the ```<repo-dir>/src/platform/assets``` directory and run |
| 66 | ```repo start``` to create a branch: |
| 67 | |
| 68 | ``` |
| 69 | cd src/platform/assets |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 70 | repo start <branch_name> . |
| 71 | ``` |
| 72 | |
| 73 | |
| 74 | The PATTS data files can be found in this directory: |
| 75 | |
wez | 0334393 | 2017-02-25 02:01:42 | [diff] [blame] | 76 | ```src/platform/assets/speech_synthesis/patts``` |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 77 | |
| 78 | When updating the files, the native client files (nexe) need to be zipped. |
| 79 | |
Katie D | 602acdef | 2018-01-18 19:38:02 | [diff] [blame] | 80 | Replace all of the files you need to update. You will probably not need |
| 81 | to update the manifest.json, tts_main.js or tts_controller.js, as these |
| 82 | are probably most up-to-date on ChromeOS and not google3. Look at recent |
| 83 | commit history on both platforms to determine what changes should be |
| 84 | pushed. |
| 85 | |
| 86 | Commit your changes using git, then from the chroot, run: |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 87 | |
| 88 | ``` |
| 89 | emerge-$BOARD common-assets |
| 90 | cros deploy CHROMEBOOK_IP_ADDRESS common-assets |
| 91 | ``` |
| 92 | |
| 93 | Note that you need to call cros_workon on both chromeos-assets and |
| 94 | common-assets. You will be changing files in chromeos-assets, but |
| 95 | to flash it onto your device, you need to emerge and deploy |
| 96 | common-assets. |
| 97 | |
| 98 | After that, reboot your Chromebook and verify that speech works. |
| 99 | |
| 100 | To upload the change, use repo upload, something like this: |
| 101 | |
| 102 | ``` |
| 103 | git commit -a |
Lei Zhang | 3fd577db | 2020-05-21 21:33:19 | [diff] [blame] | 104 | Bug: chromium:12345 |
| 105 | Test: Write what you tested here |
dmazzoni | 2f48975 | 2017-02-16 03:39:16 | [diff] [blame] | 106 | repo upload . |
| 107 | ``` |
dmazzoni | e442e9b | 2017-03-02 06:08:08 | [diff] [blame] | 108 | |
Katie D | 5da1390 | 2018-03-08 22:54:22 | [diff] [blame] | 109 | After submitting, inform the [Chrome Accessibility Team](mailto:chrome-a11y-core@google.com) |
Katie D | 602acdef | 2018-01-18 19:38:02 | [diff] [blame] | 110 | so that they can update their local copies of TTS per the |
Katie D | 5da1390 | 2018-03-08 22:54:22 | [diff] [blame] | 111 | [Chromevox instructions](chromevox_on_desktop_linux.md). |
Katie D | 602acdef | 2018-01-18 19:38:02 | [diff] [blame] | 112 | |
dmazzoni | e442e9b | 2017-03-02 06:08:08 | [diff] [blame] | 113 | ## Ebuild |
| 114 | |
| 115 | Note that sometimes you'll have to update the ebuild file that |
| 116 | takes the patts data files and installs them, unzipping the .nexe |
| 117 | files in the process. |
| 118 | |
| 119 | For example, you'll need to edit the ebuild if you add or remove |
| 120 | a language code, or if you add or remove a file that needs to be |
| 121 | installed as part of the extension. |
| 122 | |
| 123 | To update the ebuild, edit this file: |
| 124 | |
| 125 | ``` |
| 126 | /third_party/chromiumos-overlay/chromeos-base/common-assets/common-assets-9999.ebuild |
| 127 | ``` |
| 128 | |
| 129 | If you need to land changes to both common-assets and chromiumos-assets, |
| 130 | upload the changes separately and then make them depend on one another |
| 131 | using this syntax in the changelog: |
| 132 | |
| 133 | ``` |
| 134 | CQ-DEPEND=CL:12345 |
| 135 | ``` |
| 136 | |
| 137 | Note that you can (and often should) have two changes depend on one another |
| 138 | so they'll land atomically. |
| 139 | |
| 140 | |