speechmarkdown 0.1.13 → 0.1.15
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 +33 -0
- package/package.json +2 -2
- package/speechmarkdown.darwin-arm64.node +0 -0
- package/speechmarkdown.darwin-x64.node +0 -0
- package/speechmarkdown.linux-arm64-gnu.node +0 -0
- package/speechmarkdown.linux-x64-gnu.node +0 -0
- package/speechmarkdown.linux-x64-musl.node +0 -0
- package/speechmarkdown.win32-arm64-msvc.node +0 -0
- package/speechmarkdown.win32-x64-msvc.node +0 -0
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ High-performance SpeechMarkdown parser written in Rust. Converts [SpeechMarkdown
|
|
|
10
10
|
| Python | [speechmarkdown-rust](https://pypi.org/project/speechmarkdown-rust/) | `pip install speechmarkdown-rust` |
|
|
11
11
|
| Node.js | [speechmarkdown](https://www.npmjs.com/package/speechmarkdown) | `npm install speechmarkdown` |
|
|
12
12
|
| .NET | [SpeechMarkdown](https://www.nuget.org/packages/SpeechMarkdown) | `dotnet add package SpeechMarkdown` |
|
|
13
|
+
| Swift | [Release asset](https://github.com/AACTools/speechmarkdown-rust/releases) | Download `speechmarkdown-swift-package.zip` |
|
|
13
14
|
|
|
14
15
|
## Supported Platforms
|
|
15
16
|
|
|
@@ -32,6 +33,7 @@ All bindings expose the same core methods:
|
|
|
32
33
|
|--------|---------|-------------|
|
|
33
34
|
| `to_ssml(input, platform)` | `string` | Convert SpeechMarkdown to SSML for the given platform |
|
|
34
35
|
| `to_text(input)` | `string` | Convert SpeechMarkdown to plain text (strips all markup) |
|
|
36
|
+
| `to_smd(ssml)` | `string` | Convert SSML to SpeechMarkdown (best-effort, lossy for unsupported elements) |
|
|
35
37
|
| `parse(input)` | `string` (JSON) | Parse SpeechMarkdown and return the AST as JSON |
|
|
36
38
|
| `is_speech_markdown(input)` | `bool` | Check if a string contains SpeechMarkdown syntax |
|
|
37
39
|
| `validate(input)` | `bool` | Validate that SpeechMarkdown parses without errors |
|
|
@@ -62,6 +64,10 @@ if SpeechMarkdownParser::is_speech_markdown(&input) {
|
|
|
62
64
|
|
|
63
65
|
// Validate input
|
|
64
66
|
SpeechMarkdownParser::validate(&input)?;
|
|
67
|
+
|
|
68
|
+
// Convert SSML back to SpeechMarkdown (best-effort)
|
|
69
|
+
let smd = SpeechMarkdownParser::to_smd(r#"<speak><emphasis level="strong">word</emphasis></speak>"#)?;
|
|
70
|
+
// Returns: ++word++
|
|
65
71
|
```
|
|
66
72
|
|
|
67
73
|
### Python
|
|
@@ -77,6 +83,10 @@ is_smd = is_speech_markdown('Hello (world)[emphasis:"strong"]') # True
|
|
|
77
83
|
is_smd = is_speech_markdown('Hello world') # False
|
|
78
84
|
|
|
79
85
|
validate('Hello (world)[emphasis:"strong"]') # raises ValueError if invalid
|
|
86
|
+
|
|
87
|
+
# Convert SSML to SpeechMarkdown (best-effort)
|
|
88
|
+
smd = to_smd('<speak><emphasis level="strong">word</emphasis></speak>')
|
|
89
|
+
# Returns: ++word++
|
|
80
90
|
```
|
|
81
91
|
|
|
82
92
|
### Node.js
|
|
@@ -92,6 +102,10 @@ is_speech_markdown('Hello (world)[emphasis:"strong"]') // true
|
|
|
92
102
|
is_speech_markdown('Hello world') // false
|
|
93
103
|
|
|
94
104
|
validate('Hello (world)[emphasis:"strong"]') // throws if invalid
|
|
105
|
+
|
|
106
|
+
// Convert SSML to SpeechMarkdown (best-effort)
|
|
107
|
+
const smd = to_smd('<speak><emphasis level="strong">word</emphasis></speak>')
|
|
108
|
+
// Returns: ++word++
|
|
95
109
|
```
|
|
96
110
|
|
|
97
111
|
### .NET (C#)
|
|
@@ -107,10 +121,21 @@ string json = parser.ParseToJson("Hello world");
|
|
|
107
121
|
|
|
108
122
|
bool isSmd = parser.IsSpeechMarkdown("Hello (world)[emphasis:\"strong\"]"); // true
|
|
109
123
|
parser.Validate("Hello (world)[emphasis:\"strong\"]"); // throws on invalid
|
|
124
|
+
|
|
125
|
+
// Convert SSML to SpeechMarkdown (best-effort)
|
|
126
|
+
string smd = parser.ToSmd("<speak><emphasis level=\"strong\">word</emphasis></speak>");
|
|
127
|
+
// Returns: ++word++
|
|
110
128
|
```
|
|
111
129
|
|
|
112
130
|
### Swift
|
|
113
131
|
|
|
132
|
+
Download `speechmarkdown-swift-package.zip` from the [latest release](https://github.com/AACTools/speechmarkdown-rust/releases), unzip it, and add it as a local package in Xcode. Includes macOS (arm64 + x86_64), iOS device (arm64), and iOS simulator (arm64) slices.
|
|
133
|
+
|
|
134
|
+
1. **Xcode**: File > Add Packages > Add Local > select the unzipped directory
|
|
135
|
+
2. **Or in Package.swift**: `.package(path: "./path/to/speechmarkdown-swift-package")`
|
|
136
|
+
|
|
137
|
+
To build from source instead: `./build-swift-package.sh` (requires Rust toolchain with `aarch64-apple-darwin` and `x86_64-apple-darwin` targets)
|
|
138
|
+
|
|
114
139
|
```swift
|
|
115
140
|
import SpeechMarkdown
|
|
116
141
|
|
|
@@ -122,6 +147,10 @@ let json = try parser.parseToJson(input: "Hello world")
|
|
|
122
147
|
|
|
123
148
|
let isSmd = parser.isSpeechMarkdown(input: "Hello (world)[emphasis:\"strong\"]") // true
|
|
124
149
|
try parser.validate(input: "Hello (world)[emphasis:\"strong\"]") // throws on invalid
|
|
150
|
+
|
|
151
|
+
// Convert SSML to SpeechMarkdown (best-effort)
|
|
152
|
+
let smd = try parser.toSmd(ssml: "<speak><emphasis level=\"strong\">word</emphasis></speak>")
|
|
153
|
+
// Returns: ++word++
|
|
125
154
|
```
|
|
126
155
|
|
|
127
156
|
### C API
|
|
@@ -147,6 +176,10 @@ bool is_smd = speechmarkdown_is_speech_markdown("Hello (world)[emphasis:\"strong
|
|
|
147
176
|
// Validate
|
|
148
177
|
bool valid = speechmarkdown_validate("Hello (world)[emphasis:\"strong\"]");
|
|
149
178
|
|
|
179
|
+
// Convert SSML to SpeechMarkdown (best-effort)
|
|
180
|
+
const char* smd = speechmarkdown_to_smd("<speak><emphasis level=\"strong\">word</emphasis></speak>");
|
|
181
|
+
speechmarkdown_free((char*)smd);
|
|
182
|
+
|
|
150
183
|
// Get last error (thread-local)
|
|
151
184
|
const char* err = speechmarkdown_get_error();
|
|
152
185
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "speechmarkdown",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
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": "0.1.
|
|
13
|
+
"version": "0.1.15"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"speech",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|