Skip to main content

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.

Usage

Rust

use speechmarkdown_rust::{SpeechMarkdownParser, Platform};

// Convert to SSML
let ssml = SpeechMarkdownParser::to_ssml(
    "Hello (world)[emphasis:\"strong\"]",
    Platform::AmazonAlexa,
)?;
// => <speak>Hello <emphasis level="strong">world</emphasis></speak>

// Convert to plain text
let text = SpeechMarkdownParser::to_text("Hello (world)[emphasis:\"strong\"]")?;
// => Hello world

// Parse to AST (JSON)
let ast = SpeechMarkdownParser::parse("Hello world")?;

Supported Platforms

Platform Enum Value String ID
Amazon Alexa Platform::AmazonAlexa "amazon-alexa" or "alexa"
Google Assistant Platform::GoogleAssistant "google-assistant" or "google"
Microsoft Azure Platform::MicrosoftAzure "microsoft-azure" or "azure"
Apple Platform::Apple "apple"
W3C Platform::W3c "w3c"
Samsung Bixby Platform::SamsungBixby "samsung-bixby" or "bixby"
ElevenLabs Platform::ElevenLabs "elevenlabs"
IBM Watson Platform::IbmWatson "ibm-watson" or "watson"

Language Bindings

The library exposes a C ABI (cdylib/staticlib) so it can be used from any language. Pre-built bindings are provided for .NET, Swift, and Node.js.

Build the native library

cargo build --release

This produces:

  • Windows: target/release/speechmarkdown_rust.dll
  • macOS: target/release/libspeechmarkdown_rust.dylib
  • Linux: target/release/libspeechmarkdown_rust.so

C API

#include "bindings/speechmarkdown.h"

// Convert SpeechMarkdown to SSML
const char* ssml = speechmarkdown_to_ssml("Hello (world)[emphasis:\"strong\"]", "amazon-alexa");
printf("%s\n", ssml);
speechmarkdown_free((char*)ssml);

// Convert to plain text
const char* text = speechmarkdown_to_text("Hello (world)[emphasis:\"strong\"]");
printf("%s\n", text);
speechmarkdown_free((char*)text);

// Get last error (thread-local)
const char* err = speechmarkdown_get_error();

.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");

Copy bindings/dotnet/SpeechMarkdown.cs into your project and place the native library in your output directory alongside the assembly.

Swift

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")

Include bindings/swift/SpeechMarkdown.swift, bindings/swift/module.modulemap, and bindings/speechmarkdown.h in your Xcode project. Link against the compiled .dylib.

Node.js

const { SpeechMarkdownParser } = require('./bindings/nodejs');

const parser = new SpeechMarkdownParser();

const ssml = parser.toSsml('Hello (world)[emphasis:"strong"]', 'amazon-alexa');
const text = parser.toText('Hello (world)[emphasis:"strong"]');
const json = parser.parseToJson('Hello world');

Install ffi-napi and ref-napi as dependencies. Build the native library first with cargo build --release.

Python

from speechmarkdown import to_ssml, to_text, parse

ssml = to_ssml('Hello (world)[emphasis:"strong"]', 'amazon-alexa')
text = to_text('Hello (world)[emphasis:"strong"]')
ast = parse('Hello world')  # returns dict

Available on PyPI as speechmarkdown-rust.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

speechmarkdown_rust-0.1.12.tar.gz (449.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

speechmarkdown_rust-0.1.12-cp313-cp313-win_amd64.whl (221.7 kB view details)

Uploaded CPython 3.13Windows x86-64

speechmarkdown_rust-0.1.12-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (360.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

speechmarkdown_rust-0.1.12-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (351.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

speechmarkdown_rust-0.1.12-cp313-cp313-macosx_11_0_arm64.whl (317.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

speechmarkdown_rust-0.1.12-cp313-cp313-macosx_10_12_x86_64.whl (323.7 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

File details

Details for the file speechmarkdown_rust-0.1.12.tar.gz.

File metadata

  • Download URL: speechmarkdown_rust-0.1.12.tar.gz
  • Upload date:
  • Size: 449.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for speechmarkdown_rust-0.1.12.tar.gz
Algorithm Hash digest
SHA256 d42041af83eaa20ca6ac77466f4a25803e03b20918b0204358cf72d47434a4fb
MD5 66a38c626853215c8719f9bb441fb808
BLAKE2b-256 78a0d65b3934c2b9223f77723356c690a0108a48e3ed9d1de8a89f669cfe625e

See more details on using hashes here.

Provenance

The following attestation bundles were made for speechmarkdown_rust-0.1.12.tar.gz:

Publisher: publish.yml on AACTools/speechmarkdown-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file speechmarkdown_rust-0.1.12-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for speechmarkdown_rust-0.1.12-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 da8718cd9f4b5876f849b105baa0dae3f4109843c571696190a56a4bc173232b
MD5 132f1b38c67e5e863d177a1e3afe1122
BLAKE2b-256 31fd34ed35575ba8efb586c3702a4ec5d9091592d3dfdca19b988bec18df0f15

See more details on using hashes here.

Provenance

The following attestation bundles were made for speechmarkdown_rust-0.1.12-cp313-cp313-win_amd64.whl:

Publisher: publish.yml on AACTools/speechmarkdown-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file speechmarkdown_rust-0.1.12-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for speechmarkdown_rust-0.1.12-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d30ae802b15a81a18c1cd6d32fd1b26539b0b523cb8a573226adce0b292ecdf6
MD5 8b83570ebdc6930f7bb42ea479383af9
BLAKE2b-256 e4be9edcb432b1f5adbe62a70a4b14bf0fd99fd8171a90eaf384dd41f88f637d

See more details on using hashes here.

Provenance

The following attestation bundles were made for speechmarkdown_rust-0.1.12-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on AACTools/speechmarkdown-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file speechmarkdown_rust-0.1.12-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for speechmarkdown_rust-0.1.12-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3517cc68316fbd9df6c2615151cf8f01c221b211252ddb66c4a932a1cb32dc0c
MD5 2b2360b281d3c5406df653751d4b0009
BLAKE2b-256 eed4a83f12fd451032704ad1ae28cca19f014deef924183da7741954c3e1a669

See more details on using hashes here.

Provenance

The following attestation bundles were made for speechmarkdown_rust-0.1.12-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on AACTools/speechmarkdown-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file speechmarkdown_rust-0.1.12-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for speechmarkdown_rust-0.1.12-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bd792ded9da1d62552b65b0a284280053f0bbab84fcfe9bb842f7a39dea02ee7
MD5 d7edd0cb7df8921450b2ef2bfcfdf76a
BLAKE2b-256 c16ca510465dc30c5f667079fb70c833d6fa82f6b0e991667953771e262a6bf0

See more details on using hashes here.

Provenance

The following attestation bundles were made for speechmarkdown_rust-0.1.12-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish.yml on AACTools/speechmarkdown-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file speechmarkdown_rust-0.1.12-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for speechmarkdown_rust-0.1.12-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3374549bc46cf62b9798b8145a6ee4ba47f0648e453bb73f0bc3a8a172004fff
MD5 14a497e3da09be28b3ad5b257b8269b7
BLAKE2b-256 b0af9fd13f3b1d1643170bfd4b849bfbc65eef32f2129cd508b78d7f60a4fee9

See more details on using hashes here.

Provenance

The following attestation bundles were made for speechmarkdown_rust-0.1.12-cp313-cp313-macosx_10_12_x86_64.whl:

Publisher: publish.yml on AACTools/speechmarkdown-rust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page