speechmarkdown 0.1.12 → 0.1.13
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 +98 -57
- 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
|
@@ -2,6 +2,40 @@
|
|
|
2
2
|
|
|
3
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
4
|
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
| Language | Package | Install |
|
|
8
|
+
|----------|---------|---------|
|
|
9
|
+
| Rust | [speechmarkdown-rust](https://crates.io/crates/speechmarkdown-rust) | `cargo add speechmarkdown-rust` |
|
|
10
|
+
| Python | [speechmarkdown-rust](https://pypi.org/project/speechmarkdown-rust/) | `pip install speechmarkdown-rust` |
|
|
11
|
+
| Node.js | [speechmarkdown](https://www.npmjs.com/package/speechmarkdown) | `npm install speechmarkdown` |
|
|
12
|
+
| .NET | [SpeechMarkdown](https://www.nuget.org/packages/SpeechMarkdown) | `dotnet add package SpeechMarkdown` |
|
|
13
|
+
|
|
14
|
+
## Supported Platforms
|
|
15
|
+
|
|
16
|
+
| Platform | String ID |
|
|
17
|
+
|----------|-----------|
|
|
18
|
+
| Amazon Alexa | `"amazon-alexa"` or `"alexa"` |
|
|
19
|
+
| Google Assistant | `"google-assistant"` or `"google"` |
|
|
20
|
+
| Microsoft Azure | `"microsoft-azure"` or `"azure"` |
|
|
21
|
+
| Apple | `"apple"` |
|
|
22
|
+
| W3C | `"w3c"` |
|
|
23
|
+
| Samsung Bixby | `"samsung-bixby"` or `"bixby"` |
|
|
24
|
+
| ElevenLabs | `"elevenlabs"` |
|
|
25
|
+
| IBM Watson | `"ibm-watson"` or `"watson"` |
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
All bindings expose the same core methods:
|
|
30
|
+
|
|
31
|
+
| Method | Returns | Description |
|
|
32
|
+
|--------|---------|-------------|
|
|
33
|
+
| `to_ssml(input, platform)` | `string` | Convert SpeechMarkdown to SSML for the given platform |
|
|
34
|
+
| `to_text(input)` | `string` | Convert SpeechMarkdown to plain text (strips all markup) |
|
|
35
|
+
| `parse(input)` | `string` (JSON) | Parse SpeechMarkdown and return the AST as JSON |
|
|
36
|
+
| `is_speech_markdown(input)` | `bool` | Check if a string contains SpeechMarkdown syntax |
|
|
37
|
+
| `validate(input)` | `bool` | Validate that SpeechMarkdown parses without errors |
|
|
38
|
+
|
|
5
39
|
## Usage
|
|
6
40
|
|
|
7
41
|
### Rust
|
|
@@ -14,61 +48,50 @@ let ssml = SpeechMarkdownParser::to_ssml(
|
|
|
14
48
|
"Hello (world)[emphasis:\"strong\"]",
|
|
15
49
|
Platform::AmazonAlexa,
|
|
16
50
|
)?;
|
|
17
|
-
// => <speak>Hello <emphasis level="strong">world</emphasis></speak>
|
|
18
51
|
|
|
19
52
|
// Convert to plain text
|
|
20
53
|
let text = SpeechMarkdownParser::to_text("Hello (world)[emphasis:\"strong\"]")?;
|
|
21
|
-
// => Hello world
|
|
22
54
|
|
|
23
|
-
// Parse to AST (JSON)
|
|
55
|
+
// Parse to AST (JSON string)
|
|
24
56
|
let ast = SpeechMarkdownParser::parse("Hello world")?;
|
|
25
|
-
```
|
|
26
57
|
|
|
27
|
-
|
|
58
|
+
// Check if input contains SpeechMarkdown syntax
|
|
59
|
+
if SpeechMarkdownParser::is_speech_markdown(&input) {
|
|
60
|
+
// ...
|
|
61
|
+
}
|
|
28
62
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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"` |
|
|
63
|
+
// Validate input
|
|
64
|
+
SpeechMarkdownParser::validate(&input)?;
|
|
65
|
+
```
|
|
39
66
|
|
|
40
|
-
|
|
67
|
+
### Python
|
|
41
68
|
|
|
42
|
-
|
|
69
|
+
```python
|
|
70
|
+
from speechmarkdown_rust import to_ssml, to_text, parse, is_speech_markdown, validate
|
|
43
71
|
|
|
44
|
-
|
|
72
|
+
ssml = to_ssml('Hello (world)[emphasis:"strong"]', 'amazon-alexa')
|
|
73
|
+
text = to_text('Hello (world)[emphasis:"strong"]')
|
|
74
|
+
ast = parse('Hello world')
|
|
45
75
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
```
|
|
76
|
+
is_smd = is_speech_markdown('Hello (world)[emphasis:"strong"]') # True
|
|
77
|
+
is_smd = is_speech_markdown('Hello world') # False
|
|
49
78
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- **macOS**: `target/release/libspeechmarkdown_rust.dylib`
|
|
53
|
-
- **Linux**: `target/release/libspeechmarkdown_rust.so`
|
|
79
|
+
validate('Hello (world)[emphasis:"strong"]') # raises ValueError if invalid
|
|
80
|
+
```
|
|
54
81
|
|
|
55
|
-
###
|
|
82
|
+
### Node.js
|
|
56
83
|
|
|
57
|
-
```
|
|
58
|
-
|
|
84
|
+
```js
|
|
85
|
+
const { to_ssml, to_text, parse, is_speech_markdown, validate } = require('speechmarkdown')
|
|
59
86
|
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
speechmarkdown_free((char*)ssml);
|
|
87
|
+
const ssml = to_ssml('Hello (world)[emphasis:"strong"]', 'amazon-alexa')
|
|
88
|
+
const text = to_text('Hello (world)[emphasis:"strong"]')
|
|
89
|
+
const ast = parse('Hello world')
|
|
64
90
|
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
printf("%s\n", text);
|
|
68
|
-
speechmarkdown_free((char*)text);
|
|
91
|
+
is_speech_markdown('Hello (world)[emphasis:"strong"]') // true
|
|
92
|
+
is_speech_markdown('Hello world') // false
|
|
69
93
|
|
|
70
|
-
//
|
|
71
|
-
const char* err = speechmarkdown_get_error();
|
|
94
|
+
validate('Hello (world)[emphasis:"strong"]') // throws if invalid
|
|
72
95
|
```
|
|
73
96
|
|
|
74
97
|
### .NET (C#)
|
|
@@ -81,9 +104,10 @@ var parser = new SpeechMarkdownParser();
|
|
|
81
104
|
string ssml = parser.ToSsml("Hello (world)[emphasis:\"strong\"]", Platform.AmazonAlexa);
|
|
82
105
|
string text = parser.ToText("Hello (world)[emphasis:\"strong\"]");
|
|
83
106
|
string json = parser.ParseToJson("Hello world");
|
|
84
|
-
```
|
|
85
107
|
|
|
86
|
-
|
|
108
|
+
bool isSmd = parser.IsSpeechMarkdown("Hello (world)[emphasis:\"strong\"]"); // true
|
|
109
|
+
parser.Validate("Hello (world)[emphasis:\"strong\"]"); // throws on invalid
|
|
110
|
+
```
|
|
87
111
|
|
|
88
112
|
### Swift
|
|
89
113
|
|
|
@@ -95,32 +119,49 @@ let parser = SpeechMarkdownParser()
|
|
|
95
119
|
let ssml = try parser.toSsml(input: "Hello (world)[emphasis:\"strong\"]", platform: "amazon-alexa")
|
|
96
120
|
let text = try parser.toText(input: "Hello (world)[emphasis:\"strong\"]")
|
|
97
121
|
let json = try parser.parseToJson(input: "Hello world")
|
|
122
|
+
|
|
123
|
+
let isSmd = parser.isSpeechMarkdown(input: "Hello (world)[emphasis:\"strong\"]") // true
|
|
124
|
+
try parser.validate(input: "Hello (world)[emphasis:\"strong\"]") // throws on invalid
|
|
98
125
|
```
|
|
99
126
|
|
|
100
|
-
|
|
127
|
+
### C API
|
|
101
128
|
|
|
102
|
-
|
|
129
|
+
```c
|
|
130
|
+
#include "speechmarkdown.h"
|
|
103
131
|
|
|
104
|
-
|
|
105
|
-
const
|
|
132
|
+
// Convert to SSML
|
|
133
|
+
const char* ssml = speechmarkdown_to_ssml("Hello (world)[emphasis:\"strong\"]", "amazon-alexa");
|
|
134
|
+
speechmarkdown_free((char*)ssml);
|
|
106
135
|
|
|
107
|
-
|
|
136
|
+
// Convert to plain text
|
|
137
|
+
const char* text = speechmarkdown_to_text("Hello (world)[emphasis:\"strong\"]");
|
|
138
|
+
speechmarkdown_free((char*)text);
|
|
108
139
|
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
```
|
|
140
|
+
// Parse to JSON
|
|
141
|
+
const char* json = speechmarkdown_parse("Hello world");
|
|
142
|
+
speechmarkdown_free((char*)json);
|
|
113
143
|
|
|
114
|
-
|
|
144
|
+
// Check for SpeechMarkdown syntax
|
|
145
|
+
bool is_smd = speechmarkdown_is_speech_markdown("Hello (world)[emphasis:\"strong\"]");
|
|
115
146
|
|
|
116
|
-
|
|
147
|
+
// Validate
|
|
148
|
+
bool valid = speechmarkdown_validate("Hello (world)[emphasis:\"strong\"]");
|
|
117
149
|
|
|
118
|
-
|
|
119
|
-
|
|
150
|
+
// Get last error (thread-local)
|
|
151
|
+
const char* err = speechmarkdown_get_error();
|
|
152
|
+
```
|
|
120
153
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
154
|
+
## Building from Source
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
cargo build --release
|
|
124
158
|
```
|
|
125
159
|
|
|
126
|
-
|
|
160
|
+
This produces:
|
|
161
|
+
- **Windows**: `target/release/speechmarkdown_rust.dll`
|
|
162
|
+
- **macOS**: `target/release/libspeechmarkdown_rust.dylib`
|
|
163
|
+
- **Linux**: `target/release/libspeechmarkdown_rust.so`
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "speechmarkdown",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
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.13"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"speech",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|