# SSMD Specification Here we specify how Speech Synthesis Markdown (SSMD) works. ## Syntax SSMD is mapped to SSML using the following rules. - [SSMD Specification](#ssmd-specification) - [Syntax](#syntax) - [Text](#text) - [Emphasis](#emphasis) - [Break](#break) - [Paragraph](#paragraph) - [Prosody](#prosody) - [Say-as](#say-as) - [Audio](#audio) - [Headings](#headings) - [Extensions](#extensions) --- ### Text Any text written is implicitly wrapped in a `` root element. This will be omitted in the rest of the examples shown in this section. SSMD: ``` text ``` SSML: ```html text ``` --- ### Emphasis SSMD: ``` *command* & conquer **_command_** & conquer ``` SSML: ```html command & conquer command & conquer ``` --- ### Break Pauses can be indicated by using `...`. Several modifications to the duration are allowed as shown below. SSMD: ``` Hello ... world (default: x-strong break like after a paragraph) Hello - ...0 world (skip break when there would otherwise be one like after this dash) Hello ...c world (medium break like after a comma) Hello ...s world (strong break like after a sentence) Hello ...p world (extra string break like after a paragraph) Hello ...5s world (5 second break (max 10s)) Hello ...100ms world (100 millisecond break (max 10000ms)) Hello ...100 world (100 millisecond break (max 10000ms)) ``` SSML: ```html Hello world (default: x-strong break like after a paragraph) Hello - 0 world (skip break when there would otherwise be one like after this dash) Hello c world (medium break like after a comma) Hello s world (strong break like after a sentence) Hello p world (extra string break like after a paragraph) Hello world (5 second break (max 10s)) Hello world (100 millisecond break (max 10000ms)) Hello 100 world (100 millisecond break (max 10000ms)) ``` --- ### Paragraph Empty lines indicate a paragraph. SSMD: ``` First prepare the ingredients. Don't forget to wash them first. Lastly mix them all together. Don't forget to do the dishes after! ``` SSML: ```html

First prepare the ingredients. Don't forget to wash them first.

Lastly mix them all together.

Don't forget to do the dishes after!

``` --- ### Prosody The prosody or rythm depends the volume, rate and pitch of the delivered text. Each of those values can be defined by a number between 1 and 5 where those mean: | number | volume | rate | pitch | | ------ | ------ | ------ | ------ | | 0 | silent | | | | 1 | x-soft | x-slow | x-low | | 2 | soft | slow | low | | 3 | medium | medium | medium | | 4 | loud | fast | high | | 5 | x-loud | x-fast | x-high | SSMD: ``` Volume: ~silent~ --extra soft-- -soft- medium +loud+ ++extra loud++ Rate: <fast> extra fast: >>extra fast>> Pitch: __extra low__ _low_ medium ^high^ ^^extra high^^ [extra loud, fast, and high](vrp: 555) ``` SSML: ```html Volume: silent extra soft soft medium loud extra loud Rate: extra slow slow medium fast: fast extra fast: extra fast Pitch: extra low low medium high extra high extra loud, fast, and high ``` The shortcuts are listed first. While they can be combined, sometimes it's easier and shorter to just use the explicit form shown in the last 2 lines. All of them can be nested, too. Moreover changes in volume (`[louder](v: +10dB)`) and pitch (`[lower](p: -4%)`) can also be given explicitly in relative values. --- ### Say-as You can give the speech sythesis engine hints as to what it's supposed to read using `as`. Possible values: - character - spell out each single character, e.g. for KGB - number - cardinal number, e.g. 100 - ordinal - ordinal number, e.g. 1st - digits - spell out each single digit, e.g. 123 as 1 - 2 - 3 - fraction - pronounce number as fraction, e.g. 3/4 as three quarters - unit - e.g. 1meter - date - read content as a date, must provide format - time - duration in minutes and seconds - address - read as part of an address - telephone - read content as a telephone number - expletive - beeps out the content SSMD: ``` telephone number is [+49 123456](as: telephone). You can't say [fuck](as: expletive) on television. ``` SSML: ```html telephone number is +49 123456. You can't say fuck on television. ``` --- ### Audio Audio Syntax : [description of sound](urlOfSound.mp3 alternative text) Description text is used for display Following the url, an alternate text may be provided in case the file is not readable SSMD: ``` Here's a fun sound [boing](https://example.com/sounds/boing.mp3) [a cat purring](cat_purr_close.ogg Purr (sound didn't load)) [](miaou.mp3) ``` SSML: ```html Here's a fun sound ``` --- ### Headings Heading tag adds emphasis and a small break by default, but you can configure it as you like : ``` const ssml = ssmd("# My first heading 1", { headingLevels: { 1: [ { tag: "emphasis", value: 'strong' }, { tag: "pause", value: '300ms' }, ], // if we ommit key "2", it will uses default params for heading 2 3: [ { tag: "pause", value: '50ms' }, { tag: "prosody", value: {rate: 'slow'} }, { tag: "pause", value: '200ms' }, ], } }); ``` You can use any tag and value referenced from [ssml-builder project](https://www.npmjs.com/package/ssml-builder/v/0.4.3) By default headings give : * \# Heading 1 -> strong emphasis and a 100ms pause after * \# Heading 2 -> moderate emphasis and a 75ms pause after * \# Heading 3 -> reduced emphasis and a 50ms pause after SSMD: ``` # Heading 1 ## Heading 2 ##Heading 2 ### Heading 3 #### Heading 4 // Not handled by default ``` SSML: ```html Heading 1 Heading 2 Heading 2 Heading 3 #### Heading 4 // Not handled by default ``` --- ### Extensions Amazon SSML SSMD: ``` If he [whispers](ext: whisper), he lies. Listen this [https://example.com/test.mp3](ext: audio). [Waouh](as: interjection) trop bien ! ``` SSML: ```html If he whispers, he lies. Listen this Waouh trop bien ! ``` ---