├── .eslintrc.json
├── .github
└── workflows
│ └── ci-pipeline.yml
├── .gitignore
├── LICENSE
├── README.md
├── figures
└── wikivoice.png
├── index.js
├── package-lock.json
├── package.json
├── src
├── wiki2ssml.js
└── wikivoice.pegjs
├── test
├── helper.js
├── wiki2ssml-extension-test.js
└── wiki2ssml-test.js
└── yarn.lock
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true,
4 | "commonjs": true,
5 | "es6": true
6 | },
7 | "extends": "eslint:recommended",
8 | "parserOptions": {
9 | "ecmaVersion": 2017,
10 | "sourceType": "module"
11 | },
12 | "rules": {
13 | "indent": [
14 | "error",
15 | 4
16 | ],
17 | "linebreak-style": [
18 | "error",
19 | "unix"
20 | ],
21 | "quotes": [
22 | "error",
23 | "double"
24 | ],
25 | "semi": [
26 | "error",
27 | "always"
28 | ]
29 | },
30 | "globals": {
31 | "__dirname" : false,
32 | /* MOCHA */
33 | "describe" : false,
34 | "it" : false,
35 | "before" : false,
36 | "beforeEach" : false,
37 | "after" : false,
38 | "afterEach" : false
39 | }
40 | }
--------------------------------------------------------------------------------
/.github/workflows/ci-pipeline.yml:
--------------------------------------------------------------------------------
1 | name: ci pipeline
2 |
3 | on:
4 | - push
5 | - pull_request
6 |
7 | jobs:
8 | main:
9 |
10 | runs-on: ubuntu-latest
11 |
12 | strategy:
13 | matrix:
14 | node-version: [18.x, 20.x, 22.x, 23.x]
15 |
16 | steps:
17 | - uses: actions/checkout@v3
18 | - name: Node.js ${{ matrix.node-version }}
19 | uses: actions/setup-node@v3
20 | with:
21 | node-version: ${{ matrix.node-version }}
22 | - name: Dependency installation
23 | run: |
24 | npm ci
25 | npm run build --if-present
26 | - name: Linting
27 | run: npm run lint
28 | - name: Unit tests
29 | run: npm run test
30 | - name: Coverage
31 | run: npm run coverage
32 | - name: Codecov upload
33 | uses: codecov/codecov-action@v3
34 | with:
35 | token: ${{ secrets.CODECOV_TOKEN }}
36 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | .DS_Store
3 | npm-debug.log
4 | coverage
5 | .nyc_output
6 | TODO.txt
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright 2019 Xi Bai
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://github.com/baxtree/wiki2ssml/actions/workflows/ci-pipeline.yml?query=branch%3Amaster)   [](https://github.com/baxtree/wiki2ssml/blob/master/LICENSE)
2 |
3 |
4 | # Wiki2SSML
5 |
6 | `wiki2ssml` can transform the `WikiVoice` markups into the W3C SSML widely supported by various text-to-speech services as an interchange format for synthesised voice tuning.
7 |
8 | # Install
9 | ```sh
10 | $ npm install wiki2ssml
11 | ```
12 | or
13 | ```sh
14 | $ yarn add wiki2ssml
15 | ```
16 |
17 | # Introduction
18 | `wiki2ssml` eases the burden of editors preparing scripts in SSML, widely understood by modern speech synthesisers including but not limited to Amazon Polly, Google TTS, IBM Watson TTS and Microsoft Azure TTS. It has been developed in Vanilla JavaScript and powered by `WikiVoice` which provides an unobtrusive solution of blending voice-tuning markups with free texts and creates seamless experiences of editing scripts and voices in one go.
19 | #
20 |
21 |
22 |
23 |
24 | # Format
25 | ```
26 | [[attribute(:value)?(,attribute:value)*(|target)?]]
27 | ```
28 | # Supported Markups
29 | | Expressions | Operations|
30 | | ------------- |-------------|
31 | | [[volume:SCALE|TEXT]] | Speaking volume |
32 | | [[speed:SCALE|TEXT]] | Speaking rate |
33 | | [[pitch:SCALE|TEXT]] | Speaking pitch |
34 | | [[silence:DURATION,strength:STRENGTH]] | Pause with duration and strength |
35 | | [[emphasis:LEVEL|TEXT]] | Emphasis with LEVEL |
36 | | [[audio:AUDIO_URI]] | Audio embedded into speech|
37 | | [[lang:LANGUAGE|TEXT]] | Language indicator |
38 | | [[paragraph|TEXT]] | Paragraph indicator |
39 | | [[sentence|TEXT]] | Sentence indicator |
40 | | [[type:TYPE|TEXT]] | Type it should be said as |
41 | | [[voice:NAME|TEXT]] | Voice name it should be said with |
42 | | [[pos:POS|TEXT]] | Part of speech it should be prounouced as |
43 | | [[substitute:TEXT1|TEXT2]] | Replace TEXT2 with TEXT1 as substitution |
44 | | [[alphabet:ALPHABET,pronunciation:PRONUNCIATION|TEXT]] | Phonetic pronunciation |
45 | | [[volume:SCALE,speed:SCALE,pitch:SCALE|TEXT]] | Speaking volume, rate and pitch |
46 | | [[type:TYPE,format:FORMAT,detail:DETAIL|TEXT]] | Type it should be said as |
47 | | [[mark:NAME]] | Mark referencing a location |
48 | | [[seeAlso:URI] | URI providing additional information about marked-up content]
49 | | [[cacheControl:no-cache]] | No caching on marked-up content |
50 | | [[lexicon:URI,type:TEXT]] | Location of the lexicon document and its media type |
51 | | *[[...]][[...]]...[[...]]* | <par> time container with one or more markups|
52 | | #[[...]][[...]]...[[...]]# | <seq> time container with one or more markups|
53 |
54 | # Vendor-Specific Markups
55 | | Expressions | Operations|
56 | | ------------- |-------------|
57 | | [[amzWhispered|TEXT]] | Whispering |
58 | | [[amzPhonation:PHONATION|TEXT]] | Speaking Softly |
59 | | [[amzTimbre:SCALE|TEXT]] | Controlling Timbre |
60 | | [[amzDRC|TEXT]] | Dynamic Range Compression |
61 | | [[amzBreathDuration:SCALE,amzBreathVolume:SCALE]] | Breathing based on the manual model |
62 | | [[amzDefaultBreath]] | Default breathing based on the manual model |
63 | | [[amzAutoBreathsVolume:SCALE,amzAutoBreathsFrequency:SCALE,amzAutoBreathsDuration:SCALE|TEXT]] | Breathing based on the automated model |
64 | | [[amzDefaultAutoBreaths]] | Default breathing based on the automated model |
65 | | [[amzSpeakingStyle:STYLE|TEXT]] | Speaking style |
66 | | [[amzEmotion:EMOTION,amzIntensity:SCALE|TEXT]] | Speaking emotionally |
67 | | [[amzMaxDuration:DURATION#124;TEXT]] | Maximum Speech duration |
68 | | [[gglMediaSpeak|TEXT]] | Media container for speech |
69 | | [[gglMediaSpeakEnd:DURATION|TEXT]] | Media container for speech with the ending time |
70 | | [[gglMediaSpeakFadeIn:DURATION,gglMediaSpeakFadeOut:DURATION|TEXT]] | Media container for speach with fade |
71 | | [[gglMediaAudio:URI]] | Media container for audio |
72 | | [[gglMediaAudioFadeIn:DURATION,gglMediaAudioFadeOut:DURATION,gglMediaAudio:URI]] | Media container for audio with fade |
73 | | [[ibmExprType:TYPE|TEXT]] | Expressiveness type |
74 | | [[ibmTransType:TYPE,ibmTransStrength:SCALE|TEXT]] | Voice transformation |
75 | | [[ibmTransBreathiness:SCALE,ibmTransPitchRange:SCALE,ibmTransTimbre:SCALE|TEXT]] | Voice custom transformation |
76 | | [[voice:NAME|[[mstExprType:TYPE|TEXT]]]] | Voice-specific speaking style |
77 | | [[mstBackgroundAudio:URI,mstBackgroundAudioVolume:SCALE]] | Background audio and its volume |
78 | | [[mstBackgroundAudio:URI,mstBackgroundAudioFadeIn:SCALE,mstBackgroundAudioFadeOut:SCALE]] | Background audio with fade-in and fade-out |
79 | | [[mstExprStyle:STYLE,mstExprDegree:SCALE|TEXT]] | Speaking style and its intensity |
80 |
81 | More details on canonical attribute values can be found at [Speech Synthesis Markup Language (SSML)](https://www.w3.org/TR/speech-synthesis/). For ranges of vendor-specific values please refer to their online documents. Each attribute name in camel case can be rewritten in kebab case (e.g., firstSecondThird <=> first-second-third). Non-vendor-specific attributes can be abbreviated into their first three letters.
82 |
83 | # parseToSsml(input, languageCode, options)
84 | - input `` (required)
85 | - languageCode `` (required: [RFC 1766](https://tools.ietf.org/html/rfc1766))
86 | - options `` (optional)
87 | - version `` (default: "1.1")
88 | - pretty `` (default: false)
89 | - encoding `` (default: "UTF-8")
90 |
91 | # Example
92 | ```js
93 | var parser = require("wiki2ssml");
94 | try {
95 | var input = "[[volume:+2dB,speed:50%|Speak this with the volume increased by 2dB at half the default speech rate.]]";
96 | var ssml = parser.parseToSsml(input, "en-GB", {pretty: true});
97 | console.log(ssml);
98 | } catch (e) {
99 | if (e instanceof parser.SyntaxError) {
100 | // The input does not have valid WikiVoice markups
101 | } else if (e instanceof parser.ArgumentError) {
102 | // Either the input or the language code is missing
103 | } else {
104 | // Handle any unspecified exceptions
105 | }
106 | }
107 | ```
108 | will print out:
109 | ```xml
110 |
111 |
112 | Speak this with the volume increased by 2dB at half the default speech rate.
113 |
114 | ```
115 |
--------------------------------------------------------------------------------
/figures/wikivoice.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/baxtree/wiki2ssml/6cf59208a0953be8cd0d755c04dbca1f1d676fbc/figures/wikivoice.png
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | module.exports = require("./src/wiki2ssml");
4 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "wiki2ssml",
3 | "version": "0.2.21",
4 | "description": "Wiki2SSML provides the WikiVoice markup language used for fine-tuning synthesised voice.",
5 | "license": "Apache-2.0",
6 | "main": "index.js",
7 | "scripts": {
8 | "lint": "./node_modules/eslint/bin/eslint.js ./src/wiki2ssml.js ./test/wiki2ssml-test.js",
9 | "test": "./node_modules/mocha/bin/_mocha ./test/*-test.js",
10 | "coverage": "./node_modules/nyc/bin/nyc.js --reporter=lcov mocha"
11 | },
12 | "repository": {
13 | "type": "git",
14 | "url": "git+https://github.com/baxtree/wiki2ssml.git"
15 | },
16 | "keywords": [
17 | "ssml",
18 | "wikitext",
19 | "text-to-speech",
20 | "voice tuning",
21 | "amazon polly",
22 | "google cloud tts",
23 | "ibm watson tts",
24 | "microsoft azure tts",
25 | "nuance"
26 | ],
27 | "author": {
28 | "name": "Xi Bai",
29 | "email": "xi.bai.ed@gmail.com"
30 | },
31 | "bugs": {
32 | "url": "https://github.com/baxtree/wiki2ssml/issues"
33 | },
34 | "homepage": "https://github.com/baxtree/wiki2ssml#readme",
35 | "dependencies": {
36 | "peggy": "^3.0.2",
37 | "prettify-xml": "^1.2.0"
38 | },
39 | "devDependencies": {
40 | "chai": "^4.3.10",
41 | "eslint": "^8.43.0",
42 | "mocha": "^10.2.0",
43 | "nyc": "^15.1.0",
44 | "xml2js": "^0.6.2"
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/wiki2ssml.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var peggy = require("peggy");
4 | var fs = require("fs");
5 | var prettifyXml = require("prettify-xml");
6 |
7 | const _EXTNS = {
8 | "mstts": "http://www.w3.org/2001/mstts",
9 | "vxml": "http://www.w3.org/2001/vxml"
10 | };
11 |
12 | module.exports = (() => {
13 | try {
14 | var _parser = peggy.generate(fs.readFileSync(__dirname + "/wikivoice.pegjs").toString());
15 | }
16 | catch (e) {
17 | throw new SyntaxError(e.message);
18 | }
19 |
20 | var _getSsmlHead = (language, version, encoding) => {
21 | return "" +
22 | (version === "1.0" ? "" : "") +
23 | "";
28 | };
29 |
30 | var _getSsmlTail = () => {
31 | return " ";
32 | };
33 |
34 | var _getSsmlAsString = (ssmlBody, language, options) => {
35 | var ext_ns = "";
36 | for (var namespace in _EXTNS) {
37 | if (ssmlBody.indexOf(namespace + ":") > -1) {
38 | ext_ns += "xmlns:" + namespace + "=\"" + _EXTNS[namespace] + "\" ";
39 | }
40 | }
41 | var ssml = _getSsmlHead(language, options.version, options.encoding).replace("{{EXTNS_PLACEHOLDER}}", ext_ns) + ssmlBody + _getSsmlTail();
42 | if (options.pretty) {
43 | return prettifyXml(ssml, {indent: 2, newline: "\n"});
44 | }
45 | return ssml;
46 | };
47 |
48 | var _parseToSsml = (input, languageCode, options) => {
49 | if (!input || input.length === 0) {
50 | throw new ArgumentError("Input is missing when calling parseToSsml");
51 | }
52 | if (!languageCode) {
53 | throw new ArgumentError("Language code is missing when calling parseToSsml");
54 | }
55 | options = (typeof(options) === "undefined") ? {} : options;
56 | if (typeof(options.version) === "undefined") {
57 | options.version = "1.1";
58 | }
59 | if (typeof(options.pretty) === "undefined") {
60 | options.pretty = false;
61 | }
62 | if (typeof(options.encoding) === "undefined") {
63 | options.encoding = "UTF-8";
64 | }
65 | try {
66 | var parsed = _parser.parse(input);
67 | }
68 | catch (e) {
69 | throw new SyntaxError(e.message);
70 | }
71 | return _getSsmlAsString(parsed, languageCode, options);
72 | };
73 |
74 | class ArgumentError extends Error {
75 | constructor(message) {
76 | super(message);
77 | this.name = this.constructor.name;
78 | if (typeof Error.captureStackTrace === "function") {
79 | Error.captureStackTrace(this, this.constructor);
80 | } else {
81 | this.stack = (new Error(message)).stack;
82 | }
83 | }
84 | }
85 |
86 | class SyntaxError extends Error {
87 | constructor(message) {
88 | super(message);
89 | this.name = this.constructor.name;
90 | if (typeof Error.captureStackTrace === "function") {
91 | Error.captureStackTrace(this, this.constructor);
92 | } else {
93 | this.stack = (new Error(message)).stack;
94 | }
95 | }
96 | }
97 |
98 | return {
99 | parseToSsml: _parseToSsml,
100 |
101 | reloadGrammar: (grammar) => {
102 | try {
103 | _parser = peggy.generate(grammar);
104 | }
105 | catch (e) {
106 | throw new SyntaxError(e.message);
107 | }
108 | },
109 |
110 | parseToPlainText: (input) => {
111 | var parsed = _parseToSsml(input, "ANY");
112 | return parsed.replace(/(<([^>]+)>)/ig, "");
113 | },
114 |
115 | hasValidMarkups: (input) => {
116 | try {
117 | var ssmlBody = _parser.parse(input);
118 | return ssmlBody !== input;
119 | }
120 | catch (e) {
121 | return false;
122 | }
123 | },
124 |
125 | ArgumentError: ArgumentError,
126 | SyntaxError: SyntaxError
127 | };
128 | })();
--------------------------------------------------------------------------------
/src/wikivoice.pegjs:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | {
3 | /* eslint-enable */
4 | function toText(matches) {
5 | for (var i = 0; i < matches.length; i++) {
6 | matches[i] = matches[i][1];
7 | }
8 | return matches.join("").replace(/["'&<>]/g, (char) => {
9 | switch (char) {
10 | case "\"": return """;
11 | case "'": return "'";
12 | case "&": return "&";
13 | case "<": return "<";
14 | case ">": return ">";
15 | }
16 | });
17 | }
18 |
19 | function toTime(matches) {
20 | var sign = matches[0] == null ? "" : matches[0];
21 | var integral = matches[1].join("");
22 | var decimal = matches[2] == undefined ? "" : matches[2][0] + matches[2][1].join("")
23 | var unit = matches[3];
24 | return integral + decimal + unit;
25 | }
26 |
27 | function toVolume(matches) {
28 | if (matches[matches.length - 1] === "dB") {
29 | return matches[0].join("") + "dB";
30 | }
31 | return matches;
32 | }
33 |
34 | function toRate(matches) {
35 | if (matches[matches.length - 1] === "%") {
36 | return matches[0].join("") + "%";
37 | }
38 | return matches;
39 | }
40 |
41 | function toPitch(matches) {
42 | if (matches[matches.length - 1] === "%") {
43 | return matches[0].join("") + "%";
44 | }
45 | else if (matches[matches.length - 1] === "Hz") {
46 | return matches[0].join("") + "Hz";
47 | }
48 | else if (matches[matches.length - 1] === "st") {
49 | return matches[0].join("") + "st";
50 | }
51 | return matches;
52 | }
53 |
54 | function toDetail(matches) {
55 | return matches.join("");
56 | }
57 |
58 | function toFlattened(matches) {
59 | return matches.toString().split(",").join("");
60 | }
61 | /* eslint-disable */
62 | }
63 | BEGIN
64 | = text_and_statement:TextAndStatements* text:Text
65 | {
66 | return text_and_statement.join("") + text;
67 | }
68 |
69 | TextAndStatements
70 | = TextParallelStatements / TextSequentialStatements / TextStatement
71 |
72 | TextParallelStatements
73 | = text:Text statements:ParallelStatements
74 | {
75 | return text + statements;
76 | }
77 |
78 | TextSequentialStatements
79 | = text:Text statements:SequentialStatements
80 | {
81 | return text + statements;
82 | }
83 |
84 | TextStatement
85 | = text:Text statement:Statement
86 | {
87 | return text + statement;
88 | }
89 |
90 | Text
91 | = text:(!("[[" / "]]" / "*[[" / "]]*" / "#[[" / "]]#") .)*
92 | {
93 | return toText(text);
94 | }
95 |
96 | Target
97 | = text_left:Text statement:Statement* text_right:Text
98 | {
99 | return text_left + statement + text_right;
100 | }
101 |
102 | ParallelStatements
103 | = "*" statements:Statement+ "*"
104 | {
105 | return "" + statements.join("") + " ";
106 | }
107 |
108 | SequentialStatements
109 | = "#" statements:Statement+ "#"
110 | {
111 | return "" + statements.join("") + " ";
112 | }
113 |
114 | Statement
115 | = Prosody
116 | / Emphasis
117 | / Silence
118 | / Substitute
119 | / Audio
120 | / Lang
121 | / Paragraph
122 | / Sentence
123 | / Phoneme
124 | / Type
125 | / Voice
126 | / PartOfSpeech
127 | / Mark
128 | / SeeAlso
129 | / CacheControl
130 | / Lexicon
131 | / VendorExtension
132 |
133 | Prosody
134 | = SpeedPitchVolume / SpeedVolumePitch / PitchSpeedVolume / PitchVolumeSpeed / VolumeSpeedPitch / VolumePitchSpeed
135 | / SpeedPitch / SpeedVolume / PitchSpeed / PitchVolume / VolumeSpeed / VolumePitch
136 | / Speed / Pitch / Volume
137 |
138 | SpeedPitchVolume
139 | = "[[" _ ("speed"i / "spe"i) _ ":" _ speed:RATE _ "," _ ("pitch"i / "pit"i) _ ":" _ pitch:PITCH _ "," _ ("volume"i / "vol"i) _ ":" _ volume:VOLUME _ "|" target:Target "]]"
140 | {
141 | return '' + target + ' ';
142 | }
143 |
144 | SpeedVolumePitch
145 | = "[[" _ ("speed"i / "spe"i) _ ":" _ speed:RATE _ "," _ ("volume"i / "vol"i) _ ":" _ volume:VOLUME _ "," _ ("pitch"i / "pit"i) _ ":" _ pitch:PITCH _ "|" target:Target "]]"
146 | {
147 | return '' + target + ' ';
148 | }
149 |
150 | PitchSpeedVolume
151 | = "[[" _ ("pitch"i / "pit"i) _ ":" _ pitch:PITCH _ "," _ ("speed"i / "spe"i) _ ":" _ speed:RATE _ "," _ ("volume"i / "vol"i) _ ":" _ volume:VOLUME _ "|" target:Target "]]"
152 | {
153 | return '' + target + ' ';
154 | }
155 |
156 | PitchVolumeSpeed
157 | = "[[" _ ("pitch"i / "pit"i) _ ":" _ pitch:PITCH _ "," _ ("volume"i / "vol"i) _ ":" _ volume:VOLUME _ "," _ ("speed"i / "spe"i) _ ":" _ speed:RATE _ "|" target:Target "]]"
158 | {
159 | return '' + target + ' ';
160 | }
161 |
162 | VolumeSpeedPitch
163 | = "[[" _ ("volume"i / "vol"i) _ ":" _ volume:VOLUME _ "," _ ("speed"i / "spe"i) _ ":" _ speed:RATE _ "," _ ("pitch"i / "pit"i) _ ":" _ pitch:PITCH _ "|" target:Target "]]"
164 | {
165 | return '' + target + ' ';
166 | }
167 |
168 | VolumePitchSpeed
169 | = "[[" _ ("volume"i / "vol"i) _ ":" _ volume:VOLUME _ "," _ ("pitch"i / "pit"i) _ ":" _ pitch:PITCH _ "," _ ("speed"i / "spe"i) _ ":" _ speed:RATE _ "|" target:Target "]]"
170 | {
171 | return '' + target + ' ';
172 | }
173 |
174 | SpeedPitch
175 | = "[[" _ ("speed"i / "spe"i) _ ":" _ speed:RATE _ "," _ ("pitch"i / "pit"i) _ ":" _ pitch:PITCH _ "|" target:Target "]]"
176 | {
177 | return '' + target + ' ';
178 | }
179 |
180 | SpeedVolume
181 | = "[[" _ ("speed"i / "spe"i) _ ":" _ speed:RATE _ "," _ ("volume"i / "vol"i) _ ":" _ volume:VOLUME _ "|" target:Target "]]"
182 | {
183 | return '' + target + ' ';
184 | }
185 |
186 | PitchSpeed
187 | = "[[" _ ("pitch"i / "pit"i) _ ":" _ pitch:PITCH _ "," _ ("speed"i / "spe"i) _ ":" _ speed:RATE _ "|" target:Target "]]"
188 | {
189 | return '' + target + ' ';
190 | }
191 |
192 | PitchVolume
193 | = "[[" _ ("pitch"i / "pit"i) _ ":" _ pitch:PITCH _ "," _ ("volume"i / "vol"i) _ ":" _ volume:VOLUME _ "|" target:Target "]]"
194 | {
195 | return '' + target + ' ';
196 | }
197 |
198 | VolumeSpeed
199 | = "[[" _ ("volume"i / "vol"i) _ ":" _ volume:VOLUME _ "," _ ("speed"i / "spe"i) _ ":" _ speed:RATE _ "|" target:Target "]]"
200 | {
201 | return '' + target + ' ';
202 | }
203 |
204 | VolumePitch
205 | = "[[" _ ("volume"i / "vol"i) _ ":" _ volume:VOLUME _ "," _ ("pitch"i / "pit"i) _ ":" _ pitch:PITCH _ "|" target:Target "]]"
206 | {
207 | return '' + target + ' ';
208 | }
209 |
210 | Speed
211 | = "[[" _ ("speed"i / "spe"i) _ ":" _ speed:RATE _"|" target:Target "]]"
212 | {
213 | return '' + target + ' ';
214 | }
215 |
216 | Pitch
217 | = "[[" _ ("pitch"i / "pit"i) _ ":" _ pitch:PITCH _ "|" target:Target "]]"
218 | {
219 | return '' + target + ' ';
220 | }
221 |
222 | Volume
223 | = "[[" _ ("volume"i / "vol"i) _ ":" _ volume:VOLUME _ "|" target:Target "]]"
224 | {
225 | return '' + target + ' ';
226 | }
227 |
228 | Emphasis
229 | = "[[" _ ("emphasis"i / "emp"i) _ ":" _ level:LEVEL _ "|" target:Target "]]"
230 | {
231 | return '' + target + ' ';
232 | }
233 |
234 | Silence
235 | = SilenceTimeStrength / SilenceStrengthTime / SilenceTime / SilenceStrength
236 |
237 | SilenceTimeStrength
238 | = "[[" _ ("silence"i / "sil"i) _ ":" _ time:TIME _ "," _ ("strength"i / "str"i) _ ":" _ strength:STRENTH _ "]]"
239 | {
240 | return ' ';
241 | }
242 |
243 | SilenceStrengthTime
244 | = "[[" _ ("strength"i / "str"i) _ ":" _ strength:STRENTH _ "," _ ("silence"i / "sil"i) _ ":" _ time:TIME _ "]]"
245 | {
246 | return ' ';
247 | }
248 |
249 | SilenceTime
250 | = "[[" _ ("silence"i / "sil"i) _ ":" _ time:TIME _ "]]"
251 | {
252 | return ' ';
253 | }
254 |
255 | SilenceStrength
256 | = "[[" _ ("strength"i / "str"i) _ ":" _ strength:STRENTH _ "]]"
257 | {
258 | return ' ';
259 | }
260 |
261 | Substitute
262 | = "[[" _ ("substitute"i / "sub"i) _ ":" substitute:(!"|" .)+ "|" original:(!"]]" .)* "]]"
263 | {
264 | return '' + toText(original) + ' ';
265 | }
266 |
267 | Audio
268 | = AudioSrc / AudioSoundLevel / AudioClipBeginEnd / AudioClipEndBegin
269 | / AudioClipBeginEndRepeatCount / AudioClipRepeatCountBeginEnd
270 | / AudioClipBeginEndSpeed / AudioClipSpeedBeginEnd
271 | / AudioClipRepeatCountDuration / AudioClipRepeatDurationCount
272 |
273 | AudioSrc
274 | = "[[" _ ("audio"i / "aud"i) _ ":" uri:(!("," / "]]") .)+ "]]"
275 | {
276 | return ' '
277 | }
278 | AudioSoundLevel
279 | = "[[" _ ("audio"i / "aud"i) _ ":" _ uri:(!"," .)+ _ "," _ ("level"i / "lev"i) _ ":" _ sound_level:SOUND_LEVEL _ "]]"
280 | {
281 | return ' '
282 | }
283 |
284 | AudioClipBeginEnd
285 | = "[[" _ ("audio"i / "aud"i) _ ":" _ uri:(!"," .)+ _ "," _ ("begin"i / "beg"i) _ ":" _ clip_begin:TIME _ "," _ ("end"i) _ ":" _ clip_end:TIME _ "]]"
286 | {
287 | return ' '
288 | }
289 |
290 | AudioClipEndBegin
291 | = "[[" _ ("audio"i / "aud"i) _ ":" _ uri:(!"," .)+ _ "," _ ("end"i) _ ":" _ clip_end:TIME _ "," _ ("begin"i / "beg"i) _ ":" _ clip_begin:TIME _ "]]"
292 | {
293 | return ' '
294 | }
295 |
296 | AudioClipBeginEndRepeatCount
297 | = "[[" _ ("audio"i / "aud"i) _ ":" _ uri:(!"," .)+ _ "," _ ("begin"i / "beg"i) _ ":" _ clip_begin:TIME _ "," _ ("end"i) _ ":" _ clip_end:TIME _ "," _ ("count"i / "cou"i) _ ":" _ repeat_count:COUNT _ "]]"
298 | {
299 | return ' '
300 | }
301 |
302 | AudioClipRepeatCountBeginEnd
303 | = "[[" _ ("audio"i / "aud"i) _ ":" _ uri:(!"," .)+ _ "," _ ("count"i / "cou"i) _ ":" _ repeat_count:COUNT _ "," _ ("begin"i / "beg"i) _ ":" _ clip_begin:TIME _ "," _ ("end"i) _ ":" _ clip_end:TIME _ "]]"
304 | {
305 | return ' '
306 | }
307 |
308 | AudioClipRepeatCountDuration
309 | = "[[" _ ("audio"i / "aud"i) _ ":" _ uri:(!"," .)+ _ "," _ ("count"i / "cou"i) _ ":" _ repeat_count:COUNT _ "," _ ("duration"i / "dur"i) _ ":" _ duration:TIME _ "]]"
310 | {
311 | return ' '
312 | }
313 |
314 | AudioClipRepeatDurationCount
315 | = "[[" _ ("audio"i / "aud"i) _ ":" _ uri:(!"," .)+ _ "," _ ("duration"i / "dur"i) _ ":" _ duration:TIME _ "," _ ("count"i / "cou"i) _ ":" _ repeat_count:COUNT _ "]]"
316 | {
317 | return ' '
318 | }
319 |
320 | AudioClipBeginEndSpeed
321 | = "[[" _ ("audio"i / "aud"i) _ ":" _ uri:(!"," .)+ _ "," _ ("begin"i / "beg"i) _ ":" _ clip_begin:TIME _ "," _ ("end"i) _ ":" _ clip_end:TIME _ "," _ ("speed"i / "spe"i) _ ":" _ speed:NON_NEGATIVE_PERCENTAGE _ "]]"
322 | {
323 | return ' '
324 | }
325 |
326 | AudioClipSpeedBeginEnd
327 | = "[[" _ ("audio"i / "aud"i) _ ":" _ uri:(!"," .)+ _ "," _ ("speed"i / "spe"i) _ ":" _ speed:NON_NEGATIVE_PERCENTAGE _ "," _ ("begin"i / "beg"i) _ ":" _ clip_begin:TIME _ "," _ ("end"i) _ ":" _ clip_end:TIME _ "]]"
328 | {
329 | return ' '
330 | }
331 |
332 | Lang
333 | = "[[" _ ("lang"i / "lan"i) _ ":" lang:(!"|" .)+ "|" target:Target "]]"
334 | {
335 | return '' + target + ' '
336 | }
337 |
338 | Paragraph
339 | = "[[" _ ("paragraph"i / "par"i) _ "|" target:Target "]]"
340 | {
341 | return '' + target + '
'
342 | }
343 |
344 | Sentence
345 | = "[[" _ ("sentence"i / "sen"i) _ "|" target:Target "]]"
346 | {
347 | return '' + target + ' '
348 | }
349 |
350 | Type
351 | = InterpretFormatDetail / InterpretDetailFormat / FormatInterpretDetail / FormatDetailInterpret / DetailFormatInterpret / DetailInterpretFormat
352 | / InterpretFormat / FormatInterpret / Interpret
353 |
354 | InterpretFormatDetail
355 | = "[[" _ ("type"i / "typ"i) _ ":" _ interpret:INTERPRET _ "," _ ("format"i / "for"i) _ ":" _ format:FORMAT _ "," _ ("detail"i / "det"i) _ ":" _ detail:DETAIL _ "|" target:Target "]]"
356 | {
357 | return '' + target + ' ';
358 | }
359 |
360 | InterpretDetailFormat
361 | = "[[" _ ("type"i / "typ"i) _ ":" _ interpret:INTERPRET _ "," _ ("detail"i / "det"i) _ ":" _ detail:DETAIL _ "," _ ("format"i / "for"i) _ ":" _ format:FORMAT _ "|" target:Target "]]"
362 | {
363 | return '' + target + ' ';
364 | }
365 |
366 | FormatInterpretDetail
367 | = "[[" _ ("format"i / "for"i) _ ":" _ format:FORMAT _ "," _ ("type"i / "typ"i) _ ":" _ interpret:INTERPRET _ "," _ ("detail"i / "det"i) _ ":" _ detail:DETAIL _ "|" target:Target "]]"
368 | {
369 | return '' + target + ' ';
370 | }
371 |
372 | FormatDetailInterpret
373 | = "[[" _ ("format"i / "for"i) _ ":" _ format:FORMAT _ "," _ ("detail"i / "det"i) _ ":" _ detail:DETAIL _ "," _ ("type"i / "typ"i) _ ":" _ interpret:INTERPRET _ "|" target:Target "]]"
374 | {
375 | return '' + target + ' ';
376 | }
377 |
378 | DetailFormatInterpret
379 | = "[[" _ ("detail"i / "det"i) _ ":" _ detail:DETAIL _ "," _ ("format"i / "for"i) _ ":" _ format:FORMAT _ "," _ ("type"i / "typ"i) _":" _ interpret:INTERPRET _ "|" target:Target "]]"
380 | {
381 | return '' + target + ' ';
382 | }
383 |
384 | DetailInterpretFormat
385 | = "[[" _ ("detail"i / "det"i) _ ":" _ detail:DETAIL _ "," _ ("type"i / "typ"i) _ ":" _ interpret:INTERPRET _ "," _ ("format"i / "for"i) _ ":" _ format:FORMAT _ "|" target:Target "]]"
386 | {
387 | return '' + target + ' ';
388 | }
389 |
390 | FormatInterpret
391 | = "[[" _ ("format"i / "for"i) _ ":" _ format:FORMAT _ "," _ ("type"i / "typ"i) _ ":" _ interpret:INTERPRET _ "|" target:Target "]]"
392 | {
393 | return '' + target + ' ';
394 | }
395 |
396 | InterpretFormat
397 | = "[[" _ ("type"i / "typ"i) _ ":" _ interpret:INTERPRET _ "," _ ("format"i / "for"i) _ ":" _ format:FORMAT _ "|" target:Target "]]"
398 | {
399 | return '' + target + ' ';
400 | }
401 |
402 | Interpret
403 | = "[[" _ ("type"i / "typ"i) _ ":" _ interpret:INTERPRET _ "|" target:Target "]]"
404 | {
405 | return '' + target + ' ';
406 | }
407 |
408 | Voice
409 | = "[[" _ ("voice"i / "voi"i) _ ":" _ name:(!"|" .)+ _ "|" target:Target "]]"
410 | {
411 | return '' + target + ' ';
412 | }
413 |
414 | PartOfSpeech
415 | = "[[" _ ("pos"i) _ ":" _ role:(!"|" .)+ _ "|" target:Target "]]"
416 | {
417 | return '' + target + " "
418 | }
419 |
420 | Phoneme
421 | = AlphabetPronunciation / PronunciationAlphabet / Pronunciation
422 |
423 | AlphabetPronunciation
424 | = "[[" _ ("alphabet"i / "alp"i) _ ":" _ alphabet:(!"," .)+ "," _ ("pronunciation"i / "pro"i) _ ":" _ pronunciation:(!"|" .)+ "|" target:Target "]]"
425 | {
426 | return '' + target + ' ';
427 | }
428 |
429 | PronunciationAlphabet
430 | = "[[" _ ("pronunciation"i / "pro"i) _ ":" _ pronunciation:(!"," .)+ "," _ ("alphabet"i / "alp"i) _ ":" _ alphabet:(!"|" .)+ "|" target:Target "]]"
431 | {
432 | return '' + target + ' ';
433 | }
434 |
435 | Pronunciation
436 | = "[[" _ ("pronunciation"i / "pro"i) _ ":" _ pronunciation:(!"|" .)+ "|" target:Target "]]"
437 | {
438 | return '' + target + ' ';
439 | }
440 |
441 | Mark
442 | = "[[" _ ("mark"i / "mar"i) _ ":" name:(!"]]" .)+ "]]"
443 | {
444 | return ' ';
445 | }
446 |
447 | SeeAlso
448 | = "[[" _ ("see-also"i / "seeAlso"i / "see"i) _ ":" uri:(!"]]" .)+ "]]"
449 | {
450 | return ' '
451 | }
452 |
453 | CacheControl
454 | = "[[" _ ("cache-control" / "cacheControl"i / "cac"i) _ ":" content:(!"]]" .)* "]]"
455 | {
456 | return ' '
457 | }
458 |
459 | Lexicon
460 | = LexiconUriMediaType / LexiconMediaTypeUri / LexiconUri
461 |
462 | LexiconUri
463 | = "[[" _ ("lexicon"i / "lex"i) _ ":" uri:(!"]]" .)+ "]]"
464 | {
465 | return ' '
466 | }
467 |
468 | LexiconUriMediaType
469 | = "[[" _ ("lexicon"i / "lex"i) _ ":" _ uri:(!"," .)+ _ "," _ ("type"i / "typ"i) _ ":" _ type:(!"]]" .)+ "]]"
470 | {
471 | return ' '
472 | }
473 |
474 | LexiconMediaTypeUri
475 | = "[[" _ ("type"i / "typ"i) _ ":" _ type:(!"," .)+ _ "," _ ("lexicon"i / "lex"i) _ ":" _ uri:(!"]]" .)+ "]]"
476 | {
477 | return ' '
478 | }
479 |
480 | _ "optional whitespace"
481 | = [ \t\n\r]*
482 |
483 | STRENTH
484 | = "none" / "x-weak" / "weak" / "medium" / "strong" / "x-strong"
485 |
486 | LEVEL
487 | = "strong" / "moderate" / "none" / "reduced"
488 |
489 | TIME
490 | = [+|-]?[0-9]+(.[0-9]+)?"s" / [+|-]?[0-9]+(.[0-9]+)?"ms"
491 |
492 | RATE
493 | = "x-slow" / "slow" / "medium" / "fast" / "x-fast" / "default" / NON_NEGATIVE_PERCENTAGE
494 |
495 | PITCH
496 | = "x-low" / "low" / "medium" / "high" / "x-high" / "default" / PERCENTAGE / [\+\-0-9]+"Hz" / [\+\-0-9]+"st"
497 |
498 | VOLUME
499 | = "silent" / "x-soft" / "soft" / "medium" / "loud" / "x-loud" / "default" / SOUND_LEVEL
500 |
501 | INTERPRET
502 | = "cardinal" / "number" / "ordinal" / "characters" / "digits" / "fraction" / "expletive" / "bleep" / "interjection" / "unit" / "verbatim" / "spell-out" / "date" / "time" / "telephone" / "address"
503 | / "letters" / "vxml:boolean" / "vxml:currency" / "vxml:date" / "vxml:digits" / "vxml:phone"
504 |
505 | FORMAT
506 | = "hms24" / "hms12" / "mdy" / "dmy" / "ymd" / "md" / "dm" / "ym" / "my" / "d" / "m" / "y"
507 |
508 | DETAIL
509 | = [0-9]+ / [a-zA-Z]+
510 |
511 | PERCENTAGE
512 | = [\+\-0-9]+"%"
513 |
514 | NON_NEGATIVE_PERCENTAGE
515 | = [0-9]+"%"
516 |
517 | COUNT
518 | = [+]?[0-9]+(.[0-9]+)?
519 |
520 | SOUND_LEVEL
521 | = [\+\-0-9]+(.[0-9])*"dB"
522 |
523 | VendorExtension
524 | = AmazonWhispered / AmazonPhonation / AmazonTimbre / AmazonDynamicRangeCompression / AmazonMaxDuration
525 | / AmazonBreathSound / AmazonAutoBreathSound / AmazonSpeakingStyle / AmazonEmotionIntensity / AmazonIntensityEmotion
526 | / GoogleMediaContainer
527 | / IBMExpressiveness / IBMVoiceTransformation / IBMVoiceCustomTransformation
528 | / MicrosoftSpeakingStyleDegree / MicrosoftSpeakingDegreeStyle / MicrosoftSpeakingStyle
529 | / MicrosoftBackground
530 |
531 | AmazonWhispered
532 | = "[[" _ ("amz-whispered"i / "amz-whi"i / "amzWhispered"i / "aws"i) _ "|" target:Target "]]"
533 | {
534 | return '' + target + ' ';
535 | }
536 |
537 | AmazonPhonation
538 | = "[[" _ ("amz-phonation"i / "amz-pho"i / "amzPhonation"i / "aph"i) _ ":" _ phonation:AMAZON_PHONATION _ "|" target:Target "]]"
539 | {
540 | return '' + target + ' ';
541 | }
542 |
543 | AmazonTimbre
544 | = "[[" _ ("amz-timbre"i / "amz-tim"i / "amzTimbre"i / "ati"i) _ ":" _ timbre:PERCENTAGE _ "|" target:Target "]]"
545 | {
546 | return '' + target + ' ';
547 | }
548 |
549 | AmazonDynamicRangeCompression
550 | = "[[" _ ("amz-drc"i / "amzDRC"i / "adr"i) _ "|" target:Target "]]"
551 | {
552 | return '' + target + ' ';
553 | }
554 |
555 | AmazonMaxDuration
556 | = "[[" _ ("amz-max-duration"i / "amz-max-dur"i / "amzMaxDuration"i / "amd"i) _ ":" _ duration:AMAZON_MAX_DURATION _"|" target:Target "]]"
557 | {
558 | return '' + target + ' ';
559 | }
560 |
561 | AmazonBreathSound
562 | = AmazonBreathDurationVolume / AmazonBreathVolumeDuration
563 | / AmazonBreathDuration / AmazonBreathVolume
564 | / AmazonBreath
565 |
566 | AmazonBreathDurationVolume
567 | = "[[" _ ("amz-breath-duration"i / "amz-bre-dur"i / "amzBreathDuration"i / "abd"i) _ ":" _ duration:AMAZON_DURATION _ "," _ ("amz-breath-volume"i / "amz-bre-vol"i / "amzBreathVolume"i / "abv"i) _ ":" _ volume:VOLUME _ "]]"
568 | {
569 | return ' ';
570 | }
571 |
572 | AmazonBreathVolumeDuration
573 | = "[[" _ ("amz-breath-volume"i / "amz-bre-vol"i / "amzBreathVolume"i / "abv"i) _ ":" _ volume:VOLUME _ "," _ ("amz-breath-duration"i / "amz-bre-dur"i / "amzBreathDuration"i / "abd"i) _ ":" _ duration:AMAZON_DURATION _ "]]"
574 | {
575 | return ' ';
576 | }
577 |
578 | AmazonBreathDuration
579 | = "[[" _ ("amz-breath-duration"i / "amz-bre-dur"i / "amzBreathDuration"i / "abd"i) _ ":" _ duration:AMAZON_DURATION _ "]]"
580 | {
581 | return ' ';
582 | }
583 |
584 | AmazonBreathVolume
585 | = "[[" _ ("amz-breath-volume"i / "amz-bre-vol"i / "amzBreathVolume"i / "abv"i) _ ":" _ volume:VOLUME _ "]]"
586 | {
587 | return ' ';
588 | }
589 |
590 | AmazonBreath
591 | = "[[" _ ("amz-default-breath"i / "amz-def-bre"i / "amzDefaultBreath"i / "adb"i) _ "]]"
592 | {
593 | return ' ';
594 | }
595 |
596 | AmazonAutoBreathSound
597 | = AmazonAutoBreathsVolumeFrequencyDuration / AmazonAutoBreathsVolumeDurationFrequency / AmazonAutoBreathsDurationFrequencyVolume
598 | / AmazonAutoBreathsDurationVolumeFrequency / AmazonAutoBreathsFrequencyDurationVolume / AmazonAutoBreathsFrequencyVolumeDuration
599 | / AmazonAutoBreathsVolumeDuration / AmazonAutoBreathsDurationVolume
600 | / AmazonAutoBreathsVolumeFrequency / AmazonAutoBreathsFrequencyVolume
601 | / AmazonAutoBreathsFrequencyDuration / AmazonAutoBreathsDurationFrequency
602 | / AmazonAutoBreathsVolume / AmazonAutoBreathsFrequency / AmazonAutoBreathsDuration
603 | / AmazonAutoBreaths
604 |
605 | AmazonAutoBreathsVolumeFrequencyDuration
606 | = "[[" _ ("amz-auto-breaths-volume"i / "amz-aut-bre-vol"i / "amzAutoBreathsVolume"i / "abv"i) _ ":" _ volume:AMAZON_VOLUME _ "," _ ("amz-auto-breaths-frequency"i / "amz-auto-bre-fre"i / "amzAutoBreathsFrequency"i / "abf"i) _ ":" _ frequency:AMAZON_FREQUENCY _ "," _ ("amz-auto-breaths-duration"i / "amz-aut-bre-dur"i / "amzAutoBreathsDuration"i / "abd"i) _ ":" _ duration:AMAZON_DURATION _ "|" target:Target "]]"
607 | {
608 | return '' + target + ' ';
609 | }
610 |
611 | AmazonAutoBreathsVolumeDurationFrequency
612 | = "[[" _ ("amz-auto-breaths-volume"i / "amz-auto-bre-vol"i / "amzAutoBreathsVolume"i / "abv"i) _ ":" _ volume:AMAZON_VOLUME _ "," _ ("amz-auto-breaths-duration"i / "amz-aut-bre-dur"i / "amzAutoBreathsDuration"i / "abd"i) _ ":" _ duration:AMAZON_DURATION _ "," _ ("amz-auto-breaths-frequency"i / "amz-aut-bre-fre"i / "amzAutoBreathsFrequency"i / "abf"i) _ ":" _ frequency:AMAZON_FREQUENCY _ "|" target:Target "]]"
613 | {
614 | return '' + target + ' ';
615 | }
616 |
617 | AmazonAutoBreathsDurationFrequencyVolume
618 | = "[[" _ ("amz-auto-breaths-duration"i / "amz-aut-bre-dur"i / "amzAutoBreathsDuration"i / "abd"i) _ ":" _ duration:AMAZON_DURATION _ "," _ ("amz-auto-breaths-frequency"i / "amz-aut-bre-fre"i / "amzAutoBreathsFrequency"i / "abf"i) _ ":" _ frequency:AMAZON_FREQUENCY _ "," _ ("amz-auto-breaths-volume"i / "amz-auto-bre-vol"i / "amzAutoBreathsVolume"i / "abv"i) _ ":" _ volume:AMAZON_VOLUME _ "|" target:Target "]]"
619 | {
620 | return '' + target + ' ';
621 | }
622 |
623 | AmazonAutoBreathsDurationVolumeFrequency
624 | = "[[" _ ("amz-auto-breaths-duration"i / "amz-aut-bre-dur"i / "amzAutoBreathsDuration"i / "abd"i) _ ":" _ duration:AMAZON_DURATION _ "," _ ("amz-auto-breaths-volume"i / "amz-auto-bre-vol"i / "amzAutoBreathsVolume"i / "abv"i) _ ":" _ volume:AMAZON_VOLUME _ "," _ ("amz-auto-breaths-frequency"i / "amz-aut-bre-fre"i / "amzAutoBreathsFrequency"i / "abf"i) _ ":" _ frequency:AMAZON_FREQUENCY _ "|" target:Target "]]"
625 | {
626 | return '' + target + ' ';
627 | }
628 |
629 | AmazonAutoBreathsFrequencyDurationVolume
630 | = "[[" _ ("amz-auto-breaths-frequency"i / "amz-aut-bre-fre"i / "amzAutoBreathsFrequency"i / "abf"i) _ ":" _ frequency:AMAZON_FREQUENCY _ "," _ ("amz-auto-breaths-duration"i / "amz-aut-bre-dur"i / "amzAutoBreathsDuration"i / "abd"i) _ ":" _ duration:AMAZON_DURATION _ "," _ ("amz-auto-breaths-volume"i / "amz-auto-bre-vol"i / "amzAutoBreathsVolume"i / "abv"i) _ ":" _ volume:AMAZON_VOLUME _ "|" target:Target "]]"
631 | {
632 | return '' + target + ' ';
633 | }
634 |
635 | AmazonAutoBreathsFrequencyVolumeDuration
636 | = "[[" _ ("amz-auto-breaths-frequency"i / "amz-aut-bre-fre"i / "amzAutoBreathsFrequency"i / "abf"i) _ ":" _ frequency:AMAZON_FREQUENCY _ "," _ ("amz-auto-breaths-volume"i / "amz-auto-bre-vol"i / "amzAutoBreathsVolume"i / "abv"i) _ ":" _ volume:AMAZON_VOLUME _ "," _ ("amz-auto-breaths-duration"i / "amz-aut-bre-dur"i / "amzAutoBreathsDuration"i / "abd"i) _ ":" _ duration:AMAZON_DURATION _ "|" target:Target "]]"
637 | {
638 | return '' + target + ' ';
639 | }
640 |
641 | AmazonAutoBreathsVolumeFrequency
642 | = "[[" _ ("amz-auto-breaths-volume"i / "amz-auto-bre-vol"i / "amzAutoBreathsVolume"i / "abv"i) _ ":" _ volume:AMAZON_VOLUME _ "," _ ("amz-auto-breaths-frequency"i / "amz-aut-bre-fre"i / "amzAutoBreathsFrequency"i / "abf"i) _ ":" _ frequency:AMAZON_FREQUENCY _ "|" target:Target "]]"
643 | {
644 | return '' + target + ' ';
645 | }
646 |
647 | AmazonAutoBreathsFrequencyVolume
648 | = "[[" _ ("amz-auto-breaths-frequency"i / "amz-aut-bre-fre"i / "amzAutoBreathsFrequency"i / "abf"i) _ ":" _ frequency:AMAZON_FREQUENCY _ "," _ ("amz-auto-breaths-volume"i / "amz-auto-bre-vol"i / "amzAutoBreathsVolume"i / "abv"i) _ ":" _ volume:AMAZON_VOLUME _ "|" target:Target "]]"
649 | {
650 | return '' + target + ' ';
651 | }
652 |
653 | AmazonAutoBreathsVolumeDuration
654 | = "[[" _ ("amz-auto-breaths-volume"i / "amz-auto-bre-vol"i / "amzAutoBreathsVolume"i / "abv"i) _ ":" _ volume:AMAZON_VOLUME _ "," _ ("amz-auto-breaths-duration"i / "amz-aut-bre-dur"i / "amzAutoBreathsDuration"i / "abd"i) _ ":" _ duration:AMAZON_DURATION _ "|" target:Target "]]"
655 | {
656 | return '' + target + ' ';
657 | }
658 |
659 | AmazonAutoBreathsDurationVolume
660 | = "[[" _ ("amz-auto-breaths-duration"i / "amz-aut-bre-dur"i / "amzAutoBreathsDuration"i / "abd"i) _ ":" _ duration:AMAZON_DURATION _ "," _ ("amz-auto-breaths-volume"i / "amz-auto-bre-vol"i / "amzAutoBreathsVolume"i / "abv"i) _ ":" _ volume:AMAZON_VOLUME _ "|" target:Target "]]"
661 | {
662 | return '' + target + ' ';
663 | }
664 |
665 | AmazonAutoBreathsFrequencyDuration
666 | = "[[" _ ("amz-auto-breaths-frequency"i / "amz-aut-bre-fre"i / "amzAutoBreathsFrequency"i / "abf"i) _ ":" _ frequency:AMAZON_FREQUENCY _ "," _ ("amz-auto-breaths-duration"i / "amz-aut-bre-dur"i / "amzAutoBreathsDuration"i / "abd"i) _ ":" _ duration:AMAZON_DURATION _ "|" target:Target "]]"
667 | {
668 | return '' + target + ' ';
669 | }
670 |
671 | AmazonAutoBreathsDurationFrequency
672 | = "[[" _ ("amz-auto-breaths-duration"i / "amz-aut-bre-dur"i / "amzAutoBreathsDuration"i / "abd"i) _ ":" _ duration:AMAZON_DURATION _ "," _ ("amz-auto-breaths-frequency"i / "amz-aut-bre-fre"i / "amzAutoBreathsFrequency"i / "abf"i) _ ":" _ frequency:AMAZON_FREQUENCY _ "|" target:Target "]]"
673 | {
674 | return '' + target + ' ';
675 | }
676 |
677 | AmazonAutoBreathsVolume
678 | = "[[" _ ("amz-auto-breaths-volume"i / "amz-auto-bre-vol"i / "amzAutoBreathsVolume"i / "abv"i) _ ":" _ volume:AMAZON_VOLUME _ "|" target:Target "]]"
679 | {
680 | return '' + target + ' ';
681 | }
682 |
683 | AmazonAutoBreathsFrequency
684 | = "[[" _ ("amz-auto-breaths-frequency"i / "amz-aut-bre-fre"i / "amzAutoBreathsFrequency"i / "abf"i) _ ":" _ frequency:AMAZON_FREQUENCY _ "|" target:Target "]]"
685 | {
686 | return '' + target + ' ';
687 | }
688 |
689 | AmazonAutoBreathsDuration
690 | = "[[" _ ("amz-auto-breaths-duration"i / "amz-aut-bre-dur"i / "amzAutoBreathsDuration"i / "abd"i) _ ":" _ duration:AMAZON_DURATION _ "|" target:Target "]]"
691 | {
692 | return '' + target + ' ';
693 | }
694 |
695 | AmazonAutoBreaths
696 | = "[[" _ ("amz-default-auto-breaths"i / "amz-aut-bre"i / "amzDefaultAutoBreaths"i / "adb"i) _ "|" target:Target "]]"
697 | {
698 | return '' + target + ' ';
699 | }
700 |
701 | AmazonSpeakingStyle
702 | = "[[" _ ("amz-speaking-style"i / "amz-spe-sty"i / "amzSpeakingStyle"i / "ass"i) _ ":" _ style:AMAZON_STYLE _ "|" target:Target "]]"
703 | {
704 | return '' + target + ' ';
705 | }
706 |
707 | AmazonEmotionIntensity
708 | = "[[" _ ("amz-emotion"i / "amz-emo"i / "amzEmotion"i / "aem"i) _ ":" _ emotion:AMAZON_EMOTION _ "," _ ("amz-intensity"i / "amz-int"i / "amzIntensity"i / "ain"i) _ ":" _ intensity:AMAZON_INTENSITY _ "|" target:Target "]]"
709 | {
710 | return '' + target + ' ';
711 | }
712 |
713 | AmazonIntensityEmotion
714 | = "[[" _ ("amz-intensity"i / "amz-int"i / "amzIntensity"i / "ain"i) _ ":" _ intensity:AMAZON_INTENSITY _ "," _ ("amz-emotion"i / "amz-emo"i / "amzEmotion"i / "aem"i) _ ":" _ emotion:AMAZON_EMOTION _ "|" target:Target "]]"
715 | {
716 | return '' + target + ' ';
717 | }
718 |
719 | AMAZON_VOLUME
720 | = "default" / "x-soft" / "soft" / "medium" / "loud" / "x-loud"
721 |
722 | AMAZON_FREQUENCY
723 | = "default" / "x-low" / "low" / "medium" / "high" / "x-high"
724 |
725 | AMAZON_PHONATION
726 | = "soft"
727 |
728 | AMAZON_DURATION
729 | = "x-short" / "short" / "medium" / "long" / "x-long" / "default"
730 |
731 | AMAZON_STYLE
732 | = "music" / "news" / "conversational" / "long-form"
733 |
734 | AMAZON_EMOTION
735 | = "excited" / "disappointed"
736 |
737 | AMAZON_INTENSITY
738 | = "low" / "medium" / "high"
739 |
740 | AMAZON_MAX_DURATION
741 | = [+]?[0-9]+(.[0-9]+)?"s" / [+]?[0-9]+(.[0-9]+)?"ms"
742 |
743 | GoogleMediaContainer
744 | = GoolgeMediaSpeak / GoolgeMediaSpeakBegin / GoolgeMediaSpeakEnd / GoolgeMediaSpeakBeginEnd / GoolgeMediaSpeakEndBegin
745 | / GoolgeMediaAudio
746 | / GoolgeMediaSpeakFadeInFadeOut / GoolgeMediaSpeakFadeOutFadeIn
747 | / GoolgeMediaAudioFadeInFadeOutMedia / GoolgeMediaAudioFadeOutFadeInMedia
748 | / GoolgeMediaAudioMediaFadeInFadeOut / GoolgeMediaAudioMediaFadeOutFadeIn
749 | / GoolgeMediaAudioFadeInMediaFadeOut / GoolgeMediaAudioFadeOutMediaFadeIn
750 |
751 | GoolgeMediaSpeak
752 | = "[[" _ ("ggl-media-speak"i / "ggl-med-spe"i / "gglMediaSpeak"i / "gms"i) _ "|" target:Target "]]"
753 | {
754 | return '' + target + ' ';
755 | }
756 | GoolgeMediaSpeakBegin
757 | = "[[" _ ("ggl-media-speak-begin"i / "ggl-med-spe-begin"i / "gglMediaSpeakBegin"i / "gmsb"i) _ ":" _ time:GoogleTime _ "|" target:Target "]]"
758 | {
759 | return '' + target + ' ';
760 | }
761 |
762 | GoolgeMediaSpeakEnd
763 | = "[[" _ ("ggl-media-speak-end"i / "ggl-med-spe-end"i / "gglMediaSpeakEnd"i / "gmse"i) _ ":" _ time:GoogleTime _ "|" target:Target "]]"
764 | {
765 | return '' + target + ' ';
766 | }
767 |
768 | GoolgeMediaSpeakBeginEnd
769 | = "[[" _ ("ggl-media-speak-begin"i / "ggl-med-spe-begin"i / "gglMediaSpeakBegin"i / "gmsb"i) _ ":" _ begin:GoogleTime _ "," _ ("ggl-media-speak-end"i / "ggl-med-spe-end"i / "gglMediaSpeakEnd"i / "gmse"i) _ ":" _ end:GoogleTime _ "|" target:Target "]]"
770 | {
771 | return '' + target + ' ';
772 | }
773 |
774 | GoolgeMediaSpeakEndBegin
775 | = "[[" _ ("ggl-media-speak-end"i / "ggl-med-spe-end"i / "gglMediaSpeakEnd"i / "gmse"i) _ ":" _ end:GoogleTime _ "," _ ("ggl-media-speak-begin"i / "ggl-med-spe-begin"i / "gglMediaSpeakBegin"i / "gmsb"i) _ ":" _ begin:GoogleTime _ "|" target:Target "]]"
776 | {
777 | return '' + target + ' ';
778 | }
779 |
780 | GoolgeMediaSpeakFadeInFadeOut
781 | = "[[" _ ("ggl-media-speak-fade-in"i / "ggl-medi-spe-fad-in"i / "gglMediaSpeakFadeIn"i / "gsi"i) _ ":" _ fade_in_Duration:TIME _ "," _ ("ggl-media-speak-fade-out"i / "ggl-med-spe-fad-out"i / "gglMediaSpeakFadeOut"i / "gso"i) _ ":" _ fade_out_Duration:TIME _ "|" target:Target "]]"
782 | {
783 | return '' + target + ' ';
784 | }
785 |
786 | GoolgeMediaSpeakFadeOutFadeIn
787 | = "[[" _ ("ggl-media-speak-fade-out"i / "ggl-med-spe-fad-out"i / "gglMediaSpeakFadeOut"i / "gso"i) _ ":" _ fade_out_Duration:TIME _ "," _ ("ggl-media-speak-fade-in"i / "ggl-medi-spe-fad-in"i / "gglMediaSpeakFadeIn"i / "gsi"i) _ ":" _ fade_in_Duration:TIME _ "|" target:Target "]]"
788 | {
789 | return '' + target + ' ';
790 | }
791 |
792 | GoolgeMediaAudio
793 | = "[[" _ ("ggl-media-audio"i / "ggl-med-aud"i / "gglMediaAudio"i / "gma"i) _ ":" uri:(!("]]" / ",") .)+ "]]"
794 | {
795 | return ' '
796 | }
797 | GoolgeMediaAudioFadeInFadeOutMedia
798 | = "[[" _ ("ggl-media-audio-fade-in"i / "ggl-med-aud-fad-in"i / "gglMediaAudioFadeIn"i / "gfi"i) _ ":" _ fade_in_Duration:TIME _ "," _ ("ggl-media-audio-fade-out"i / "ggl-med-aud-fad-out"i / "gglMediaAudioFadeOut"i / "gfo"i) _ ":" _ fade_out_Duration:TIME _ "," _ ("ggl-media-audio"i / "ggl-med-aud"i / "gglMediaAudio"i / "gma"i) _ ":" uri:(!"]]" .)+ "]]"
799 | {
800 | return ' '
801 | }
802 |
803 | GoolgeMediaAudioFadeOutFadeInMedia
804 | = "[[" _ ("ggl-media-audio-fade-out"i / "ggl-med-aud-fad-out"i / "gglMediaAudioFadeOut"i / "gfo"i) _ ":" _ fade_out_Duration:TIME _ "," _ ("ggl-media-audio-fade-in"i / "ggl-med-aud-fad-in"i / "gglMediaAudioFadeIn"i / "gfi"i) _ ":" _ fade_in_Duration:TIME _ "," _ ("ggl-media-audio"i / "ggl-med-aud"i / "gglMediaAudio"i / "gma"i) _ ":" uri:(!"]]" .)+ "]]"
805 | {
806 | return ' '
807 | }
808 | GoolgeMediaAudioMediaFadeInFadeOut
809 | = "[[" _ ("ggl-media-audio"i / "ggl-med-aud"i / "gglMediaAudio"i / "gma"i) _ ":" uri:(!"," .)+ _ "," _ ("ggl-media-audio-fade-in"i / "ggl-med-aud-fad-in"i / "gglMediaAudioFadeIn"i / "gfi"i) _ ":" _ fade_in_Duration:TIME _ "," _ ("ggl-media-audio-fade-out"i / "ggl-med-aud-fad-out"i / "gglMediaAudioFadeOut"i / "gfo"i) _ ":" _ fade_out_Duration:TIME "]]"
810 | {
811 | return ' '
812 | }
813 |
814 | GoolgeMediaAudioMediaFadeOutFadeIn
815 | = "[[" _ ("ggl-media-audio"i / "ggl-med-aud"i / "gglMediaAudio"i / "gma"i) _ ":" uri:(!"," .)+ _ "," _ ("ggl-media-audio-fade-out"i / "ggl-med-aud-fad-out"i / "gglMediaAudioFadeOut"i / "gfo"i) _ ":" _ fade_out_Duration:TIME _ "," _ ("ggl-media-audio-fade-in"i / "ggl-med-aud-fad-in"i / "gglMediaAudioFadeIn"i / "gfi"i) _ ":" _ fade_in_Duration:TIME "]]"
816 | {
817 | return ' '
818 | }
819 |
820 | GoolgeMediaAudioFadeInMediaFadeOut
821 | = "[[" _ ("ggl-media-audio-fade-in"i / "ggl-med-aud-fad-in"i / "gglMediaAudioFadeIn"i / "gfi"i) _ ":" _ fade_in_Duration:TIME _ "," _ ("ggl-media-audio"i / "ggl-med-aud"i / "gglMediaAudio"i / "gma"i) _ ":" uri:(!"," .)+ _ "," _ ("ggl-media-audio-fade-out"i / "ggl-med-aud-fad-out"i / "gglMediaAudioFadeOut"i / "gfo"i) _ ":" _ fade_out_Duration:TIME "]]"
822 | {
823 | return ' '
824 | }
825 |
826 | GoolgeMediaAudioFadeOutMediaFadeIn
827 | = "[[" _ ("ggl-media-audio-fade-out"i / "ggl-med-aud-fad-out"i / "gglMediaAudioFadeOut"i / "gfo"i) _ ":" _ fade_out_Duration:TIME _ "," _ ("ggl-media-audio"i / "ggl-med-aud"i / "gglMediaAudio"i / "gma"i) _ ":" uri:(!"," .)+ _ "," _ ("ggl-media-audio-fade-in"i / "ggl-med-aud-fad-in"i / "gglMediaAudioFadeIn"i / "gfi"i) _ ":" _ fade_in_Duration:TIME "]]"
828 | {
829 | return ' '
830 | }
831 |
832 | GoogleTime
833 | = GoogleTimeDesignation / (!"." .)+."begin" GoogleTimeDesignation / (!"." .)+."end" GoogleTimeDesignation
834 |
835 | GoogleTimeDesignation
836 | = [+|-]?[0-9]+(.[0-9]+)?"h" / [+|-]?[0-9]+(.[0-9]+)?"min"/ TIME
837 |
838 | IBMExpressiveness
839 | = "[[" _ ("ibm-expr-type"i / "ibm-expr-typ"i / "ibmExprType"i / "iet"i) _ ":" _ expressiveness:IBM_EXPRTYPE _ "|" target:Target "]]"
840 | {
841 | return '' + target + ' ';
842 | }
843 |
844 | IBMVoiceTransformation
845 | = IBMTransformationTypeStrength / IBMTransformationStrengthType / IBMTransformationType
846 |
847 | IBMTransformationTypeStrength
848 | = "[[" _ ("ibm-trans-type"i / "ibm-tra-typ"i / "ibmTransType"i / "itt"i) _ ":" _ type:IBM_TRANSTYPE _ "," _ ("ibm-trans-strength"i / "ibm-tra-stre"i / "ibmTransStrength"i / "its"i) _ ":" _ strength:PERCENTAGE _ "|" target:Target "]]"
849 | {
850 | return '' + target + ' ';
851 | }
852 |
853 | IBMTransformationStrengthType
854 | = "[[" _ ("ibm-trans-strength"i / "ibm-tra-stre"i / "ibmTransStrength"i / "its"i) _ ":" _ strength:PERCENTAGE _ "," _ ("ibm-trans-type"i / "ibm-tra-typ"i / "ibmTransType"i / "itt"i) _ ":" _ type:IBM_TRANSTYPE _ "|" target:Target "]]"
855 | {
856 | return '' + target + ' ';
857 | }
858 |
859 | IBMTransformationType
860 | = "[[" _ ("ibm-trans-type"i / "ibm-tra-typ"i / "ibmTransType"i / "itt"i) _ ":" _ type:IBM_TRANSTYPE _ "|" target:Target "]]"
861 | {
862 | return '' + target + ' ';
863 | }
864 |
865 | IBMVoiceCustomTransformation
866 | = IBMTransformationBreathinessPitchRangeTimbre
867 | / IBMTransformationBreathinessTimbrePitchRange
868 | / IBMTransformationPitchRangeTimbreBreathiness
869 | / IBMTransformationPitchRangeBreathinessTimbre
870 | / IBMTransformationTimbreBreathinessPitchRange
871 | / IBMTransformationTimbrePitchRangeBreathiness
872 | / IBMTransformationBreathinessPitchRange / IBMTransformationPitchRangeBreathiness
873 | / IBMTransformationPitchRangeTimbre / IBMTransformationTimbrePitchRange
874 | / IBMTransformationTimbreBreathiness / IBMTransformationBreathinessTimbre
875 | / IBMTransformationBreathiness / IBMTransformationPitchRange / IBMTransformationTimbre
876 |
877 | IBMTransformationBreathinessPitchRangeTimbre
878 | = "[[" _ ("ibm-trans-breathiness"i / "ibm-tra-bre"i / "ibmTransBreathiness"i / "itb"i) _ ":" _ breathiness:IBM_BREATHINESS _ "," _ ("ibm-trans-pitch-range"i / "ibm-tra-pit-ran"i / "ibmTransPitchRange"i / "itp"i) _ ":" _ pitch_range:IBM_PITCH_RANGE _ "," _ ("ibm-trans-timbre"i / "ibm-tra-tim"i / "ibmTransTimbre"i / "itm"i) _ ":" _ timbre:IBM_TIMBRE _ "|" target:Target "]]"
879 | {
880 | return '' + target + ' ';
881 | }
882 |
883 | IBMTransformationBreathinessTimbrePitchRange
884 | = "[[" _ ("ibm-trans-breathiness"i / "ibm-tra-bre"i / "ibmTransBreathiness"i / "itb"i) _ ":" _ breathiness:IBM_BREATHINESS _ "," _ ("ibm-trans-timbre"i / "ibm-tra-tim"i / "ibmTransTimbre"i / "itm"i) _ ":" _ timbre:IBM_TIMBRE _ "," _ ("ibm-trans-pitch-range"i / "ibm-tra-pit-ran"i / "ibmTransPitchRange"i / "itp"i) _ ":" _ pitch_range:IBM_PITCH_RANGE _ "|" target:Target "]]"
885 | {
886 | return '' + target + ' ';
887 | }
888 |
889 | IBMTransformationPitchRangeTimbreBreathiness
890 | = "[[" _ ("ibm-trans-pitch-range"i / "ibm-tra-pit-ran"i / "ibmTransPitchRange"i / "itp"i) _ ":" _ pitch_range:IBM_PITCH_RANGE _ "," _ ("ibm-trans-timbre"i / "ibm-tra-tim"i / "ibmTransTimbre"i / "itm"i) _ ":" _ timbre:IBM_TIMBRE _ "," _ ("ibm-trans-breathiness"i / "ibm-tra-bre"i / "ibmTransBreathiness"i / "itb"i) _ ":" _ breathiness:IBM_BREATHINESS _ "|" target:Target "]]"
891 | {
892 | return '' + target + ' ';
893 | }
894 |
895 | IBMTransformationPitchRangeBreathinessTimbre
896 | = "[[" _ ("ibm-trans-pitch-range"i / "ibm-tra-pit-ran"i / "ibmTransPitchRange"i / "itp"i) _ ":" _ pitch_range:IBM_PITCH_RANGE _ "," _ ("ibm-trans-breathiness"i / "ibm-tra-bre"i / "ibmTransBreathiness"i / "itb"i) _ ":" _ breathiness:IBM_BREATHINESS _ "," _ ("ibm-trans-timbre"i / "ibm-tra-tim"i / "ibmTransTimbre"i / "itm"i) _ ":" _ timbre:IBM_TIMBRE _ "|" target:Target "]]"
897 | {
898 | return '' + target + ' ';
899 | }
900 |
901 | IBMTransformationTimbreBreathinessPitchRange
902 | = "[[" _ ("ibm-trans-timbre"i / "ibm-tra-tim"i / "ibmTransTimbre"i / "itm"i) _ ":" _ timbre:IBM_TIMBRE _ "," _ ("ibm-trans-breathiness"i / "ibm-tra-bre"i / "ibmTransBreathiness"i / "itb"i) _ ":" _ breathiness:IBM_BREATHINESS _ "," _ ("ibm-trans-pitch-range"i / "ibm-tra-pit-ran"i / "ibmTransPitchRange"i / "itp"i) _ ":" _ pitch_range:IBM_PITCH_RANGE _ "|" target:Target "]]"
903 | {
904 | return '' + target + ' ';
905 | }
906 |
907 | IBMTransformationTimbrePitchRangeBreathiness
908 | = "[[" _ ("ibm-trans-timbre"i / "ibm-tra-tim"i / "ibmTransTimbre"i / "itm"i) _ ":" _ timbre:IBM_TIMBRE _ "," _ ("ibm-trans-pitch-range"i / "ibm-tra-pit-ran"i / "ibmTransPitchRange"i / "itp"i) _ ":" _ pitch_range:IBM_PITCH_RANGE _ "," _ ("ibm-trans-breathiness"i / "ibm-tra-bre"i / "ibmTransBreathiness"i / "itb"i) _ ":" _ breathiness:IBM_BREATHINESS _ "|" target:Target "]]"
909 | {
910 | return '' + target + ' ';
911 | }
912 |
913 | IBMTransformationBreathinessPitchRange
914 | = "[[" _ ("ibm-trans-breathiness"i / "ibm-tra-bre"i / "ibmTransBreathiness"i / "itb"i) _ ":" _ breathiness:IBM_BREATHINESS _ "," _ ("ibm-trans-pitch-range"i / "ibm-tra-pit-ran"i / "ibmTransPitchRange"i / "itp"i) _ ":" _ pitch_range:IBM_PITCH_RANGE _ "|" target:Target "]]"
915 | {
916 | return '' + target + ' ';
917 | }
918 |
919 | IBMTransformationPitchRangeBreathiness
920 | = "[[" _ ("ibm-trans-pitch-range"i / "ibm-tra-pit-ran"i / "ibmTransPitchRange"i / "itp"i) _ ":" _ pitch_range:IBM_PITCH_RANGE _ "," _ ("ibm-trans-breathiness"i / "ibmTransBreathiness"i / "itb"i) _ ":" _ breathiness:IBM_BREATHINESS _ "|" target:Target "]]"
921 | {
922 | return '' + target + ' ';
923 | }
924 |
925 | IBMTransformationPitchRangeTimbre
926 | = "[[" _ ("ibm-trans-pitch-range"i / "ibm-tra-pit-ran"i / "ibmTransPitchRange"i / "itp"i) _ ":" _ pitch_range:IBM_PITCH_RANGE _ "," _ ("ibm-trans-timbre"i / "ibm-tra-tim"i / "ibmTransTimbre"i / "itm"i) _ ":" _ timbre:IBM_TIMBRE _ "|" target:Target "]]"
927 | {
928 | return '' + target + ' ';
929 | }
930 |
931 | IBMTransformationTimbrePitchRange
932 | = "[[" _ ("ibm-trans-timbre"i / "ibm-tra-tim"i / "ibmTransTimbre"i / "itm"i) _ ":" _ timbre:IBM_TIMBRE _ "," _ ("ibm-trans-pitch-range"i / "ibm-tra-pit-ran"i / "ibmTransPitchRange"i / "itp"i) _ ":" _ pitch_range:IBM_PITCH_RANGE _ "|" target:Target "]]"
933 | {
934 | return '' + target + ' ';
935 | }
936 |
937 | IBMTransformationTimbreBreathiness
938 | = "[[" _ ("ibm-trans-timbre"i / "ibm-tra-tim"i / "ibmTransTimbre"i / "itm"i) _ ":" _ timbre:IBM_TIMBRE _ "," _ ("ibm-trans-breathiness"i / "ibm-tra-bre"i / "ibmTransBreathiness"i / "itb"i) _ ":" _ breathiness:IBM_BREATHINESS _ "|" target:Target "]]"
939 | {
940 | return '' + target + ' ';
941 | }
942 |
943 | IBMTransformationBreathinessTimbre
944 | = "[[" _ ("ibm-trans-breathiness"i / "ibm-tra-bre"i / "ibmTransBreathiness"i / "itb"i) _ ":" _ breathiness:IBM_BREATHINESS _ "," _ ("ibm-trans-timbre"i / "ibm-tra-tim"i / "ibmTransTimbre"i / "itm"i) _ ":" _ timbre:IBM_TIMBRE _ "|" target:Target "]]"
945 | {
946 | return '' + target + ' ';
947 | }
948 |
949 | IBMTransformationBreathiness
950 | = "[[" _ ("ibm-trans-breathiness"i / "ibm-tra-bre"i / "ibmTransBreathiness"i / "itb"i) _ ":" _ breathiness:IBM_BREATHINESS _ "|" target:Target "]]"
951 | {
952 | return '' + target + ' ';
953 | }
954 |
955 | IBMTransformationPitchRange
956 | = "[[" _ ("ibm-trans-pitch-range"i / "ibm-tra-pit-ran"i / "ibmTransPitchRange"i / "itp"i) _ ":" _ pitch_range:IBM_PITCH_RANGE _ "|" target:Target "]]"
957 | {
958 | return '' + target + ' ';
959 | }
960 |
961 | IBMTransformationTimbre
962 | = "[[" _ ("ibm-trans-timbre"i / "ibm-tra-tim"i / "ibmTransTimbre"i / "itm"i) _ ":" _ timbre:IBM_TIMBRE _ "|" target:Target "]]"
963 | {
964 | return '' + target + ' ';
965 | }
966 |
967 | IBM_BREATHINESS
968 | = "x-low" / "low" / "default" / "high" / "x-high" / PERCENTAGE
969 |
970 | IBM_PITCH_RANGE
971 | = "x-narrow" / "narrow" / "default" / "wide" / "x-wide" / PERCENTAGE
972 |
973 | IBM_TIMBRE
974 | = "Sunrise" / "Breeze"
975 |
976 | IBM_TRANSTYPE
977 | = "Young" / "Soft"
978 |
979 | IBM_EXPRTYPE
980 | = "GoodNews" / "Apology" / "Uncertainty"
981 |
982 | MicrosoftBackground
983 | = MicrosoftBackgroundAudio
984 | / MicrosoftBackgroundAudioVolume / MicrosoftBackgroundVolumeAudio
985 | / MicrosoftBackgroundAudioFadeIn / MicrosoftBackgroundFadeInAudio
986 | / MicrosoftBackgroundAudioFadeOut / MicrosoftBackgroundFadeOutAudio
987 | / MicrosoftBackgroundAudioFadeInFadeOut / MicrosoftBackgroundAudioFadeOutFadeIn
988 | / MicrosoftBackgroundFadeInAudioFadeOut / MicrosoftBackgroundFadeInFadeOutAudio
989 | / MicrosoftBackgroundFadeOutAudioFadeIn / MicrosoftBackgroundFadeOutFadeInAudio
990 |
991 | MicrosoftSpeakingStyle
992 | = "[[" _ ("mst-expr-style"i / "mst-exp-sty"i / "mstExprStyle"i / "met"i) _ ":" _ expressiveness:(!"|" .)+ _ "|" target:Target "]]"
993 | {
994 | return '' + target + ' ';
995 | }
996 |
997 | MicrosoftSpeakingStyleDegree
998 | = "[[" _ ("mst-expr-style"i / "mst-exp-sty"i / "mstExprStyle"i / "met"i) _ ":" expressiveness:(!"," .)+ _ "," _ ("mst-expr-degree"i / "mst-exp-deg"i / "MstExprDegree"i / "med"i) _ ":" _ degree:MICROSOFT_STYLE_DEGREE _ "|" target:Target "]]"
999 | {
1000 | return '' + target + ' ';
1001 | }
1002 |
1003 | MicrosoftSpeakingDegreeStyle
1004 | = "[[" _ ("mst-expr-degree"i / "mst-exp-deg"i / "mstExprDegree"i / "med"i) _ ":" _ degree:MICROSOFT_STYLE_DEGREE + "," _ ("mst-expr-style"i / "mst-exp-sty"i / "mstExprStyle"i / "met"i) _ ":" expressiveness:(!"|" .)+ _ "|" target:Target "]]"
1005 | {
1006 | return '' + target + ' ';
1007 | }
1008 |
1009 | MicrosoftBackgroundAudio
1010 | = "[[" _ ("mst-background-audio"i / "mst-bg-aud"i / "mstBackgroundAudio"i / "mba"i) _ ":" uri:(!("]]" / ",") .)+ "]]"
1011 | {
1012 | return ' '
1013 | }
1014 |
1015 | MicrosoftBackgroundAudioVolume
1016 | = "[[" _ ("mst-background-audio"i / "mst-bg-aud"i / "mstBackgroundAudio"i / "mba"i) _ ":" uri:(!"," .)+ _ "," _ ("mst-background-audio-volume"i / "mst-bg-aud-vol"i / "mstBackgroundAudioVolume"i / "mbv"i) _ ":" _ volume:MICROSOFT_VOLUME "]]"
1017 | {
1018 | return ' '
1019 | }
1020 |
1021 | MicrosoftBackgroundVolumeAudio
1022 | = "[[" _ ("mst-background-audio-volume"i / "mst-bg-aud-vol"i / "mstBackgroundAudioVolume"i / "mbv"i) _ ":" _ volume:MICROSOFT_VOLUME _ "," _ ("mst-background-audio"i / "mst-bg-aud"i / "mstBackgroundAudio"i / "mba"i) _ ":" uri:(!("]]" / ",") .)+ "]]"
1023 | {
1024 | return ' '
1025 | }
1026 |
1027 | MicrosoftBackgroundAudioFadeIn
1028 | = "[[" _ ("mst-background-audio"i / "mst-bg-aud"i / "mstBackgroundAudio"i / "mba"i) _ ":" uri:(!"," .)+ _ "," _ ("mst-background-audio-fade-in"i / "mst-bg-aud-fad-in"i / "mstBackgroundAudioFadeIn"i / "mfi"i) _ ":" _ fade_millis:MICROSOFT_FADE_DURATION "]]"
1029 | {
1030 | return ' '
1031 | }
1032 |
1033 | MicrosoftBackgroundFadeInAudio
1034 | = "[[" _ ("mst-background-audio-fade-in"i / "mst-bg-aud-fad-in"i / "mstBackgroundAudioFadeIn"i / "mfi"i) _ ":" _ fade_millis:MICROSOFT_FADE_DURATION _ "," _ ("mst-background-audio"i / "mst-bg-aud"i / "mstBackgroundAudio"i / "mba"i) _ ":" uri:(!("]]" / ",") .)+ "]]"
1035 | {
1036 | return ' '
1037 | }
1038 |
1039 | MicrosoftBackgroundAudioFadeOut
1040 | = "[[" _ ("mst-background-audio"i / "mst-bg-aud"i / "mstBackgroundAudio"i / "mba"i) _ ":" uri:(!"," .)+ _ "," _ ("mst-background-audio-fade-out"i / "mst-bg-aud-fad-out"i / "mstBackgroundAudioFadeOut"i / "mfo"i) _ ":" _ fade_millis:MICROSOFT_FADE_DURATION "]]"
1041 | {
1042 | return ' '
1043 | }
1044 |
1045 | MicrosoftBackgroundFadeOutAudio
1046 | = "[[" _ ("mst-background-audio-fade-out"i / "mst-bg-aud-fad-out"i / "mstBackgroundAudioFadeOut"i / "mfo"i) _ ":" _ fade_millis:MICROSOFT_FADE_DURATION _ "," _ ("mst-background-audio"i / "mst-bg-aud"i / "mstBackgroundAudio"i / "mba"i) _ ":" uri:(!("]]" / ",") .)+ "]]"
1047 | {
1048 | return ' '
1049 | }
1050 |
1051 | MicrosoftBackgroundAudioFadeInFadeOut
1052 | = "[[" _ ("mst-background-audio"i / "mst-bg-aud"i / "mstBackgroundAudio"i / "mba"i) _ ":" uri:(!"," .)+ _ "," _ ("mst-background-audio-fade-in"i / "mst-bg-aud-fad-in"i / "mstBackgroundAudioFadeIn"i / "mfi"i) _ ":" _ fade_in_millis:MICROSOFT_FADE_DURATION _ "," _ ("mst-background-audio-fade-out"i / "mst-bg-aud-fad-out"i / "mstBackgroundAudioFadeOut"i / "mfo"i) _ ":" _ fade_out_millis:MICROSOFT_FADE_DURATION "]]"
1053 | {
1054 | return ' '
1055 | }
1056 |
1057 | MicrosoftBackgroundAudioFadeOutFadeIn
1058 | = "[[" _ ("mst-background-audio"i / "mst-bg-aud"i / "mstBackgroundAudio"i / "mba"i) _ ":" uri:(!"," .)+ _ "," _ ("mst-background-audio-fade-out"i / "mst-bg-aud-fad-out"i / "mstBackgroundAudioFadeOut"i / "mfo"i) _ ":" _ fade_out_millis:MICROSOFT_FADE_DURATION _ "," _ ("mst-background-audio-fade-in"i / "mst-bg-aud-fad-in"i / "mstBackgroundAudioFadeIn"i / "mfi"i) _ ":" _ fade_in_millis:MICROSOFT_FADE_DURATION "]]"
1059 | {
1060 | return ' '
1061 | }
1062 |
1063 | MicrosoftBackgroundFadeInAudioFadeOut
1064 | = "[[" _ ("mst-background-audio-fade-in"i / "mst-bg-aud-fad-in"i / "mstBackgroundAudioFadeIn"i / "mfi"i) _ ":" _ fade_in_millis:MICROSOFT_FADE_DURATION _ "," _ ("mst-background-audio"i / "mst-bg-aud"i / "mstBackgroundAudio"i / "mba"i) _ ":" uri:(!"," .)+ _ "," _ ("mst-background-audio-fade-out"i / "mst-bg-aud-fad-out"i / "mstBackgroundAudioFadeOut"i / "mfo"i) _ ":" _ fade_out_millis:MICROSOFT_FADE_DURATION "]]"
1065 | {
1066 | return ' '
1067 | }
1068 |
1069 | MicrosoftBackgroundFadeInFadeOutAudio
1070 | = "[[" _ ("mst-background-audio-fade-in"i / "mst-bg-aud-fad-in"i / "mstBackgroundAudioFadeIn"i / "mfi"i) _ ":" _ fade_in_millis:MICROSOFT_FADE_DURATION _ "," _ ("mst-background-audio-fade-out"i / "mst-bg-aud-fad-out"i / "mstBackgroundAudioFadeOut"i / "mfo"i) _ ":" _ fade_out_millis:MICROSOFT_FADE_DURATION _ "," _ ("mst-background-audio"i / "mst-bg-aud"i / "mstBackgroundAudio"i / "mba"i) _ ":" uri:(!("]]" / ",") .)+ "]]"
1071 | {
1072 | return ' '
1073 | }
1074 |
1075 | MicrosoftBackgroundFadeOutAudioFadeIn
1076 | = "[[" _ ("mst-background-audio-fade-out"i / "mst-bg-aud-fad-out"i / "mstBackgroundAudioFadeOut"i / "mfo"i) _ ":" _ fade_out_millis:MICROSOFT_FADE_DURATION _ "," _ ("mst-background-audio"i / "mst-bg-aud"i / "mstBackgroundAudio"i / "mba"i) _ ":" uri:(!"," .)+ _ "," _ ("mst-background-audio-fade-in"i / "mst-bg-aud-fad-in"i / "mstBackgroundAudioFadeIn"i / "mfi"i) _ ":" _ fade_in_millis:MICROSOFT_FADE_DURATION "]]"
1077 | {
1078 | return ' '
1079 | }
1080 |
1081 | MicrosoftBackgroundFadeOutFadeInAudio
1082 | = "[[" _ ("mst-background-audio-fade-out"i / "mst-bg-aud-fad-out"i / "mstBackgroundAudioFadeOut"i / "mfo"i) _ ":" _ fade_out_millis:MICROSOFT_FADE_DURATION _ "," _ ("mst-background-audio-fade-in"i / "mst-bg-aud-fad-in"i / "mstBackgroundAudioFadeIn"i / "mfi"i) _ ":" _ fade_in_millis:MICROSOFT_FADE_DURATION _ "," _ ("mst-background-audio"i / "mstBackgroundAudio"i / "mba"i) _ ":" uri:(!("]]" / ",") .)+ "]]"
1083 | {
1084 | return ' '
1085 | }
1086 |
1087 | MICROSOFT_VOLUME
1088 | = [1][0][0] / [1-9][0-9] / [0-9]
1089 |
1090 | MICROSOFT_FADE_DURATION
1091 | = [1][0][0][0][0] / [1-9][0-9][0-9][0-9] / [1-9][0-9][0-9] / [1-9][0-9] / [0-9]
1092 |
1093 | MICROSOFT_STYLE_DEGREE
1094 | = [+]?[0-9]+(.[0-9]+)?
--------------------------------------------------------------------------------
/test/helper.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var expect = require("chai").expect;
4 | var xml2js = require("xml2js");
5 |
6 | module.exports = (() => {
7 |
8 | const _HEAD = "" +
9 | "" +
10 | "";
14 | const _MSTTS_EXTENDED_HEAD = "" +
15 | "" +
16 | "";
21 | const _VXML_EXTENDED_HEAD = "" +
22 | "" +
23 | "";
28 | const _TAIL = " ";
29 |
30 | function _runHappyTests(tests, undertest) {
31 | tests.forEach((test) => {
32 | it("should parse " + test.expression + " and output SSML string", () => {
33 | var parsed = undertest.parseToSsml(test.expression, "en-GB", {version: "1.0"});
34 | expect(parsed).to.be.have.string(" { expect(err).to.be.null; });
37 | });
38 | });
39 | }
40 |
41 | function _runSadTests(tests, undertest) {
42 | tests.forEach((test) => {
43 | it("should fail on parsing " + test.expression, () => {
44 | try {
45 | undertest.parseToSsml(test.expression, "en-GB", {version: "1.0"});
46 | expect.fail();
47 | } catch (e) {
48 | expect(e instanceof test.expected).to.be.true;
49 | expect(e.message).to.have.string("Expected");
50 | }
51 | });
52 | });
53 | }
54 |
55 | return {
56 | HEAD: _HEAD,
57 | MSTTS_EXTENDED_HEAD: _MSTTS_EXTENDED_HEAD,
58 | VXML_EXTENDED_HEAD: _VXML_EXTENDED_HEAD,
59 | TAIL: _TAIL,
60 | runHappyTests: _runHappyTests,
61 | runSadTests: _runSadTests
62 | };
63 | })();
--------------------------------------------------------------------------------
/test/wiki2ssml-extension-test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var helper = require("./helper");
4 |
5 | describe("Test wiki2ssml", () => {
6 |
7 | var undertest;
8 |
9 | describe("Vendor extensions", () => {
10 | describe("Amazon Polly", () => {
11 | undertest = require("../src/wiki2ssml");
12 | var happy = [
13 | { expression: "[[amzWhispered|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
14 | { expression: "[[amz-whispered|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
15 | { expression: "[[aws|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
16 | { expression: "[[amzPhonation:soft|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
17 | { expression: "[[amz-phonation:soft|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
18 | { expression: "[[aph:soft|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
19 | { expression: "[[amzTimbre:+15%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
20 | { expression: "[[amz-timbre:+15%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
21 | { expression: "[[ati:+15%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
22 | { expression: "[[amzDRC|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
23 | { expression: "[[amz-drc|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
24 | { expression: "[[adr|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
25 | { expression: "[[amz-max-duration:5s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
26 | { expression: "[[amz-max-dur:5s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
27 | { expression: "[[amzMaxDuration:5s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
28 | { expression: "[[amd:5s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
29 | { expression: "[[amzBreathDuration:medium,amzBreathVolume:x-loud]]", expected: helper.HEAD + "" + helper.TAIL },
30 | { expression: "[[amz-breath-duration:medium,amz-breath-volume:x-loud]]", expected: helper.HEAD + "" + helper.TAIL },
31 | { expression: "[[abd:medium,abv:x-loud]]", expected: helper.HEAD + "" + helper.TAIL },
32 | { expression: "[[amzBreathVolume:x-loud,amzBreathDuration:medium]]", expected: helper.HEAD + "" + helper.TAIL },
33 | { expression: "[[amz-breath-volume:x-loud,amz-breath-duration:medium]]", expected: helper.HEAD + "" + helper.TAIL },
34 | { expression: "[[abv:x-loud,abd:medium]]", expected: helper.HEAD + "" + helper.TAIL },
35 | { expression: "[[amzBreathVolume:x-loud]]", expected: helper.HEAD + "" + helper.TAIL },
36 | { expression: "[[amz-breath-volume:x-loud]]", expected: helper.HEAD + "" + helper.TAIL },
37 | { expression: "[[abv:x-loud]]", expected: helper.HEAD + "" + helper.TAIL },
38 | { expression: "[[amzBreathDuration:medium]]", expected: helper.HEAD + "" + helper.TAIL },
39 | { expression: "[[amz-breath-duration:medium]]", expected: helper.HEAD + "" + helper.TAIL },
40 | { expression: "[[abd:medium]]", expected: helper.HEAD + "" + helper.TAIL },
41 | { expression: "[[amzDefaultBreath]]", expected: helper.HEAD + " " + helper.TAIL },
42 | { expression: "[[amz-default-breath]]", expected: helper.HEAD + " " + helper.TAIL },
43 | { expression: "[[adb]]", expected: helper.HEAD + " " + helper.TAIL },
44 | { expression: "[[amzAutoBreathsVolume:medium,amzAutoBreathsFrequency:low,amzAutoBreathsDuration:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
45 | { expression: "[[amz-auto-breaths-volume:medium,amz-auto-breaths-frequency:low,amz-auto-breaths-duration:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
46 | { expression: "[[abv:medium,abf:low,abd:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
47 | { expression: "[[amzAutoBreathsVolume:medium,amzAutoBreathsDuration:long,amzAutoBreathsFrequency:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
48 | { expression: "[[amz-auto-breaths-volume:medium,amz-auto-breaths-duration:long,amz-auto-breaths-frequency:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
49 | { expression: "[[abv:medium,abd:long,abf:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
50 | { expression: "[[amzAutoBreathsDuration:long,amzAutoBreathsFrequency:low,amzAutoBreathsVolume:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
51 | { expression: "[[amz-auto-breaths-duration:long,amz-auto-breaths-frequency:low,amz-auto-breaths-volume:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
52 | { expression: "[[abd:long,abf:low,abv:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
53 | { expression: "[[amzAutoBreathsDuration:long,amzAutoBreathsVolume:medium,amzAutoBreathsFrequency:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
54 | { expression: "[[amz-auto-breaths-duration:long,amz-auto-breaths-volume:medium,amz-auto-breaths-frequency:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
55 | { expression: "[[abd:long,abv:medium,abf:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
56 | { expression: "[[amzAutoBreathsFrequency:low,amzAutoBreathsVolume:medium,amzAutoBreathsDuration:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
57 | { expression: "[[amz-auto-breaths-frequency:low,amz-auto-breaths-volume:medium,amz-auto-breaths-duration:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
58 | { expression: "[[abf:low,abv:medium,abd:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
59 | { expression: "[[amzAutoBreathsFrequency:low,amzAutoBreathsDuration:long,amzAutoBreathsVolume:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
60 | { expression: "[[amz-auto-breaths-frequency:low,amz-auto-breaths-duration:long,amz-auto-breaths-volume:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
61 | { expression: "[[abf:low,abd:long,abv:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
62 | { expression: "[[amzAutoBreathsVolume:medium,amzAutoBreathsFrequency:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
63 | { expression: "[[amz-auto-breaths-volume:medium,amz-auto-breaths-frequency:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
64 | { expression: "[[abv:medium,abf:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
65 | { expression: "[[amzAutoBreathsFrequency:low,amzAutoBreathsVolume:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
66 | { expression: "[[amz-auto-breaths-frequency:low,amz-auto-breaths-volume:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
67 | { expression: "[[abf:low,abv:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
68 | { expression: "[[amzAutoBreathsDuration:long,amzAutoBreathsVolume:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
69 | { expression: "[[amz-auto-breaths-duration:long,amz-auto-breaths-volume:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
70 | { expression: "[[abd:long,abv:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
71 | { expression: "[[amzAutoBreathsVolume:medium,amzAutoBreathsDuration:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
72 | { expression: "[[amz-auto-breaths-volume:medium,amz-auto-breaths-duration:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
73 | { expression: "[[abv:medium,abd:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
74 | { expression: "[[amzAutoBreathsFrequency:low,amzAutoBreathsDuration:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
75 | { expression: "[[amz-auto-breaths-frequency:low,amz-auto-breaths-duration:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
76 | { expression: "[[abf:low,abd:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
77 | { expression: "[[amzAutoBreathsDuration:long,amzAutoBreathsFrequency:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
78 | { expression: "[[amz-auto-breaths-duration:long,amz-auto-breaths-frequency:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
79 | { expression: "[[abd:long,abf:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
80 | { expression: "[[amzAutoBreathsVolume:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
81 | { expression: "[[amz-auto-breaths-volume:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
82 | { expression: "[[abv:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
83 | { expression: "[[amzAutoBreathsFrequency:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
84 | { expression: "[[amz-auto-breaths-frequency:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
85 | { expression: "[[abf:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
86 | { expression: "[[amzAutoBreathsDuration:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
87 | { expression: "[[amz-auto-breaths-duration:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
88 | { expression: "[[abd:long|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
89 | { expression: "[[amzDefaultAutoBreaths|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
90 | { expression: "[[amz-default-auto-breaths|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
91 | { expression: "[[adb|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
92 | { expression: "[[amzSpeakingStyle:music|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
93 | { expression: "[[amz-speaking-style:music|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
94 | { expression: "[[ass:music|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
95 | { expression: "[[amzSpeakingStyle:news|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
96 | { expression: "[[amz-speaking-style:news|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
97 | { expression: "[[ass:news|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
98 | { expression: "[[amzSpeakingStyle:conversational|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
99 | { expression: "[[amz-speaking-style:conversational|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
100 | { expression: "[[ass:conversational|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
101 | { expression: "[[amzSpeakingStyle:long-form|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
102 | { expression: "[[amz-speaking-style:long-form|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
103 | { expression: "[[ass:long-form|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
104 | { expression: "[[amzEmotion:excited,amzIntensity:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
105 | { expression: "[[amz-emotion:excited,amz-intensity:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
106 | { expression: "[[aem:excited,ain:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
107 | { expression: "[[amzIntensity:low,amzEmotion:excited|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
108 | { expression: "[[amz-intensity:low,amz-emotion:excited|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
109 | { expression: "[[ain:low,aem:excited|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL }
110 | ];
111 |
112 | var sad = [
113 | { expression: "[[amzPhonation:unknown|TEXT]]", expected: undertest.SyntaxError },
114 | { expression: "[[amzTimbre:unknown|TEXT]]", expected: undertest.SyntaxError },
115 | { expression: "[[amz-max-duration:5m|TEXT]]", expected: undertest.SyntaxError },
116 | { expression: "[[amz-max-duration:5h|TEXT]]", expected: undertest.SyntaxError },
117 | { expression: "[[amzBreathVolume:unknown]]", expected: undertest.SyntaxError },
118 | { expression: "[[amzBreathDuration:unknown]]", expected: undertest.SyntaxError },
119 | { expression: "[[amzAutoBreathsVolume:unknown|TEXT]]", expected: undertest.SyntaxError },
120 | { expression: "[[amzAutoBreathsFrequency:unknown|TEXT]]", expected: undertest.SyntaxError },
121 | { expression: "[[amzAutoBreathsDuration:unknown|TEXT]]", expected: undertest.SyntaxError },
122 | { expression: "[[amzSpeakingStyle:unknown|TEXT]]", expected: undertest.SyntaxError },
123 | { expression: "[[amzEmotion:unknown,amzIntensity:low|TEXT]]", expected: undertest.SyntaxError },
124 | { expression: "[[amzIntensity:unknown, amzEmotion:excited|TEXT]]", expected: undertest.SyntaxError }
125 | ];
126 |
127 | helper.runHappyTests(happy, undertest);
128 | helper.runSadTests(sad, undertest);
129 | });
130 | });
131 |
132 | describe("Google Text to Speech", () => {
133 | undertest = require("../src/wiki2ssml");
134 | var happy = [
135 | { expression: "[[gglMediaSpeak|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
136 | { expression: "[[ggl-media-speak|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
137 | { expression: "[[gms|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
138 | { expression: "[[gglMediaSpeakBegin:-10s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
139 | { expression: "[[ggl-media-speak-begin:10s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
140 | { expression: "[[gmsb:10s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
141 | { expression: "[[gglMediaSpeakEnd:10s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
142 | { expression: "[[ggl-media-speak-end:10s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
143 | { expression: "[[gmse:10s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
144 | { expression: "[[gglMediaSpeakBegin:5s,gglMediaSpeakEnd:10s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
145 | { expression: "[[gglMediaSpeakEnd:10s,gglMediaSpeakBegin:5s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
146 | { expression: "[[ggl-media-speak-end:+10s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
147 | { expression: "[[ggl-media-speak-begin:foo_id.begin+250ms|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
148 | { expression: "[[ggl-media-speak-end:foo_id.end-250ms|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
149 | { expression: "[[gglMediaSpeakFadeIn:1s,gglMediaSpeakFadeOut:2s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
150 | { expression: "[[ggl-media-speak-fade-in:1s,ggl-media-speak-fade-out:2s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
151 | { expression: "[[gglMediaSpeakFadeOut:2s,gglMediaSpeakFadeIn:1s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
152 | { expression: "[[ggl-media-speak-fade-out:2s,ggl-media-speak-fade-in:1s|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
153 | { expression: "[[gglMediaAudio:https://example.mp3]]", expected: helper.HEAD + " " + helper.TAIL },
154 | { expression: "[[ggl-media-audio:https://example.mp3]]", expected: helper.HEAD + " " + helper.TAIL },
155 | { expression: "[[gma:https://example.mp3]]", expected: helper.HEAD + " " + helper.TAIL },
156 | { expression: "[[gglMediaAudioFadeIn:1ms,gglMediaAudioFadeOut:2ms,gglMediaAudio:https://example.mp3]]", expected: helper.HEAD + " " + helper.TAIL },
157 | { expression: "[[ggl-media-audio-fade-in:1ms,ggl-media-audio-fade-out:2ms,ggl-media-audio:https://example.mp3]]", expected: helper.HEAD + " " + helper.TAIL },
158 | { expression: "[[gglMediaAudio:https://example.mp3,gglMediaAudioFadeIn:1ms,gglMediaAudioFadeOut:2ms]]", expected: helper.HEAD + " " + helper.TAIL },
159 | { expression: "[[ggl-media-audio:https://example.mp3,gglMediaAudioFadeIn:1ms,gglMediaAudioFadeOut:2ms]]", expected: helper.HEAD + " " + helper.TAIL },
160 | { expression: "[[gglMediaAudio:https://example.mp3,gglMediaAudioFadeOut:2s,gglMediaAudioFadeIn:1s]]", expected: helper.HEAD + " " + helper.TAIL },
161 | { expression: "[[ggl-media-audio:https://example.mp3,gglMediaAudioFadeOut:2s,gglMediaAudioFadeIn:1s]]", expected: helper.HEAD + " " + helper.TAIL },
162 | { expression: "[[gglMediaAudioFadeIn:1ms,gglMediaAudio:https://example.mp3,gglMediaAudioFadeOut:2ms]]", expected: helper.HEAD + " " + helper.TAIL },
163 | { expression: "[[ggl-media-audio-fade-in:1ms,ggl-media-audio:https://example.mp3,ggl-media-audio-fade-out:2ms]]", expected: helper.HEAD + " " + helper.TAIL },
164 | { expression: "[[gglMediaAudioFadeOut:2s,gglMediaAudio:https://example.mp3,gglMediaAudioFadeIn:1s]]", expected: helper.HEAD + " " + helper.TAIL },
165 | { expression: "[[ggl-media-audio-fade-out:2s,ggl-media-audio:https://example.mp3,gglMediaAudioFadeIn:1s]]", expected: helper.HEAD + " " + helper.TAIL },
166 | { expression: "[[gfi:1ms,gfo:2ms,gglMediaAudio:https://example.mp3]]", expected: helper.HEAD + " " + helper.TAIL },
167 | { expression: "[[gfi:1ms,gfo:2ms,ggl-media-audio:https://example.mp3]]", expected: helper.HEAD + " " + helper.TAIL },
168 | { expression: "[[gglMediaAudioFadeOut:2ms,gglMediaAudioFadeIn:1ms,gglMediaAudio:https://example.mp3]]", expected: helper.HEAD + " " + helper.TAIL },
169 | { expression: "[[ggl-media-audio-fade-out:2ms,ggl-media-audio-fade-in:1ms,ggl-media-audio:https://example.mp3]]", expected: helper.HEAD + " " + helper.TAIL },
170 | { expression: "[[gfo:2ms,gfi:1ms,gglMediaAudio:https://example.mp3]]", expected: helper.HEAD + " " + helper.TAIL },
171 | { expression: "[[gfo:2ms,gfi:1ms,ggl-media-audio:https://example.mp3]]", expected: helper.HEAD + " " + helper.TAIL }
172 | ];
173 |
174 | var sad = [
175 | { expression: "[[gglMediaSpeakEnd:unknown|TEXT]]", expected: undertest.SyntaxError },
176 | { expression: "[[gglMediaAudioFadeOut:unknown,gglMediaAudioFadeIn:1ms,gglMediaAudio:https://example.mp3]]", expected: undertest.SyntaxError },
177 | { expression: "[[gglMediaAudioFadeOut:2s,gglMediaAudioFadeIn:unknown,gglMediaAudio:https://example.mp3]]", expected: undertest.SyntaxError }
178 | ];
179 |
180 | helper.runHappyTests(happy, undertest);
181 | helper.runSadTests(sad, undertest);
182 | });
183 |
184 | describe("IBM Watson Text to Speech", () => {
185 | undertest = require("../src/wiki2ssml");
186 | var happy = [
187 | { expression: "[[ibmExprType:GoodNews|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
188 | { expression: "[[ibm-expr-type:GoodNews|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
189 | { expression: "[[iet:GoodNews|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
190 | { expression: "[[ibmTransType:Young,ibmTransStrength:80%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
191 | { expression: "[[ibm-trans-type:Young,ibm-trans-strength:80%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
192 | { expression: "[[itt:Young,its:80%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
193 | { expression: "[[ibmTransStrength:80%,ibmTransType:Young|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
194 | { expression: "[[ibm-trans-strength:80%,ibm-trans-type:Young|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
195 | { expression: "[[ibmTransType:Young|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
196 | { expression: "[[ibm-trans-type:Young|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
197 | { expression: "[[itt:Young|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
198 | { expression: "[[ibmTransBreathiness:high,ibmTransPitchRange:wide,ibmTransTimbre:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
199 | { expression: "[[ibm-trans-breathiness:high,ibm-trans-pitch-range:wide,ibm-trans-timbre:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
200 | { expression: "[[itb:high,itp:wide,itm:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
201 | { expression: "[[ibmTransBreathiness:high,ibmTransTimbre:Sunrise,ibmTransPitchRange:wide|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
202 | { expression: "[[ibm-trans-breathiness:high,ibm-trans-timbre:Sunrise,ibm-trans-pitch-range:wide|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
203 | { expression: "[[itb:high,itm:Sunrise,itp:wide|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
204 | { expression: "[[ibmTransPitchRange:wide,ibmTransTimbre:Sunrise,ibmTransBreathiness:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
205 | { expression: "[[itp:wide,itm:Sunrise,itb:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
206 | { expression: "[[ibmTransPitchRange:wide,ibmTransBreathiness:high,ibmTransTimbre:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
207 | { expression: "[[ibm-trans-pitch-range:wide,ibm-trans-breathiness:high,ibm-trans-timbre:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
208 | { expression: "[[itp:wide,itb:high,itm:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
209 | { expression: "[[ibmTransTimbre:Sunrise,ibmTransBreathiness:high,ibmTransPitchRange:wide|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
210 | { expression: "[[ibm-trans-timbre:Sunrise,ibm-trans-breathiness:high,ibm-trans-pitch-range:wide|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
211 | { expression: "[[itm:Sunrise,itp:wide,itb:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
212 | { expression: "[[ibmTransTimbre:Sunrise,ibmTransPitchRange:wide,ibmTransBreathiness:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
213 | { expression: "[[ibm-trans-timbre:Sunrise,ibm-trans-pitch-range:wide,ibm-trans-breathiness:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
214 | { expression: "[[itm:Sunrise,itp:wide,itb:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
215 | { expression: "[[ibmTransBreathiness:high,ibmTransPitchRange:wide|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
216 | { expression: "[[ibm-trans-breathiness:high,ibm-trans-pitch-range:wide|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
217 | { expression: "[[itb:high,itp:wide|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
218 | { expression: "[[ibmTransBreathiness:high,ibmTransTimbre:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
219 | { expression: "[[ibm-trans-breathiness:high,ibm-trans-timbre:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
220 | { expression: "[[itb:high,itm:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
221 | { expression: "[[ibmTransPitchRange:wide,ibmTransTimbre:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
222 | { expression: "[[ibm-trans-pitch-range:wide,ibm-trans-timbre:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
223 | { expression: "[[itp:wide,itm:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
224 | { expression: "[[ibmTransPitchRange:wide,ibmTransBreathiness:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
225 | { expression: "[[ibm-trans-pitch-range:wide,ibm-trans-breathiness:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
226 | { expression: "[[itp:wide,itb:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
227 | { expression: "[[ibmTransTimbre:Sunrise,ibmTransBreathiness:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
228 | { expression: "[[ibm-trans-timbre:Sunrise,ibm-trans-breathiness:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
229 | { expression: "[[itm:Sunrise,itb:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
230 | { expression: "[[ibmTransTimbre:Sunrise,ibmTransPitchRange:wide|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
231 | { expression: "[[ibm-trans-timbre:Sunrise,ibm-trans-pitch-range:wide|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
232 | { expression: "[[itm:Sunrise,itp:wide|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
233 | { expression: "[[ibmTransBreathiness:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
234 | { expression: "[[ibm-trans-breathiness:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
235 | { expression: "[[itb:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
236 | { expression: "[[ibmTransPitchRange:wide|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
237 | { expression: "[[ibm-trans-pitch-range:wide|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
238 | { expression: "[[itp:wide|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
239 | { expression: "[[ibmTransTimbre:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
240 | { expression: "[[ibm-trans-timbre:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
241 | { expression: "[[itm:Sunrise|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL }
242 | ];
243 |
244 | var sad = [
245 | { expression: "[[ibmExprType:unknown|TEXT]]", expected: undertest.SyntaxError },
246 | { expression: "[[ibmTransType:unknown|TEXT]]", expected: undertest.SyntaxError },
247 | { expression: "[[ibmTransStrength:unknown,ibmTransType:Young|TEXT]]", expected: undertest.SyntaxError },
248 | { expression: "[[ibmTransBreathiness:unknown|TEXT]]", expected: undertest.SyntaxError },
249 | { expression: "[[ibmTransPitchRange:unknown|TEXT]]", expected: undertest.SyntaxError },
250 | { expression: "[[ibmTransTimbre:unknown|TEXT]]",expected: undertest.SyntaxError }
251 | ];
252 |
253 | helper.runHappyTests(happy, undertest);
254 | helper.runSadTests(sad, undertest);
255 | });
256 |
257 | describe("Microsoft Cognitive Speech Service", () => {
258 | undertest = require("../src/wiki2ssml");
259 | var happy = [
260 | { expression: "[[mstBackgroundAudio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
261 | { expression: "[[mst-background-audio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
262 | { expression: "[[mba:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
263 | { expression: "[[mstBackgroundAudio:https://example.mp3,mstBackgroundAudioVolume:0]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
264 | { expression: "[[mst-background-audio:https://example.mp3,mstBackgroundAudioVolume:0]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
265 | { expression: "[[mba:https://example.mp3,mbv:0]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
266 | { expression: "[[mba:https://example.mp3,mbv:50]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
267 | { expression: "[[mba:https://example.mp3,mbv:100]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
268 | { expression: "[[mstBackgroundAudioVolume:0,mstBackgroundAudio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
269 | { expression: "[[mst-background-audio-volume:0,mst-background-audio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
270 | { expression: "[[mbv:0,mba:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
271 | { expression: "[[mstBackgroundAudio:https://example.mp3,mstBackgroundAudioFadeIn:0]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
272 | { expression: "[[mst-background-audio:https://example.mp3,mstBackgroundAudioFadeIn:0]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
273 | { expression: "[[mstBackgroundAudio:https://example.mp3,mstBackgroundAudioFadeIn:10000]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
274 | { expression: "[[mst-background-audio:https://example.mp3,mst-background-audio-fade-in:10000]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
275 | { expression: "[[mstBackgroundAudioFadeIn:0,mstBackgroundAudio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
276 | { expression: "[[mst-background-audio-fade-in:0,mst-background-audio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
277 | { expression: "[[mstBackgroundAudioFadeIn:10000,mstBackgroundAudio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
278 | { expression: "[[mst-background-audio-fade-in:10000,mst-background-audio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
279 | { expression: "[[mba:https://example.mp3,mfi:10000]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
280 | { expression: "[[mstBackgroundAudio:https://example.mp3,mstBackgroundAudioFadeOut:0]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
281 | { expression: "[[mst-background-audio:https://example.mp3,mst-background-audio-fade-out:0]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
282 | { expression: "[[mstBackgroundAudio:https://example.mp3,mstBackgroundAudioFadeOut:10000]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
283 | { expression: "[[mst-background-audio:https://example.mp3,mst-background-audio-fade-out:10000]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
284 | { expression: "[[mstBackgroundAudioFadeOut:0,mstBackgroundAudio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
285 | { expression: "[[mst-background-audio-fade-out:0,mst-background-audio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
286 | { expression: "[[mstBackgroundAudioFadeOut:10000,mstBackgroundAudio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
287 | { expression: "[[mst-background-audio-fade-out:10000,mst-background-audio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
288 | { expression: "[[mba:https://example.mp3,mfo:10000]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
289 | { expression: "[[mstBackgroundAudio:https://example.mp3,mstBackgroundAudioFadeIn:10,mstBackgroundAudioFadeOut:20]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
290 | { expression: "[[mst-background-audio:https://example.mp3,mst-background-audio-fade-in:10,mst-background-audio-fade-out:20]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
291 | { expression: "[[mstBackgroundAudio:https://example.mp3,mstBackgroundAudioFadeOut:20,mstBackgroundAudioFadeIn:10]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
292 | { expression: "[[mst-background-audio:https://example.mp3,mst-background-audio-fade-out:20,mst-background-audio-fade-in:10]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
293 | { expression: "[[mstBackgroundAudioFadeIn:10,mstBackgroundAudio:https://example.mp3,mstBackgroundAudioFadeOut:20]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
294 | { expression: "[[mst-background-audio-fade-in:10,mst-background-audio:https://example.mp3,mst-background-audio-fade-out:20]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
295 | { expression: "[[mstBackgroundAudioFadeIn:10,mstBackgroundAudioFadeOut:20,mstBackgroundAudio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
296 | { expression: "[[mst-background-audio-fade-in:10,mst-background-audio-fade-out:20,mst-background-audio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
297 | { expression: "[[mstBackgroundAudioFadeOut:20,mstBackgroundAudioFadeIn:10,mstBackgroundAudio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
298 | { expression: "[[mst-background-audio-fade-out:20,mst-background-audio-fade-in:10,mst-background-audio:https://example.mp3]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
299 | { expression: "[[mstBackgroundAudioFadeOut:20,mstBackgroundAudio:https://example.mp3,mstBackgroundAudioFadeIn:10]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
300 | { expression: "[[mst-background-audio-fade-out:20,mst-background-audio:https://example.mp3,mst-background-audio-fade-in:10]]", expected: helper.MSTTS_EXTENDED_HEAD + "" + helper.TAIL },
301 | { expression: "[[mst-expr-style:cheerful|TEXT]]", expected: helper.MSTTS_EXTENDED_HEAD + "TEXT " + helper.TAIL },
302 | { expression: "[[mst-expr-style:cheerful,mst-expr-degree:0.5|TEXT]]", expected: helper.MSTTS_EXTENDED_HEAD + "TEXT " + helper.TAIL },
303 | { expression: "[[mst-expr-degree:0.5,mst-expr-style:cheerful|TEXT]]", expected: helper.MSTTS_EXTENDED_HEAD + "TEXT " + helper.TAIL }
304 | ];
305 |
306 | var sad = [
307 | { expression: "[[mstBackgroundAudio:https://example.mp3,mstBackgroundAudioVolume:101]]", expected: undertest.SyntaxError },
308 | { expression: "[[mstBackgroundAudio:https://example.mp3,mstBackgroundAudioVolume:-1]]", expected: undertest.SyntaxError },
309 | { expression: "[[mstBackgroundAudio:https://example.mp3,mstBackgroundAudioFadeIn:10001]]", expected: undertest.SyntaxError },
310 | { expression: "[[mstBackgroundAudio:https://example.mp3,mstBackgroundAudioFadeIn:-1]]", expected: undertest.SyntaxError },
311 | { expression: "[[mstBackgroundAudio:https://example.mp3,mstBackgroundAudioFadeOut:10001]]", expected: undertest.SyntaxError },
312 | { expression: "[[mstBackgroundAudio:https://example.mp3,mstBackgroundAudioFadeOut:-1]]", expected: undertest.SyntaxError }
313 | ];
314 |
315 | helper.runHappyTests(happy, undertest);
316 | helper.runSadTests(sad, undertest);
317 | });
318 | });
319 |
--------------------------------------------------------------------------------
/test/wiki2ssml-test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var expect = require("chai").expect;
4 | var xml2js = require("xml2js");
5 | var helper = require("./helper");
6 |
7 | describe("Test wiki2ssml", () => {
8 |
9 | var undertest;
10 |
11 | describe("Test grammar", () => {
12 | it("should have no grammar errors", () => {
13 | try {
14 | undertest = require("../src/wiki2ssml");
15 | } catch (e) {
16 | expect.fail();
17 | }
18 | });
19 | });
20 |
21 | describe("Test parser", () => {
22 | describe("Speed, pitch and volume", () => {
23 | undertest = require("../src/wiki2ssml");
24 | var happy = [
25 | { expression: "[[speed:x-slow|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
26 | { expression: "[[speed:slow|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
27 | { expression: "[[speed:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
28 | { expression: "[[speed:fast|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
29 | { expression: "[[speed:x-fast|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
30 | { expression: "[[speed:default|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
31 | { expression: "[[speed:5%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
32 | { expression: "[[spe:x-slow|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
33 | { expression: "[[spe:slow|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
34 | { expression: "[[spe:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
35 | { expression: "[[spe:fast|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
36 | { expression: "[[spe:x-fast|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
37 | { expression: "[[spe:default|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
38 | { expression: "[[spe:5%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
39 | { expression: "[[pitch:x-low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
40 | { expression: "[[pitch:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
41 | { expression: "[[pitch:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
42 | { expression: "[[pitch:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
43 | { expression: "[[pitch:x-high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
44 | { expression: "[[pitch:default|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
45 | { expression: "[[pitch:5%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
46 | { expression: "[[pitch:+5%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
47 | { expression: "[[pitch:-5%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
48 | { expression: "[[pit:x-low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
49 | { expression: "[[pit:low|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
50 | { expression: "[[pit:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
51 | { expression: "[[pit:high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
52 | { expression: "[[pit:x-high|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
53 | { expression: "[[pit:default|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
54 | { expression: "[[pit:5%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
55 | { expression: "[[pit:+5%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
56 | { expression: "[[pit:-5%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
57 | { expression: "[[pitch:+5Hz|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
58 | { expression: "[[pit:+5Hz|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
59 | { expression: "[[pitch:+12st|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
60 | { expression: "[[pit:+12st|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
61 | { expression: "[[volume:silent|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
62 | { expression: "[[volume:x-soft|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
63 | { expression: "[[volume:soft|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
64 | { expression: "[[volume:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
65 | { expression: "[[volume:loud|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
66 | { expression: "[[volume:x-loud|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
67 | { expression: "[[volume:+6dB|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
68 | { expression: "[[volume:-6dB|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
69 | { expression: "[[vol:silent|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
70 | { expression: "[[vol:x-soft|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
71 | { expression: "[[vol:soft|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
72 | { expression: "[[vol:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
73 | { expression: "[[vol:loud|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
74 | { expression: "[[vol:x-loud|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
75 | { expression: "[[vol:default|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
76 | { expression: "[[vol:+6dB|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
77 | { expression: "[[vol:-6dB|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
78 | { expression: "[[volume:medium,speed:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
79 | { expression: "[[vol:+6dB,spe:5%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
80 | { expression: "[[speed:medium,volume:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
81 | { expression: "[[spe:5%,vol:+6dB|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
82 | { expression: "[[volume:medium,pitch:+5%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
83 | { expression: "[[pit:+5%,vol:+6dB|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
84 | { expression: "[[spe:medium,pit:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
85 | { expression: "[[pitch:medium,speed:5%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
86 | { expression: "[[speed:medium,volume:+6dB,pitch:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
87 | { expression: "[[volume:medium,speed:5%,pitch:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
88 | { expression: "[[volume:+6dB,pitch:medium,speed:medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
89 | { expression: "[[pitch:medium,volume:medium,speed:5%|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
90 | { expression: "[[pitch:medium,speed:medium,volume:+6dB|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
91 | { expression: "no markups", expected: helper.HEAD + "no markups" + helper.TAIL }
92 | ];
93 |
94 | var sad = [
95 | { expression: "[[speed:unknown|TEXT]]", expected: undertest.SyntaxError },
96 | { expression: "[[pitch:unknown|TEXT]]", expected: undertest.SyntaxError },
97 | { expression: "[[volume:unknown|TEXT]]", expected: undertest.SyntaxError }
98 | ];
99 |
100 | helper.runHappyTests(happy, undertest);
101 | helper.runSadTests(sad, undertest);
102 | });
103 |
104 | describe("Time containers", () => {
105 | undertest = require("../src/wiki2ssml");
106 | var happy = [
107 | { expression: "*[[pitch:medium,speed:medium,volume:+6dB|TEXT]]*", expected: helper.HEAD + "TEXT " + helper.TAIL },
108 | { expression: "#[[pitch:medium,speed:medium,volume:+6dB|TEXT]][[pitch:medium,speed:medium,volume:+6dB|TEXT]]#", expected: helper.HEAD + "TEXT TEXT " + helper.TAIL }
109 | ];
110 |
111 | var sad = [
112 | { expression: "*[[pitch:medium,speed:medium,volume:+6dB|TEXT]]", expected: undertest.SyntaxError },
113 | { expression: "#[[pitch:medium,speed:medium,volume:+6dB|TEXT]]", expected: undertest.SyntaxError },
114 | { expression: "*[[pitch:medium,speed:medium,volume:+6dB|TEXT]]#", expected: undertest.SyntaxError },
115 | { expression: "#[[pitch:medium,speed:medium,volume:+6dB|TEXT]]*", expected: undertest.SyntaxError }
116 | ];
117 |
118 | helper.runHappyTests(happy, undertest);
119 | helper.runSadTests(sad, undertest);
120 | });
121 |
122 | describe("Emphasis level", () => {
123 | undertest = require("../src/wiki2ssml");
124 | var happy = [
125 | { expression: "[[emphasis:strong|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
126 | { expression: "[[emphasis:moderate|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
127 | { expression: "[[emphasis:none|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
128 | { expression: "[[emphasis:reduced|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
129 | { expression: "[[emp:strong|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
130 | { expression: "[[emp:moderate|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
131 | { expression: "[[emp:none|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
132 | { expression: "[[emp:reduced|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
133 | ];
134 |
135 | var sad = [
136 | { expression: "[[emphasis:unknown|TEXT]]", expected: undertest.SyntaxError }
137 | ];
138 |
139 | helper.runHappyTests(happy, undertest);
140 | helper.runSadTests(sad, undertest);
141 | });
142 |
143 | describe("Silence with duration", () => {
144 | undertest = require("../src/wiki2ssml");
145 | var happy = [
146 | { expression: "[[strength:none]]", expected: helper.HEAD + "" + helper.TAIL },
147 | { expression: "[[strength:x-weak]]", expected: helper.HEAD + "" + helper.TAIL },
148 | { expression: "[[strength:weak]]", expected: helper.HEAD + "" + helper.TAIL },
149 | { expression: "[[strength:medium]]", expected: helper.HEAD + "" + helper.TAIL },
150 | { expression: "[[strength:strong]]", expected: helper.HEAD + "" + helper.TAIL },
151 | { expression: "[[strength:x-strong]]", expected: helper.HEAD + "" + helper.TAIL },
152 | { expression: "[[str:none]]", expected: helper.HEAD + "" + helper.TAIL },
153 | { expression: "[[str:x-weak]]", expected: helper.HEAD + "" + helper.TAIL },
154 | { expression: "[[str:weak]]", expected: helper.HEAD + "" + helper.TAIL },
155 | { expression: "[[str:medium]]", expected: helper.HEAD + "" + helper.TAIL },
156 | { expression: "[[str:strong]]", expected: helper.HEAD + "" + helper.TAIL },
157 | { expression: "[[str:x-strong]]", expected: helper.HEAD + "" + helper.TAIL },
158 | { expression: "[[silence:100s]]", expected: helper.HEAD + "" + helper.TAIL },
159 | { expression: "[[silence:100ms]]", expected: helper.HEAD + "" + helper.TAIL },
160 | { expression: "[[sil:100s]]", expected: helper.HEAD + "" + helper.TAIL },
161 | { expression: "[[sil:100ms]]", expected: helper.HEAD + "" + helper.TAIL },
162 | { expression: "[[silence:150ms,strength:medium]]", expected: helper.HEAD + "" + helper.TAIL },
163 | { expression: "[[strength:medium,silence:0.5s]]", expected: helper.HEAD + "" + helper.TAIL }
164 | ];
165 |
166 | var sad = [
167 | { expression: "[[silence:unknown]]", expected: undertest.SyntaxError },
168 | { expression: "[[strength:unknown]]", expected: undertest.SyntaxError }
169 | ];
170 |
171 | helper.runHappyTests(happy, undertest);
172 | helper.runSadTests(sad, undertest);
173 | });
174 |
175 | describe("Substitution", () => {
176 | undertest = require("../src/wiki2ssml");
177 | var happy = [
178 | { expression: "[[substitute:red color|red colour]]", expected: helper.HEAD + "red colour " + helper.TAIL },
179 | { expression: "[[substitute:red color|]]", expected: helper.HEAD + " " + helper.TAIL },
180 | { expression: "[[sub:red color|red colour]]", expected: helper.HEAD + "red colour " + helper.TAIL },
181 | { expression: "[[sub:red color|]]", expected: helper.HEAD + " " + helper.TAIL }
182 | ];
183 |
184 | helper.runHappyTests(happy, undertest);
185 | });
186 |
187 | describe("Embedded audio", () => {
188 | undertest = require("../src/wiki2ssml");
189 | var happy = [
190 | { expression: "[[audio:https://example.mp3]]", expected: helper.HEAD + "" + helper.TAIL },
191 | { expression: "[[aud:https://example.mp3]]", expected: helper.HEAD + "" + helper.TAIL },
192 | { expression: "[[audio:https://example.mp3,level:+6dB]]", expected: helper.HEAD + "" + helper.TAIL },
193 | { expression: "[[aud:https://example.mp3,lev:+6dB]]", expected: helper.HEAD + "" + helper.TAIL },
194 | { expression: "[[audio:https://example.mp3,begin:0.5s,end:5s]]", expected: helper.HEAD + "" + helper.TAIL },
195 | { expression: "[[aud:https://example.mp3,end:5s,begin:0.5s]]", expected: helper.HEAD + "" + helper.TAIL },
196 | { expression: "[[audio:https://example.mp3,begin:0.5s,end:5s,count:3]]", expected: helper.HEAD + "" + helper.TAIL },
197 | { expression: "[[aud:https://example.mp3,count:3,begin:0.5s,end:5s]]", expected: helper.HEAD + "" + helper.TAIL },
198 | { expression: "[[audio:https://example.mp3,begin:0.5s,end:5s,speed:100%]]", expected: helper.HEAD + "" + helper.TAIL },
199 | { expression: "[[aud:https://example.mp3,speed:100%,begin:0.5s,end:5s]]", expected: helper.HEAD + "" + helper.TAIL },
200 | { expression: "[[audio:https://example.mp3,duration:5s,count:3]]", expected: helper.HEAD + "" + helper.TAIL },
201 | { expression: "[[aud:https://example.mp3,count:3,duration:5s]]", expected: helper.HEAD + "" + helper.TAIL }
202 | ];
203 |
204 | helper.runHappyTests(happy, undertest);
205 | });
206 |
207 | describe("Language code", () => {
208 | undertest = require("../src/wiki2ssml");
209 | var happy = [
210 | { expression: "[[lang:en-GB|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
211 | { expression: "[[lan:en-GB|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL }
212 | ];
213 |
214 | helper.runHappyTests(happy, undertest);
215 | });
216 |
217 | describe("Paragraph and senctence", () => {
218 | undertest = require("../src/wiki2ssml");
219 | var happy = [
220 | { expression: "[[paragraph|TEXT]]", expected: helper.HEAD + "TEXT
" + helper.TAIL },
221 | { expression: "[[par|TEXT]]", expected: helper.HEAD + "TEXT
" + helper.TAIL },
222 | { expression: "[[sentence|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
223 | { expression: "[[sen|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL }
224 | ];
225 |
226 | helper.runHappyTests(happy, undertest);
227 | });
228 |
229 | describe("Phoneme with alphabet and pronunciation", () => {
230 | undertest = require("../src/wiki2ssml");
231 | var happy = [
232 | { expression: "[[pronunciation:təˈmɑːtəʊ|tomato]]", expected: helper.HEAD + "tomato " + helper.TAIL },
233 | { expression: "[[pro:təˈmɑːtəʊ|tomato]]", expected: helper.HEAD + "tomato " + helper.TAIL },
234 | { expression: "[[alphabet:ipa,pronunciation:təˈmɑːtəʊ|tomato]]", expected: helper.HEAD + "tomato " + helper.TAIL },
235 | { expression: "[[alp:ipa,pronunciation:təˈmɑːtəʊ|tomato]]", expected: helper.HEAD + "tomato " + helper.TAIL },
236 | { expression: "[[pronunciation:təˈmɑːtəʊ,alphabet:ipa|tomato]]", expected: helper.HEAD + "tomato " + helper.TAIL }
237 | ];
238 |
239 | helper.runHappyTests(happy, undertest);
240 | });
241 |
242 | describe("Type for interpretation", () => {
243 | undertest = require("../src/wiki2ssml");
244 | var happy = [
245 | { expression: "[[type:cardinal|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
246 | { expression: "[[type:number|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
247 | { expression: "[[type:ordinal|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
248 | { expression: "[[type:characters|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
249 | { expression: "[[type:digits|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
250 | { expression: "[[type:fraction|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
251 | { expression: "[[type:expletive|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
252 | { expression: "[[type:bleep|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
253 | { expression: "[[type:interjection|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
254 | { expression: "[[type:unit|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
255 | { expression: "[[type:verbatim|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
256 | { expression: "[[type:spell-out|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
257 | { expression: "[[type:date|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
258 | { expression: "[[type:time|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
259 | { expression: "[[type:telephone|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
260 | { expression: "[[type:address|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
261 | { expression: "[[typ:cardinal|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
262 | { expression: "[[typ:number|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
263 | { expression: "[[typ:ordinal|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
264 | { expression: "[[typ:characters|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
265 | { expression: "[[typ:digits|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
266 | { expression: "[[typ:fraction|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
267 | { expression: "[[typ:expletive|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
268 | { expression: "[[typ:bleep|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
269 | { expression: "[[typ:interjection|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
270 | { expression: "[[typ:unit|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
271 | { expression: "[[typ:verbatim|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
272 | { expression: "[[typ:spell-out|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
273 | { expression: "[[typ:date|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
274 | { expression: "[[typ:time|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
275 | { expression: "[[typ:telephone|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
276 | { expression: "[[typ:address|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
277 | { expression: "[[type:time,format:hms24|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
278 | { expression: "[[type:time,format:hms12|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
279 | { expression: "[[type:date,format:mdy|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
280 | { expression: "[[type:date,format:dmy|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
281 | { expression: "[[type:date,format:ymd|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
282 | { expression: "[[type:date,format:md|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
283 | { expression: "[[type:date,format:dm|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
284 | { expression: "[[type:date,format:ym|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
285 | { expression: "[[type:date,format:my|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
286 | { expression: "[[type:date,format:d|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
287 | { expression: "[[type:date,format:m|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
288 | { expression: "[[type:date,format:y|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
289 | { expression: "[[type:time,for:hms24|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
290 | { expression: "[[type:time,for:hms12|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
291 | { expression: "[[type:date,for:mdy|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
292 | { expression: "[[type:date,for:dmy|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
293 | { expression: "[[type:date,for:ymd|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
294 | { expression: "[[type:date,for:md|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
295 | { expression: "[[type:date,for:dm|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
296 | { expression: "[[type:date,for:ym|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
297 | { expression: "[[type:date,for:my|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
298 | { expression: "[[type:date,for:d|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
299 | { expression: "[[type:date,for:m|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
300 | { expression: "[[type:date,for:y|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
301 | { expression: "[[format:hms24,type:time|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
302 | { expression: "[[format:hms12,type:time|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
303 | { expression: "[[format:mdy,type:date|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
304 | { expression: "[[format:dmy,type:date|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
305 | { expression: "[[format:ymd,type:date|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
306 | { expression: "[[format:md,type:date|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
307 | { expression: "[[format:dm,type:date|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
308 | { expression: "[[format:ym,type:date|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
309 | { expression: "[[format:my,type:date|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
310 | { expression: "[[format:d,type:date|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
311 | { expression: "[[format:m,type:date|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
312 | { expression: "[[format:y,type:date|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
313 | { expression: "[[type:time,format:hms24,detail:1|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
314 | { expression: "[[type:time,format:hms24,det:1|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
315 | { expression: "[[type:time,detail:1,format:hms24|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
316 | { expression: "[[format:hms24,type:time,detail:1|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
317 | { expression: "[[format:hms24,detail:1,type:time|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
318 | { expression: "[[detail:1,type:time,format:hms24|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
319 | { expression: "[[detail:1,format:hms24,type:time|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
320 | { expression: "[[detail:punctuation,format:hms24,type:time|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
321 | { expression: "[[type:letters|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
322 | { expression: "[[type:vxml:boolean|TEXT]]", expected: helper.VXML_EXTENDED_HEAD + "TEXT " + helper.TAIL },
323 | { expression: "[[type:vxml:currency|TEXT]]", expected: helper.VXML_EXTENDED_HEAD + "TEXT " + helper.TAIL },
324 | { expression: "[[type:vxml:date|TEXT]]", expected: helper.VXML_EXTENDED_HEAD + "TEXT " + helper.TAIL },
325 | { expression: "[[type:vxml:digits|TEXT]]", expected: helper.VXML_EXTENDED_HEAD + "TEXT " + helper.TAIL },
326 | { expression: "[[type:vxml:phone|TEXT]]", expected: helper.VXML_EXTENDED_HEAD + "TEXT " + helper.TAIL },
327 | { expression: "[[format:md,type:vxml:date|TEXT]]", expected: helper.VXML_EXTENDED_HEAD + "TEXT " + helper.TAIL }
328 | ];
329 |
330 | var sad = [
331 | { expression: "[[type:unknown|TEXT]]", expected: undertest.SyntaxError },
332 | { expression: "[[type:date,format:unknown|TEXT]]", expected: undertest.SyntaxError },
333 | { expression: "[[type:time,format:hms24,detail:_|TEXT]]", expected: undertest.SyntaxError }
334 | ];
335 |
336 | helper.runHappyTests(happy, undertest);
337 | helper.runSadTests(sad, undertest);
338 | });
339 |
340 | describe("Voice name", () => {
341 | undertest = require("../src/wiki2ssml");
342 | var happy = [
343 | { expression: "[[voice:NAME|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
344 | { expression: "[[voi:NAME|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL }
345 | ];
346 |
347 | helper.runHappyTests(happy, undertest);
348 | });
349 |
350 | describe("Part of Speech", () => {
351 | undertest = require("../src/wiki2ssml");
352 | var happy = [
353 | { expression: "[[pos:VB|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL }
354 | ];
355 |
356 | helper.runHappyTests(happy, undertest);
357 | });
358 |
359 | describe("Mark with name", () => {
360 | undertest = require("../src/wiki2ssml");
361 | var happy = [
362 | { expression: "[[mark:NAME]]", expected: helper.HEAD + "" + helper.TAIL },
363 | { expression: "[[mar:NAME]]", expected: helper.HEAD + "" + helper.TAIL }
364 | ];
365 |
366 | helper.runHappyTests(happy, undertest);
367 | });
368 |
369 | describe("Default speaking", () => {
370 | undertest = require("../src/wiki2ssml");
371 | var happy = [
372 | { expression: "This is a test without markups", expected: helper.HEAD + "This is a test without markups" + helper.TAIL }
373 | ];
374 |
375 | helper.runHappyTests(happy, undertest);
376 | });
377 |
378 | describe("Combined markups", () => {
379 | undertest = require("../src/wiki2ssml");
380 | var happy = [
381 | { expression: "start [[volume:medium|TEXT]] middle [[silence:0.5s]] end", expected: helper.HEAD + "start TEXT middle end" + helper.TAIL },
382 | { expression: "[[volume:medium|TEXT]] middle [[silence:0.5s]] end", expected: helper.HEAD + "TEXT middle end" + helper.TAIL },
383 | { expression: "start [[volume:medium|TEXT]] middle [[silence:0.5s]]", expected: helper.HEAD + "start TEXT middle " + helper.TAIL },
384 | { expression: "[[volume:medium|TEXT]] middle [[silence:0.5s]]", expected: helper.HEAD + "TEXT middle " + helper.TAIL },
385 | { expression: "TEXT[[voice:NAME|TEXT[[lang:en-GB|TEXT]]TEXT]]TEXT", expected: helper.HEAD + "TEXTTEXTTEXT TEXT TEXT" + helper.TAIL },
386 | { expression: "[[voice:NAME|TEXT[[lang:en-GB|TEXT]]TEXT]]TEXT", expected: helper.HEAD + "TEXTTEXT TEXT TEXT" + helper.TAIL },
387 | { expression: "TEXT[[voice:NAME|TEXT[[lang:en-GB|TEXT]]TEXT]]", expected: helper.HEAD + "TEXTTEXTTEXT TEXT " + helper.TAIL },
388 | { expression: "[[voice:NAME|TEXT[[lang:en-GB|TEXT]]TEXT]]", expected: helper.HEAD + "TEXTTEXT TEXT " + helper.TAIL },
389 | { expression: "[[voice:NAME|[[lang:en-GB|TEXT]]TEXT]]", expected: helper.HEAD + "TEXT TEXT " + helper.TAIL },
390 | { expression: "[[voice:NAME|TEXT[[lang:en-GB|TEXT]]]]", expected: helper.HEAD + "TEXTTEXT " + helper.TAIL },
391 | { expression: "[[speed:medium,volume:+6dB,pitch:medium|TEXT[[type:time,format:hms24,detail:1|TEXT]]]]", expected: helper.HEAD + "TEXTTEXT " + helper.TAIL }
392 | ];
393 |
394 | var sad = [
395 | { expression: "start [volume:medium|TEXT]] middle [[silence:0.5s]] end", expected: undertest.SyntaxError },
396 | { expression: "[[volume:medium|TEXT] middle [[silence:0.5s]] end", expected: undertest.SyntaxError },
397 | { expression: "start [[volume:medium|TEXT]] middle [silence:0.5s]]", expected: undertest.SyntaxError },
398 | { expression: "[[volume:medium|TEXT]] middle [[silence:0.5s]", expected: undertest.SyntaxError },
399 | { expression: "TEXT[voice:NAME|TEXT[[lang:en-GB|TEXT]]TEXT]]TEXT", expected: undertest.SyntaxError },
400 | { expression: "[[voice:NAME|TEXT[lang:en-GB|TEXT]]TEXT]]TEXT", expected: undertest.SyntaxError },
401 | { expression: "TEXT[[voice:NAME|TEXT[[lang:en-GB|TEXT]TEXT]]", expected: undertest.SyntaxError },
402 | { expression: "[[voice:NAME|TEXT[[lang:en-GB|TEXT]]TEXT]", expected: undertest.SyntaxError }
403 | ];
404 |
405 | helper.runHappyTests(happy, undertest);
406 | helper.runSadTests(sad, undertest);
407 | });
408 |
409 | describe("Meta content", () => {
410 | undertest = require("../src/wiki2ssml");
411 | var happy = [
412 | { expression: "[[seeAlso:http://example.com/metadata.xml]]", expected: helper.HEAD + " " + helper.TAIL },
413 | { expression: "[[see-also:http://example.com/metadata.xml]]", expected: helper.HEAD + " " + helper.TAIL },
414 | { expression: "[[see:http://example.com/metadata.xml]]", expected: helper.HEAD + " " + helper.TAIL },
415 | { expression: "[[cacheControl:no-cache]]", expected: helper.HEAD + " " + helper.TAIL },
416 | { expression: "[[cache-control:no-cache]]", expected: helper.HEAD + " " + helper.TAIL },
417 | { expression: "[[cac:no-cache]]", expected: helper.HEAD + " " + helper.TAIL }
418 | ];
419 |
420 | helper.runHappyTests(happy, undertest);
421 | });
422 |
423 | describe("Lexicon", () => {
424 | undertest = require("../src/wiki2ssml");
425 | var happy = [
426 | { expression: "[[lexicon:http://example.com/lexicon.pls]]", expected: helper.HEAD + "" + helper.TAIL },
427 | { expression: "[[lex:http://example.com/lexicon.pls]]", expected: helper.HEAD + "" + helper.TAIL },
428 | { expression: "[[lexicon:http://example.com/lexicon.pls,type:media-type]]", expected: helper.HEAD + "" + helper.TAIL },
429 | { expression: "[[typ:media-type,lex:http://example.com/lexicon.pls]]", expected: helper.HEAD + "" + helper.TAIL }
430 | ];
431 |
432 | helper.runHappyTests(happy, undertest);
433 | });
434 |
435 | it("should ignore whitespaces", () => {
436 | undertest = require("../src/wiki2ssml");
437 | var happy = [
438 | { expression: "[[ speed: medium ,volume: +6dB,pitch: medium|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
439 | { expression: "[[emphasis :none|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
440 | { expression: "[[strength: medium, silence : 0.5s]]", expected: helper.HEAD + "" + helper.TAIL },
441 | { expression: "[[ substitute: red color | red colour ]]", expected: helper.HEAD + " red colour " + helper.TAIL },
442 | { expression: "[[audio :https://example.mp3]]", expected: helper.HEAD + "" + helper.TAIL },
443 | { expression: "[[lang :en-GB|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
444 | { expression: "[[paragraph |TEXT]]", expected: helper.HEAD + "TEXT
" + helper.TAIL },
445 | { expression: "[[ sentence |TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
446 | { expression: "[[pronunciation :təˈmɑːtəʊ, alphabet:ipa|tomato]]", expected: helper.HEAD + "tomato " + helper.TAIL },
447 | { expression: "[[ type:time , detail:1, format:hms24 |TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
448 | { expression: "[[voice: NAME|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL },
449 | { expression: "[[pos: VB|TEXT]]", expected: helper.HEAD + "TEXT " + helper.TAIL }
450 | ];
451 |
452 | happy.forEach((test) => {
453 | var parsed = undertest.parseToSsml(test.expression, "en-GB", {version: "1.0"});
454 | expect(parsed).to.be.have.string(" { expect(err).to.be.null; });
457 | });
458 | });
459 |
460 | it("should escape control characters", () => {
461 | undertest = require("../src/wiki2ssml");
462 | var parsed = undertest.parseToSsml("[[volume:+6dB|\"a\" + 'b' & c <> d]]", "en-GB", {version: "1.0"});
463 | expect(parsed).to.be.a("string");
464 | expect(parsed).to.equal(helper.HEAD + ""a" + 'b' & c <> d " + helper.TAIL);
465 | });
466 |
467 | it("should output the original input which dose not have markups in SSML", () => {
468 | undertest = require("../src/wiki2ssml");
469 | var textWithoutMarkup = "This is a test without markups";
470 | var parsed = undertest.parseToSsml(textWithoutMarkup, "en-GB", {version: "1.0"});
471 | expect(parsed).to.be.a("string");
472 | expect(parsed).to.equal(helper.HEAD + textWithoutMarkup + helper.TAIL);
473 | });
474 |
475 | it("should use a specific SSML version parsed in", () => {
476 | undertest = require("../src/wiki2ssml");
477 | var parsed = undertest.parseToSsml("[[volume:+6dB|TEXT]]", "en-GB", {version: "1.0"});
478 | expect(parsed).to.be.a("string");
479 | expect(parsed).to.have.string("version=\"1.0\"");
480 | });
481 |
482 | it("should prettify SSML when configured", () => {
483 | undertest = require("../src/wiki2ssml");
484 | var parsed = undertest.parseToSsml("[[volume:+6dB|TEXT]]", "en-GB", {version: "1.0", pretty: true});
485 | var expected = ["",
486 | "",
487 | "",
488 | " TEXT ",
489 | " "].join("\n");
490 | expect(parsed).to.be.a("string");
491 | expect(parsed).to.equal(expected);
492 | });
493 |
494 | it("should use SSML 1.1 by default", () => {
495 | undertest = require("../src/wiki2ssml");
496 | var parsed = undertest.parseToSsml("[[volume:+6dB|TEXT]]", "en-GB", {pretty: true});
497 | var expected = ["",
498 | "",
499 | " TEXT ",
500 | " "].join("\n");
501 | expect(parsed).to.be.a("string");
502 | expect(parsed).to.equal(expected);
503 | });
504 |
505 | it("should use the customised encoding", () => {
506 | undertest = require("../src/wiki2ssml");
507 | var parsed = undertest.parseToSsml("[[volume:+6dB|TEXT]]", "en-GB", {pretty: true, encoding: "UTF-16"});
508 | var expected = ["",
509 | "",
510 | " TEXT ",
511 | " "].join("\n");
512 | expect(parsed).to.be.a("string");
513 | expect(parsed).to.equal(expected);
514 | });
515 |
516 | it("should detect and validate markups", () => {
517 | undertest = require("../src/wiki2ssml");
518 | expect(undertest.hasValidMarkups("[[volume:medium|TEXT]] and [[silence:0.5s]] and [[substitute:substitute|original]] are markups")).to.be.true;
519 | expect(undertest.hasValidMarkups("This is a test without valid [[markups]]")).to.be.false;
520 | expect(undertest.hasValidMarkups("This is a test with no markup")).to.be.false;
521 | });
522 |
523 | it("should strip markups and output plain text", () => {
524 | undertest = require("../src/wiki2ssml");
525 | var parsed = undertest.parseToPlainText("[[volume:medium|TEXT]] and [[silence:0.5s]] and [[substitute:substitute|original]] are present");
526 | expect(parsed).to.be.a("string");
527 | expect(parsed).to.equal("TEXT and and original are present");
528 | });
529 |
530 | describe("Errors", () => {
531 | it("should throw SyntaxError on incorrect grammar", () => {
532 | undertest = require("../src/wiki2ssml");
533 | try {
534 | undertest.reloadGrammar("incorrect");
535 | expect.fail();
536 | } catch (e) {
537 | expect(e instanceof undertest.SyntaxError).to.be.true;
538 | expect(e.message).to.have.string("Expected");
539 | }
540 | });
541 |
542 | describe("should throw ArgumentError on", () => {
543 | [
544 | { input: null, expected: undertest.ArgumentError },
545 | { input: undefined, expected: undertest.ArgumentError },
546 | { input: "", expected: undertest.ArgumentError }
547 | ].forEach((test) => {
548 | it((test.input == "" ? "empty" : test.input) + " input", () => {
549 | try {
550 | undertest.parseToSsml(test.input, "en-GB", {version: "1.0"});
551 | expect.fail();
552 | } catch (e) {
553 | expect(e instanceof test.expected).to.be.true;
554 | expect(e.message).to.equal("Input is missing when calling parseToSsml");
555 | }
556 | });
557 | });
558 | });
559 |
560 | it("should throw ArgumentError on null input", () => {
561 | undertest = require("../src/wiki2ssml");
562 | try {
563 | undertest.parseToSsml(null, "en-GB", {version: "1.0"});
564 | expect.fail();
565 | } catch (e) {
566 | expect(e instanceof undertest.ArgumentError).to.be.true;
567 | expect(e.message).to.equal("Input is missing when calling parseToSsml");
568 | }
569 | });
570 |
571 | it("should throw ArgumentError on undefined input", () => {
572 | undertest = require("../src/wiki2ssml");
573 | try {
574 | undertest.parseToSsml(undefined, "en-GB", {version: "1.0"});
575 | expect.fail();
576 | } catch (e) {
577 | expect(e instanceof undertest.ArgumentError).to.be.true;
578 | expect(e.message).to.equal("Input is missing when calling parseToSsml");
579 | }
580 | });
581 |
582 | it("should throw ArgumentError on empty input", () => {
583 | undertest = require("../src/wiki2ssml");
584 | try {
585 | undertest.parseToSsml("", "en-GB", {version: "1.0"});
586 | expect.fail();
587 | } catch (e) {
588 | expect(e instanceof undertest.ArgumentError).to.be.true;
589 | expect(e.message).to.equal("Input is missing when calling parseToSsml");
590 | }
591 | });
592 |
593 | it("should throw ArgumentError on missing language code", () => {
594 | undertest = require("../src/wiki2ssml");
595 | try {
596 | undertest.parseToSsml("[[volume:+6dB|TEXT]]");
597 | expect.fail();
598 | } catch (e) {
599 | expect(e instanceof undertest.ArgumentError).to.be.true;
600 | expect(e.message).to.equal("Language code is missing when calling parseToSsml");
601 | }
602 | });
603 | });
604 | });
605 | });
--------------------------------------------------------------------------------