speechmarkdown 0.1.11 → 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 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
- ### Supported Platforms
58
+ // Check if input contains SpeechMarkdown syntax
59
+ if SpeechMarkdownParser::is_speech_markdown(&input) {
60
+ // ...
61
+ }
28
62
 
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"` |
63
+ // Validate input
64
+ SpeechMarkdownParser::validate(&input)?;
65
+ ```
39
66
 
40
- ## Language Bindings
67
+ ### Python
41
68
 
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.
69
+ ```python
70
+ from speechmarkdown_rust import to_ssml, to_text, parse, is_speech_markdown, validate
43
71
 
44
- ### Build the native library
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
- ```bash
47
- cargo build --release
48
- ```
76
+ is_smd = is_speech_markdown('Hello (world)[emphasis:"strong"]') # True
77
+ is_smd = is_speech_markdown('Hello world') # False
49
78
 
50
- This produces:
51
- - **Windows**: `target/release/speechmarkdown_rust.dll`
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
- ### C API
82
+ ### Node.js
56
83
 
57
- ```c
58
- #include "bindings/speechmarkdown.h"
84
+ ```js
85
+ const { to_ssml, to_text, parse, is_speech_markdown, validate } = require('speechmarkdown')
59
86
 
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);
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
- // 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);
91
+ is_speech_markdown('Hello (world)[emphasis:"strong"]') // true
92
+ is_speech_markdown('Hello world') // false
69
93
 
70
- // Get last error (thread-local)
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
- Copy `bindings/dotnet/SpeechMarkdown.cs` into your project and place the native library in your output directory alongside the assembly.
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
- Include `bindings/swift/SpeechMarkdown.swift`, `bindings/swift/module.modulemap`, and `bindings/speechmarkdown.h` in your Xcode project. Link against the compiled `.dylib`.
127
+ ### C API
101
128
 
102
- ### Node.js
129
+ ```c
130
+ #include "speechmarkdown.h"
103
131
 
104
- ```js
105
- const { SpeechMarkdownParser } = require('./bindings/nodejs');
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
- const parser = new SpeechMarkdownParser();
136
+ // Convert to plain text
137
+ const char* text = speechmarkdown_to_text("Hello (world)[emphasis:\"strong\"]");
138
+ speechmarkdown_free((char*)text);
108
139
 
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
- ```
140
+ // Parse to JSON
141
+ const char* json = speechmarkdown_parse("Hello world");
142
+ speechmarkdown_free((char*)json);
113
143
 
114
- Install `ffi-napi` and `ref-napi` as dependencies. Build the native library first with `cargo build --release`.
144
+ // Check for SpeechMarkdown syntax
145
+ bool is_smd = speechmarkdown_is_speech_markdown("Hello (world)[emphasis:\"strong\"]");
115
146
 
116
- ### Python
147
+ // Validate
148
+ bool valid = speechmarkdown_validate("Hello (world)[emphasis:\"strong\"]");
117
149
 
118
- ```python
119
- from speechmarkdown import to_ssml, to_text, parse
150
+ // Get last error (thread-local)
151
+ const char* err = speechmarkdown_get_error();
152
+ ```
120
153
 
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
154
+ ## Building from Source
155
+
156
+ ```bash
157
+ cargo build --release
124
158
  ```
125
159
 
126
- Available on [PyPI](https://pypi.org/project/speechmarkdown-rust/) as `speechmarkdown-rust`.
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.11",
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.11"
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