SpeechMarkdown parser - convert SpeechMarkdown to SSML
Project description
SpeechMarkdown Rust
High-performance SpeechMarkdown parser written in Rust. Converts SpeechMarkdown syntax to platform-specific SSML for Amazon Alexa, Google Assistant, Microsoft Azure, and more.
Install
| Language | Package | Install |
|---|---|---|
| Rust | speechmarkdown-rust | cargo add speechmarkdown-rust |
| Python | speechmarkdown-rust | pip install speechmarkdown-rust |
| Node.js | speechmarkdown | npm install speechmarkdown |
| .NET | SpeechMarkdown | dotnet add package SpeechMarkdown |
| Swift | Release asset | See Swift section below |
Supported Platforms
| Platform | String ID |
|---|---|
| Amazon Alexa | "amazon-alexa" or "alexa" |
| Google Assistant | "google-assistant" or "google" |
| Microsoft Azure | "microsoft-azure" or "azure" |
| Apple | "apple" |
| W3C | "w3c" |
| Samsung Bixby | "samsung-bixby" or "bixby" |
| ElevenLabs | "elevenlabs" |
| IBM Watson | "ibm-watson" or "watson" |
API
All bindings expose the same core methods:
| Method | Returns | Description |
|---|---|---|
to_ssml(input, platform) |
string |
Convert SpeechMarkdown to SSML for the given platform |
to_text(input) |
string |
Convert SpeechMarkdown to plain text (strips all markup) |
to_smd(ssml) |
string |
Convert SSML to SpeechMarkdown (best-effort, lossy for unsupported elements) |
parse(input) |
string (JSON) |
Parse SpeechMarkdown and return the AST as JSON |
is_speech_markdown(input) |
bool |
Check if a string contains SpeechMarkdown syntax |
validate(input) |
bool |
Validate that SpeechMarkdown parses without errors |
Usage
Rust
use speechmarkdown_rust::{SpeechMarkdownParser, Platform};
// Convert to SSML
let ssml = SpeechMarkdownParser::to_ssml(
"Hello (world)[emphasis:\"strong\"]",
Platform::AmazonAlexa,
)?;
// Convert to plain text
let text = SpeechMarkdownParser::to_text("Hello (world)[emphasis:\"strong\"]")?;
// Parse to AST (JSON string)
let ast = SpeechMarkdownParser::parse("Hello world")?;
// Check if input contains SpeechMarkdown syntax
if SpeechMarkdownParser::is_speech_markdown(&input) {
// ...
}
// Validate input
SpeechMarkdownParser::validate(&input)?;
// Convert SSML back to SpeechMarkdown (best-effort)
let smd = SpeechMarkdownParser::to_smd(r#"<speak><emphasis level="strong">word</emphasis></speak>"#)?;
// Returns: ++word++
Python
from speechmarkdown_rust import to_ssml, to_text, parse, is_speech_markdown, validate
ssml = to_ssml('Hello (world)[emphasis:"strong"]', 'amazon-alexa')
text = to_text('Hello (world)[emphasis:"strong"]')
ast = parse('Hello world')
is_smd = is_speech_markdown('Hello (world)[emphasis:"strong"]') # True
is_smd = is_speech_markdown('Hello world') # False
validate('Hello (world)[emphasis:"strong"]') # raises ValueError if invalid
# Convert SSML to SpeechMarkdown (best-effort)
smd = to_smd('<speak><emphasis level="strong">word</emphasis></speak>')
# Returns: ++word++
Node.js
const { to_ssml, to_text, parse, is_speech_markdown, validate } = require('speechmarkdown')
const ssml = to_ssml('Hello (world)[emphasis:"strong"]', 'amazon-alexa')
const text = to_text('Hello (world)[emphasis:"strong"]')
const ast = parse('Hello world')
is_speech_markdown('Hello (world)[emphasis:"strong"]') // true
is_speech_markdown('Hello world') // false
validate('Hello (world)[emphasis:"strong"]') // throws if invalid
// Convert SSML to SpeechMarkdown (best-effort)
const smd = to_smd('<speak><emphasis level="strong">word</emphasis></speak>')
// Returns: ++word++
.NET (C#)
using SpeechMarkdown;
var parser = new SpeechMarkdownParser();
string ssml = parser.ToSsml("Hello (world)[emphasis:\"strong\"]", Platform.AmazonAlexa);
string text = parser.ToText("Hello (world)[emphasis:\"strong\"]");
string json = parser.ParseToJson("Hello world");
bool isSmd = parser.IsSpeechMarkdown("Hello (world)[emphasis:\"strong\"]"); // true
parser.Validate("Hello (world)[emphasis:\"strong\"]"); // throws on invalid
// Convert SSML to SpeechMarkdown (best-effort)
string smd = parser.ToSmd("<speak><emphasis level=\"strong\">word</emphasis></speak>");
// Returns: ++word++
Swift
The repo root contains a Package.swift with a binary target pointing to a pre-built XCFramework. This enables both local development and Swift Package Index integration.
Option 1 — SPM (recommended):
// In your Package.swift:
.package(url: "https://github.com/AACTools/speechmarkdown-rust", branch: "spm")
Option 2 — Local package:
Download speechmarkdown-swift-package.zip from the latest release, unzip, and add as a local package in Xcode (File > Add Packages > Add Local).
Includes macOS (arm64 + x86_64), iOS device (arm64), and iOS simulator (arm64) slices.
To build from source: ./build-swift-package.sh
import SpeechMarkdown
let parser = SpeechMarkdownParser()
let ssml = try parser.toSsml(input: "Hello (world)[emphasis:\"strong\"]", platform: "amazon-alexa")
let text = try parser.toText(input: "Hello (world)[emphasis:\"strong\"]")
let json = try parser.parseToJson(input: "Hello world")
let isSmd = parser.isSpeechMarkdown(input: "Hello (world)[emphasis:\"strong\"]") // true
try parser.validate(input: "Hello (world)[emphasis:\"strong\"]") // throws on invalid
// Convert SSML to SpeechMarkdown (best-effort)
let smd = try parser.toSmd(ssml: "<speak><emphasis level=\"strong\">word</emphasis></speak>")
// Returns: ++word++
C API
#include "speechmarkdown.h"
// Convert to SSML
const char* ssml = speechmarkdown_to_ssml("Hello (world)[emphasis:\"strong\"]", "amazon-alexa");
speechmarkdown_free((char*)ssml);
// Convert to plain text
const char* text = speechmarkdown_to_text("Hello (world)[emphasis:\"strong\"]");
speechmarkdown_free((char*)text);
// Parse to JSON
const char* json = speechmarkdown_parse("Hello world");
speechmarkdown_free((char*)json);
// Check for SpeechMarkdown syntax
bool is_smd = speechmarkdown_is_speech_markdown("Hello (world)[emphasis:\"strong\"]");
// Validate
bool valid = speechmarkdown_validate("Hello (world)[emphasis:\"strong\"]");
// Convert SSML to SpeechMarkdown (best-effort)
const char* smd = speechmarkdown_to_smd("<speak><emphasis level=\"strong\">word</emphasis></speak>");
speechmarkdown_free((char*)smd);
// Get last error (thread-local)
const char* err = speechmarkdown_get_error();
Building from Source
cargo build --release
This produces:
- Windows:
target/release/speechmarkdown_rust.dll - macOS:
target/release/libspeechmarkdown_rust.dylib - Linux:
target/release/libspeechmarkdown_rust.so
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file speechmarkdown_rust-0.1.16.tar.gz.
File metadata
- Download URL: speechmarkdown_rust-0.1.16.tar.gz
- Upload date:
- Size: 494.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4b8a8ffd7cd788a6107b220b3559d91fa133781fd9596c496ca080f88d13586
|
|
| MD5 |
aae997d89d76ab38b7336185cf971655
|
|
| BLAKE2b-256 |
91277f2b1a338d239164663274bd4a9eaebe3bd39687421a34e6d21d489fdfb0
|
Provenance
The following attestation bundles were made for speechmarkdown_rust-0.1.16.tar.gz:
Publisher:
publish.yml on AACTools/speechmarkdown-rust
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
speechmarkdown_rust-0.1.16.tar.gz -
Subject digest:
f4b8a8ffd7cd788a6107b220b3559d91fa133781fd9596c496ca080f88d13586 - Sigstore transparency entry: 1602772885
- Sigstore integration time:
-
Permalink:
AACTools/speechmarkdown-rust@9e051d55691579fcecae702982833cf39359054b -
Branch / Tag:
refs/tags/v0.1.16 - Owner: https://github.com/AACTools
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9e051d55691579fcecae702982833cf39359054b -
Trigger Event:
push
-
Statement type:
File details
Details for the file speechmarkdown_rust-0.1.16-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: speechmarkdown_rust-0.1.16-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 252.1 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a2e5012c3c188ec03876ad5720722a86ff4148c71c3bf691ecf05622994413b
|
|
| MD5 |
e0965cddc573ce332da45330cdcc4d8d
|
|
| BLAKE2b-256 |
84a55738408046cb7ac1baedaa6828d5e343f659b96f042c11e0395f5c70c562
|
Provenance
The following attestation bundles were made for speechmarkdown_rust-0.1.16-cp313-cp313-win_amd64.whl:
Publisher:
publish.yml on AACTools/speechmarkdown-rust
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
speechmarkdown_rust-0.1.16-cp313-cp313-win_amd64.whl -
Subject digest:
5a2e5012c3c188ec03876ad5720722a86ff4148c71c3bf691ecf05622994413b - Sigstore transparency entry: 1602773213
- Sigstore integration time:
-
Permalink:
AACTools/speechmarkdown-rust@9e051d55691579fcecae702982833cf39359054b -
Branch / Tag:
refs/tags/v0.1.16 - Owner: https://github.com/AACTools
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9e051d55691579fcecae702982833cf39359054b -
Trigger Event:
push
-
Statement type:
File details
Details for the file speechmarkdown_rust-0.1.16-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: speechmarkdown_rust-0.1.16-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 397.2 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb0faf2e22fe5793a5c3efb3decf06b1141bd777fca35fd2b61e0c9b75c36b1a
|
|
| MD5 |
1a1d0096852053e6e6b22f1cdd54cc08
|
|
| BLAKE2b-256 |
cf1a63787846e9100f9910fd5e9abcdfb41157bb94055c5ce1694c27d8711e18
|
Provenance
The following attestation bundles were made for speechmarkdown_rust-0.1.16-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish.yml on AACTools/speechmarkdown-rust
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
speechmarkdown_rust-0.1.16-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
fb0faf2e22fe5793a5c3efb3decf06b1141bd777fca35fd2b61e0c9b75c36b1a - Sigstore transparency entry: 1602773725
- Sigstore integration time:
-
Permalink:
AACTools/speechmarkdown-rust@9e051d55691579fcecae702982833cf39359054b -
Branch / Tag:
refs/tags/v0.1.16 - Owner: https://github.com/AACTools
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9e051d55691579fcecae702982833cf39359054b -
Trigger Event:
push
-
Statement type:
File details
Details for the file speechmarkdown_rust-0.1.16-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: speechmarkdown_rust-0.1.16-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 387.1 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0c6d07083c9a72284f3036156229b272beef571bbbfa69bf649cf1d4bee406d
|
|
| MD5 |
c5405a1acbf8641ea4ac2ec0e7c49978
|
|
| BLAKE2b-256 |
281764e8a4d3634dc741ccae2e05d820ae2c61c67180e10b58876f2ae43695fa
|
Provenance
The following attestation bundles were made for speechmarkdown_rust-0.1.16-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish.yml on AACTools/speechmarkdown-rust
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
speechmarkdown_rust-0.1.16-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
c0c6d07083c9a72284f3036156229b272beef571bbbfa69bf649cf1d4bee406d - Sigstore transparency entry: 1602773423
- Sigstore integration time:
-
Permalink:
AACTools/speechmarkdown-rust@9e051d55691579fcecae702982833cf39359054b -
Branch / Tag:
refs/tags/v0.1.16 - Owner: https://github.com/AACTools
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9e051d55691579fcecae702982833cf39359054b -
Trigger Event:
push
-
Statement type:
File details
Details for the file speechmarkdown_rust-0.1.16-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: speechmarkdown_rust-0.1.16-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 348.7 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12c2b89e0d93a4e153ea17d44708e348af4cf2f8cf72a255ee66fb611e75633c
|
|
| MD5 |
0cf2913338a9d68b209fcab4a561f88a
|
|
| BLAKE2b-256 |
a49fb04f5cddcee9f9e7d0b9407d1d9ba3255a05595b33b4f4e0cb545e9f0b65
|
Provenance
The following attestation bundles were made for speechmarkdown_rust-0.1.16-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
publish.yml on AACTools/speechmarkdown-rust
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
speechmarkdown_rust-0.1.16-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
12c2b89e0d93a4e153ea17d44708e348af4cf2f8cf72a255ee66fb611e75633c - Sigstore transparency entry: 1602773994
- Sigstore integration time:
-
Permalink:
AACTools/speechmarkdown-rust@9e051d55691579fcecae702982833cf39359054b -
Branch / Tag:
refs/tags/v0.1.16 - Owner: https://github.com/AACTools
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9e051d55691579fcecae702982833cf39359054b -
Trigger Event:
push
-
Statement type:
File details
Details for the file speechmarkdown_rust-0.1.16-cp313-cp313-macosx_10_12_x86_64.whl.
File metadata
- Download URL: speechmarkdown_rust-0.1.16-cp313-cp313-macosx_10_12_x86_64.whl
- Upload date:
- Size: 355.3 kB
- Tags: CPython 3.13, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
811e67a9b9c5d652289e2718d31c3015e260c7be308de27331529233ff53c158
|
|
| MD5 |
40151dccab6d1c3ed4ce50b60ba1a57e
|
|
| BLAKE2b-256 |
869f0a8d562fd4ed07529f0f8901fe31796a87c24d3ebd409bc5e51c58bd87f4
|
Provenance
The following attestation bundles were made for speechmarkdown_rust-0.1.16-cp313-cp313-macosx_10_12_x86_64.whl:
Publisher:
publish.yml on AACTools/speechmarkdown-rust
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
speechmarkdown_rust-0.1.16-cp313-cp313-macosx_10_12_x86_64.whl -
Subject digest:
811e67a9b9c5d652289e2718d31c3015e260c7be308de27331529233ff53c158 - Sigstore transparency entry: 1602774321
- Sigstore integration time:
-
Permalink:
AACTools/speechmarkdown-rust@9e051d55691579fcecae702982833cf39359054b -
Branch / Tag:
refs/tags/v0.1.16 - Owner: https://github.com/AACTools
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9e051d55691579fcecae702982833cf39359054b -
Trigger Event:
push
-
Statement type: