@mdgate/audio 0.6.8 → 0.6.9

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.
Files changed (2) hide show
  1. package/README.md +133 -6
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,17 +1,144 @@
1
1
  # @mdgate/audio
2
2
 
3
- Convert MP3, WAV, M4A, AAC, Ogg, FLAC, and WebM audio to Markdown. Outputs GitHub-Flavored
4
- Markdown. Works in Node, Edge, and browsers. No native addons.
3
+ **Convert audio to Markdown in TypeScript.**
5
4
 
6
- Needs an `(input) => markdown` transcription function `@mdgate/ai` or your own. `all()` does not
7
- register `audio()`.
5
+ [`@mdgate/audio`](https://github.com/mdgate/converters/tree/main/packages/audio) recognizes MP3, WAV, M4A, AAC, Ogg, FLAC, and WebM audio, then hands the file to a transcription callback you provide.
6
+
7
+ It does not ship a speech model. `audio()` is not registered by `all()`.
8
+
9
+ Works in **Node.js, Cloudflare Workers, Edge runtimes, and browsers**.
10
+
11
+ ```bash
12
+ npm install @mdgate/audio
13
+ ```
14
+
15
+ ---
16
+
17
+ ## Why [`@mdgate/audio`](https://github.com/mdgate/converters/tree/main/packages/audio)
18
+
19
+ Audio is not a document format. Documents that software can parse are handled deterministically. Speech needs a model.
20
+
21
+ This package keeps that split:
22
+
23
+ ```text
24
+ audio bytes → your transcription callback → Markdown
25
+ ```
26
+
27
+ * **Pure TypeScript**
28
+ * **No Python runtime**
29
+ * **No native addons**
30
+ * **No WASM runtime**
31
+ * **Zero third-party runtime dependencies in this package**
32
+ * **Detects common audio types from their contents, not only the filename**
33
+ * **Not included in `all()`**
34
+
35
+ ---
36
+
37
+ ## What it does
38
+
39
+ The converter sniffs the audio type, then calls your `(input) => markdown` function with `{ bytes, mime }`.
40
+
41
+ The whole file is passed through. mdgate does not decode or resample the audio.
42
+
43
+ Without a callback, conversion fails as unsupported.
44
+
45
+ ---
46
+
47
+ ## Usage
8
48
 
9
49
  ```ts
10
50
  import { create } from '@mdgate/core';
11
51
  import { audio } from '@mdgate/audio';
12
52
  import { ai } from '@mdgate/ai';
13
53
 
14
- const convert = create([
15
- audio(ai({ baseURL, apiKey, model }).convertAudio),
54
+ const media = ai({
55
+ baseURL: 'https://api.example.com/v1',
56
+ apiKey: process.env.API_KEY!,
57
+ model: 'your-model',
58
+ });
59
+
60
+ const read = create([
61
+ audio(media.convertAudio),
16
62
  ]);
63
+
64
+ const markdown = await read(bytes, {
65
+ path: 'meeting.mp3',
66
+ });
17
67
  ```
68
+
69
+ Or pass any transcription function:
70
+
71
+ ```ts
72
+ import { create } from '@mdgate/core';
73
+ import { audio } from '@mdgate/audio';
74
+
75
+ const read = create([
76
+ audio(async (input) => {
77
+ // Send input.bytes to the speech model you already use.
78
+ return '...';
79
+ }),
80
+ ]);
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Node.js
86
+
87
+ ```ts
88
+ import { readFile } from 'node:fs/promises';
89
+ import { create } from '@mdgate/core';
90
+ import { audio } from '@mdgate/audio';
91
+
92
+ const read = create([
93
+ audio(transcribe),
94
+ ]);
95
+
96
+ const bytes = new Uint8Array(await readFile('meeting.mp3'));
97
+ const markdown = await read(bytes, { path: 'meeting.mp3' });
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Cloudflare Workers and Edge runtimes
103
+
104
+ ```ts
105
+ import { create } from '@mdgate/core';
106
+ import { audio } from '@mdgate/audio';
107
+
108
+ const read = create([
109
+ audio(transcribe),
110
+ ]);
111
+
112
+ export default {
113
+ async fetch(request: Request) {
114
+ const bytes = new Uint8Array(await request.arrayBuffer());
115
+ const markdown = await read(bytes);
116
+
117
+ return new Response(markdown, {
118
+ headers: {
119
+ 'content-type': 'text/markdown; charset=utf-8',
120
+ },
121
+ });
122
+ },
123
+ };
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Need more than audio?
129
+
130
+ If your application needs to read many different file types, use the complete converter set, then add `audio()` on top. `all()` does not register it.
131
+
132
+ ```bash
133
+ npm install @mdgate/converters
134
+ ```
135
+
136
+ [`@mdgate/audio`](https://github.com/mdgate/converters/tree/main/packages/audio) is one of the single-format packages in the open-source [`mdgate/converters`](https://github.com/mdgate/converters) project.
137
+
138
+ For AI agents, the same converter architecture can be used to extend `read_file` from text files to real-world document formats.
139
+
140
+ ---
141
+
142
+ ## License
143
+
144
+ MIT
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@mdgate/audio",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "description": "mdgate audio converter",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "homepage": "https://demo.mdgate.dev",
7
+ "homepage": "https://convert.mdgate.dev",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/mdgate/converters.git",
@@ -28,7 +28,7 @@
28
28
  "prepublishOnly": "bun run build"
29
29
  },
30
30
  "dependencies": {
31
- "@mdgate/core": "0.6.8"
31
+ "@mdgate/core": "0.6.9"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"