speechmarkdown 0.1.0 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # SpeechMarkdown Rust
2
+
3
+ High-performance SpeechMarkdown parser written in Rust. Converts [SpeechMarkdown](https://speechmarkdown.com/) syntax to platform-specific SSML for Amazon Alexa, Google Assistant, Microsoft Azure, and more.
4
+
5
+ ## Usage
6
+
7
+ ### Rust
8
+
9
+ ```rust
10
+ use speechmarkdown_rust::{SpeechMarkdownParser, Platform};
11
+
12
+ // Convert to SSML
13
+ let ssml = SpeechMarkdownParser::to_ssml(
14
+ "Hello (world)[emphasis:\"strong\"]",
15
+ Platform::AmazonAlexa,
16
+ )?;
17
+ // => <speak>Hello <emphasis level="strong">world</emphasis></speak>
18
+
19
+ // Convert to plain text
20
+ let text = SpeechMarkdownParser::to_text("Hello (world)[emphasis:\"strong\"]")?;
21
+ // => Hello world
22
+
23
+ // Parse to AST (JSON)
24
+ let ast = SpeechMarkdownParser::parse("Hello world")?;
25
+ ```
26
+
27
+ ### Supported Platforms
28
+
29
+ | Platform | Enum Value | String ID |
30
+ |----------|-----------|-----------|
31
+ | Amazon Alexa | `Platform::AmazonAlexa` | `"amazon-alexa"` or `"alexa"` |
32
+ | Google Assistant | `Platform::GoogleAssistant` | `"google-assistant"` or `"google"` |
33
+ | Microsoft Azure | `Platform::MicrosoftAzure` | `"microsoft-azure"` or `"azure"` |
34
+ | Apple | `Platform::Apple` | `"apple"` |
35
+ | W3C | `Platform::W3c` | `"w3c"` |
36
+ | Samsung Bixby | `Platform::SamsungBixby` | `"samsung-bixby"` or `"bixby"` |
37
+ | ElevenLabs | `Platform::ElevenLabs` | `"elevenlabs"` |
38
+ | IBM Watson | `Platform::IbmWatson` | `"ibm-watson"` or `"watson"` |
39
+
40
+ ## Language Bindings
41
+
42
+ 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.
43
+
44
+ ### Build the native library
45
+
46
+ ```bash
47
+ cargo build --release
48
+ ```
49
+
50
+ This produces:
51
+ - **Windows**: `target/release/speechmarkdown_rust.dll`
52
+ - **macOS**: `target/release/libspeechmarkdown_rust.dylib`
53
+ - **Linux**: `target/release/libspeechmarkdown_rust.so`
54
+
55
+ ### C API
56
+
57
+ ```c
58
+ #include "bindings/speechmarkdown.h"
59
+
60
+ // Convert SpeechMarkdown to SSML
61
+ const char* ssml = speechmarkdown_to_ssml("Hello (world)[emphasis:\"strong\"]", "amazon-alexa");
62
+ printf("%s\n", ssml);
63
+ speechmarkdown_free((char*)ssml);
64
+
65
+ // Convert to plain text
66
+ const char* text = speechmarkdown_to_text("Hello (world)[emphasis:\"strong\"]");
67
+ printf("%s\n", text);
68
+ speechmarkdown_free((char*)text);
69
+
70
+ // Get last error (thread-local)
71
+ const char* err = speechmarkdown_get_error();
72
+ ```
73
+
74
+ ### .NET (C#)
75
+
76
+ ```csharp
77
+ using SpeechMarkdown;
78
+
79
+ var parser = new SpeechMarkdownParser();
80
+
81
+ string ssml = parser.ToSsml("Hello (world)[emphasis:\"strong\"]", Platform.AmazonAlexa);
82
+ string text = parser.ToText("Hello (world)[emphasis:\"strong\"]");
83
+ string json = parser.ParseToJson("Hello world");
84
+ ```
85
+
86
+ Copy `bindings/dotnet/SpeechMarkdown.cs` into your project and place the native library in your output directory alongside the assembly.
87
+
88
+ ### Swift
89
+
90
+ ```swift
91
+ import SpeechMarkdown
92
+
93
+ let parser = SpeechMarkdownParser()
94
+
95
+ let ssml = try parser.toSsml(input: "Hello (world)[emphasis:\"strong\"]", platform: "amazon-alexa")
96
+ let text = try parser.toText(input: "Hello (world)[emphasis:\"strong\"]")
97
+ let json = try parser.parseToJson(input: "Hello world")
98
+ ```
99
+
100
+ Include `bindings/swift/SpeechMarkdown.swift`, `bindings/swift/module.modulemap`, and `bindings/speechmarkdown.h` in your Xcode project. Link against the compiled `.dylib`.
101
+
102
+ ### Node.js
103
+
104
+ ```js
105
+ const { SpeechMarkdownParser } = require('./bindings/nodejs');
106
+
107
+ const parser = new SpeechMarkdownParser();
108
+
109
+ const ssml = parser.toSsml('Hello (world)[emphasis:"strong"]', 'amazon-alexa');
110
+ const text = parser.toText('Hello (world)[emphasis:"strong"]');
111
+ const json = parser.parseToJson('Hello world');
112
+ ```
113
+
114
+ Install `ffi-napi` and `ref-napi` as dependencies. Build the native library first with `cargo build --release`.
115
+
116
+ ### Python
117
+
118
+ ```python
119
+ from speechmarkdown import to_ssml, to_text, parse
120
+
121
+ ssml = to_ssml('Hello (world)[emphasis:"strong"]', 'amazon-alexa')
122
+ text = to_text('Hello (world)[emphasis:"strong"]')
123
+ ast = parse('Hello world') # returns dict
124
+ ```
125
+
126
+ Available on [PyPI](https://pypi.org/project/speechmarkdown-rust/) as `speechmarkdown-rust`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speechmarkdown",
3
- "version": "0.1.0",
3
+ "version": "0.1.12",
4
4
  "description": "SpeechMarkdown parser - convert SpeechMarkdown to SSML",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "build:debug": "napi build --platform",
11
11
  "prepublishOnly": "napi prepublish -t npm",
12
12
  "test": "node test.js",
13
- "version": "napi version"
13
+ "version": "0.1.12"
14
14
  },
15
15
  "keywords": [
16
16
  "speech",
@@ -20,10 +20,15 @@
20
20
  "speechmarkdown"
21
21
  ],
22
22
  "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/AACTools/speechmarkdown-rust"
26
+ },
23
27
  "files": [
24
28
  "index.js",
25
29
  "index.d.ts",
26
- "*.node"
30
+ "*.node",
31
+ "README.md"
27
32
  ],
28
33
  "napi": {
29
34
  "binaryName": "speechmarkdown",
@@ -38,15 +43,15 @@
38
43
  ]
39
44
  },
40
45
  "devDependencies": {
41
- "@napi-rs/cli": "^3"
46
+ "@napi-rs/cli": "^3.6.2"
42
47
  },
43
48
  "optionalDependencies": {
44
- "speechmarkdown-win32-x64-msvc": "0.1.0",
45
- "speechmarkdown-win32-arm64-msvc": "0.1.0",
46
- "speechmarkdown-darwin-x64": "0.1.0",
47
49
  "speechmarkdown-darwin-arm64": "0.1.0",
48
- "speechmarkdown-linux-x64-gnu": "0.1.0",
50
+ "speechmarkdown-darwin-x64": "0.1.0",
49
51
  "speechmarkdown-linux-arm64-gnu": "0.1.0",
50
- "speechmarkdown-linux-x64-musl": "0.1.0"
52
+ "speechmarkdown-linux-x64-gnu": "0.1.0",
53
+ "speechmarkdown-linux-x64-musl": "0.1.0",
54
+ "speechmarkdown-win32-arm64-msvc": "0.1.0",
55
+ "speechmarkdown-win32-x64-msvc": "0.1.0"
51
56
  }
52
- }
57
+ }
Binary file
Binary file
Binary file