electron-native-speech 0.1.2 → 0.1.4

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 +144 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,144 @@
1
+ # electron-native-speech
2
+
3
+ Core TypeScript API for native speech transcription in Electron.
4
+
5
+ This package provides the shared types and high-level API:
6
+
7
+ - `getSpeechAvailability()`
8
+ - `transcribeFile()`
9
+ - `createSpeechSession()`
10
+
11
+ On macOS, it auto-loads `electron-native-speech-backend-macos` at runtime.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install electron-native-speech
17
+ ```
18
+
19
+ On macOS, the backend package is normally installed automatically as an optional dependency.
20
+ If your environment skips optional dependencies, install it explicitly:
21
+
22
+ ```bash
23
+ npm install electron-native-speech electron-native-speech-backend-macos
24
+ ```
25
+
26
+ ## When to use this package
27
+
28
+ Use this package when you want:
29
+
30
+ - the core speech API and types
31
+ - direct access from Node or the Electron main process
32
+ - a shared abstraction for custom backends or tests
33
+
34
+ If you need to expose speech APIs to a context-isolated Electron renderer, also install:
35
+
36
+ ```bash
37
+ npm install electron-native-speech-preload
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ### File transcription
43
+
44
+ ```ts
45
+ import { getSpeechAvailability, transcribeFile } from "electron-native-speech"
46
+
47
+ const availability = await getSpeechAvailability()
48
+ if (!availability.available) {
49
+ throw new Error(availability.reason ?? "Speech recognition unavailable")
50
+ }
51
+
52
+ const result = await transcribeFile({
53
+ filePath: "/absolute/path/to/recording.mp3",
54
+ locale: "en-US",
55
+ })
56
+
57
+ for (const segment of result.segments) {
58
+ console.log(`[${segment.startMs}ms - ${segment.endMs}ms] ${segment.text}`)
59
+ }
60
+ ```
61
+
62
+ ### Live microphone
63
+
64
+ ```ts
65
+ import { createSpeechSession } from "electron-native-speech"
66
+
67
+ const session = await createSpeechSession()
68
+
69
+ const offResult = session.on("result", (result) => {
70
+ console.log(result.text, result.isFinal ? "(final)" : "(interim)")
71
+ })
72
+
73
+ const offError = session.on("error", (error) => {
74
+ console.error(error.code, error.message)
75
+ })
76
+
77
+ await session.start({
78
+ locale: "en-US",
79
+ interimResults: true,
80
+ continuous: true,
81
+ })
82
+
83
+ // later
84
+ await session.stop()
85
+ await session.dispose()
86
+ offResult()
87
+ offError()
88
+ ```
89
+
90
+ ## API
91
+
92
+ ### `getSpeechAvailability()`
93
+
94
+ ```ts
95
+ getSpeechAvailability(): Promise<SpeechAvailability>
96
+ ```
97
+
98
+ Checks whether a supported backend is present and speech recognition is available.
99
+
100
+ ### `transcribeFile(options)`
101
+
102
+ ```ts
103
+ transcribeFile(options: FileTranscriptionOptions): Promise<FileTranscriptionResult>
104
+ ```
105
+
106
+ Recognizes speech from a local audio or video file.
107
+
108
+ ### `createSpeechSession()`
109
+
110
+ ```ts
111
+ createSpeechSession(): Promise<SpeechSession>
112
+ ```
113
+
114
+ Creates a live microphone recognition session.
115
+
116
+ ## Custom backends and tests
117
+
118
+ This package also exports:
119
+
120
+ - `setBackend()`
121
+ - `resetBackend()`
122
+ - `SpeechRecognitionError`
123
+ - all public speech types
124
+
125
+ That is useful if you want to inject a mock backend in tests or provide your own implementation.
126
+
127
+ ## Platform support
128
+
129
+ - macOS 13+
130
+ - Electron 28+
131
+ - Node.js 18+
132
+
133
+ Windows and Linux backends are not published yet.
134
+
135
+ ## Electron apps
136
+
137
+ For a complete Electron integration with `contextIsolation: true`, use:
138
+
139
+ - `electron-native-speech` for the shared API and types
140
+ - `electron-native-speech-preload` for the preload bridge and IPC handlers
141
+
142
+ Full documentation and examples:
143
+
144
+ - https://github.com/varaprasadreddy9676/electron-native-speech
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-native-speech",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Native OS speech transcription for Electron apps — fast, local, no cloud required",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -41,7 +41,7 @@
41
41
  }
42
42
  },
43
43
  "optionalDependencies": {
44
- "electron-native-speech-backend-macos": ">=0.1.1",
45
- "electron-native-speech-preload": ">=0.1.1"
44
+ "electron-native-speech-backend-macos": ">=0.1.6",
45
+ "electron-native-speech-preload": ">=0.1.4"
46
46
  }
47
47
  }