Socket
Socket
Sign inDemoInstall

wiki2ssml

Package Overview
Dependencies
2
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.12 to 0.2.13

2

package.json
{
"name": "wiki2ssml",
"version": "0.2.12",
"version": "0.2.13",
"description": "Wiki2SSML provides the WikiVoice markup language used for fine-tuning synthesised voice.",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -88,2 +88,3 @@ [![Build Status](https://travis-ci.com/baxtree/wiki2ssml.svg?branch=master)](https://travis-ci.com/baxtree/wiki2ssml) ![Codecov](https://img.shields.io/codecov/c/github/baxtree/wiki2ssml) ![Node](https://img.shields.io/static/v1?label=node.js&message=≥6.4.0&color=green) [![GitHub license](https://img.shields.io/github/license/baxtree/wiki2ssml)](https://github.com/baxtree/wiki2ssml/blob/master/LICENSE)

- pretty `<boolean>` (default: false)
- encoding `<string>` (default: "UTF-8")

@@ -90,0 +91,0 @@ # Example

@@ -19,4 +19,6 @@ "use strict";

var _getSsmlHead = (language, version) => {
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><speak version=\"" + version + "\" xmlns=\"http://www.w3.org/2001/10/synthesis\" " +
var _getSsmlHead = (language, version, encoding) => {
return "<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>" +
(version === "1.0" ? "<!DOCTYPE speak PUBLIC \"-//W3C//DTD SYNTHESIS 1.0//EN\" \"http://www.w3.org/TR/speech-synthesis/synthesis.dtd\">" : "") +
"<speak version=\"" + version + "\" xmlns=\"http://www.w3.org/2001/10/synthesis\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +

@@ -39,3 +41,3 @@ "xsi:schemaLocation=\"http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd\" " +

}
var ssml = _getSsmlHead(language, options.version).replace("{{EXTNS_PLACEHOLDER}}", ext_ns) + ssmlBody + _getSsmlTail();
var ssml = _getSsmlHead(language, options.version, options.encoding).replace("{{EXTNS_PLACEHOLDER}}", ext_ns) + ssmlBody + _getSsmlTail();
if (options.pretty) {

@@ -61,2 +63,5 @@ return prettifyXml(ssml, {indent: 2, newline: "\n"});

}
if (typeof(options.encoding) === "undefined") {
options.encoding = "UTF-8";
}
try {

@@ -63,0 +68,0 @@ var parsed = _parser.parse(input);

@@ -8,9 +8,13 @@ "use strict";

const _HEAD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><speak version=\"1.1\" xmlns=\"http://www.w3.org/2001/10/synthesis\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xsi:schemaLocation=\"http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd\" " +
"xml:lang=\"en-GB\">";
const _EXTENDED_HEAD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><speak version=\"1.1\" xmlns=\"http://www.w3.org/2001/10/synthesis\" " +
const _HEAD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<!DOCTYPE speak PUBLIC \"-//W3C//DTD SYNTHESIS 1.0//EN\" \"http://www.w3.org/TR/speech-synthesis/synthesis.dtd\">" +
"<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xsi:schemaLocation=\"http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd\" " +
"xml:lang=\"en-GB\">";
const _EXTENDED_HEAD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<!DOCTYPE speak PUBLIC \"-//W3C//DTD SYNTHESIS 1.0//EN\" \"http://www.w3.org/TR/speech-synthesis/synthesis.dtd\">" +
"<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xsi:schemaLocation=\"http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd\" " +
"xmlns:mstts=\"http://www.w3.org/2001/mstts\" " +

@@ -23,3 +27,3 @@ "xml:lang=\"en-GB\">";

it("should parse " + test.expression + " and output SSML string", () => {
var parsed = undertest.parseToSsml(test.expression, "en-GB");
var parsed = undertest.parseToSsml(test.expression, "en-GB", {version: "1.0"});
expect(parsed).to.be.have.string("<speak ");

@@ -36,3 +40,3 @@ expect(parsed).to.equal(test.expected);

try {
undertest.parseToSsml(test.expression, "en-GB");
undertest.parseToSsml(test.expression, "en-GB", {version: "1.0"});
expect.fail();

@@ -39,0 +43,0 @@ } catch (e) {

@@ -436,3 +436,3 @@ "use strict";

happy.forEach((test) => {
var parsed = undertest.parseToSsml(test.expression, "en-GB");
var parsed = undertest.parseToSsml(test.expression, "en-GB", {version: "1.0"});
expect(parsed).to.be.have.string("<speak ");

@@ -446,3 +446,3 @@ expect(parsed).to.equal(test.expected);

undertest = require("../src/wiki2ssml");
var parsed = undertest.parseToSsml("[[volume:+6dB|\"a\" + 'b' & c <> d]]", "en-GB");
var parsed = undertest.parseToSsml("[[volume:+6dB|\"a\" + 'b' & c <> d]]", "en-GB", {version: "1.0"});
expect(parsed).to.be.a("string");

@@ -455,3 +455,3 @@ expect(parsed).to.equal(helper.HEAD + "<prosody volume=\"+6dB\">&quot;a&quot; + &apos;b&apos; &amp; c &lt;&gt; d</prosody>" + helper.TAIL);

var textWithoutMarkup = "This is a test without markups";
var parsed = undertest.parseToSsml(textWithoutMarkup, "en-GB");
var parsed = undertest.parseToSsml(textWithoutMarkup, "en-GB", {version: "1.0"});
expect(parsed).to.be.a("string");

@@ -470,2 +470,14 @@ expect(parsed).to.equal(helper.HEAD + textWithoutMarkup + helper.TAIL);

undertest = require("../src/wiki2ssml");
var parsed = undertest.parseToSsml("[[volume:+6dB|TEXT]]", "en-GB", {version: "1.0", pretty: true});
var expected = ["<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"<!DOCTYPE speak PUBLIC \"-//W3C//DTD SYNTHESIS 1.0//EN\" \"http://www.w3.org/TR/speech-synthesis/synthesis.dtd\">",
"<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd\" xml:lang=\"en-GB\">",
" <prosody volume=\"+6dB\">TEXT</prosody>",
"</speak>"].join("\n");
expect(parsed).to.be.a("string");
expect(parsed).to.equal(expected);
});
it("should use SSML 1.1 by default", () => {
undertest = require("../src/wiki2ssml");
var parsed = undertest.parseToSsml("[[volume:+6dB|TEXT]]", "en-GB", {pretty: true});

@@ -480,2 +492,13 @@ var expected = ["<?xml version=\"1.0\" encoding=\"UTF-8\"?>",

it("should use the customised encoding", () => {
undertest = require("../src/wiki2ssml");
var parsed = undertest.parseToSsml("[[volume:+6dB|TEXT]]", "en-GB", {pretty: true, encoding: "UTF-16"});
var expected = ["<?xml version=\"1.0\" encoding=\"UTF-16\"?>",
"<speak version=\"1.1\" xmlns=\"http://www.w3.org/2001/10/synthesis\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd\" xml:lang=\"en-GB\">",
" <prosody volume=\"+6dB\">TEXT</prosody>",
"</speak>"].join("\n");
expect(parsed).to.be.a("string");
expect(parsed).to.equal(expected);
});
it("should detect and validate markups", () => {

@@ -515,3 +538,3 @@ undertest = require("../src/wiki2ssml");

try {
undertest.parseToSsml(test.input, "en-GB");
undertest.parseToSsml(test.input, "en-GB", {version: "1.0"});
expect.fail();

@@ -529,3 +552,3 @@ } catch (e) {

try {
undertest.parseToSsml(null, "en-GB");
undertest.parseToSsml(null, "en-GB", {version: "1.0"});
expect.fail();

@@ -541,3 +564,3 @@ } catch (e) {

try {
undertest.parseToSsml(undefined, "en-GB");
undertest.parseToSsml(undefined, "en-GB", {version: "1.0"});
expect.fail();

@@ -553,3 +576,3 @@ } catch (e) {

try {
undertest.parseToSsml("", "en-GB");
undertest.parseToSsml("", "en-GB", {version: "1.0"});
expect.fail();

@@ -556,0 +579,0 @@ } catch (e) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc