recorder-client 1.0.1 → 1.0.3
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 +40 -19
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -14,28 +14,34 @@ npm i recorder-client
|
|
|
14
14
|
|
|
15
15
|
### API
|
|
16
16
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
17
|
+
| property | type | description | default |
|
|
18
|
+
| :--------: | :-----: | :-------------------------------------------------------------------------: | :-------: |
|
|
19
|
+
| sampleRate | number | audio sampling rate | undefined |
|
|
20
|
+
| chunkSize | number | number of samples in the audio data block (length of the audio buffer zone) | undefined |
|
|
21
|
+
| ignoreMute | boolean | ignore mute | undefined |
|
|
22
|
+
|
|
23
|
+
### Event
|
|
24
|
+
|
|
25
|
+
| property | type | description |
|
|
26
|
+
| :-------------: | :-----------------------: | :------------------: |
|
|
27
|
+
| ondataavailable | (pcm: Int16Array) => void | real-time audio data |
|
|
28
|
+
| onpause | () => void | pause event |
|
|
29
|
+
| onresume | () => void | resume event |
|
|
30
|
+
| onstart | () => void | start event |
|
|
31
|
+
| onstop | (wav: Blob) => void | stop event |
|
|
32
|
+
| pause | () => void | audio pause |
|
|
33
|
+
| resume | () => void | audio resume |
|
|
34
|
+
| start | () => void | audio start |
|
|
35
|
+
| stop | () => void | audio stop |
|
|
31
36
|
|
|
32
37
|
### Helper
|
|
33
38
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
+
| property | type | description |
|
|
40
|
+
| :--------: | :----------------------------------------------: | :-----------------------------------: |
|
|
41
|
+
| pcmMerge | (pcms: Int16Array[]) => Int16Array<ArrayBuffer> | merge multiple pcm streams |
|
|
42
|
+
| pcmToWav | (pcm: Int16Array, sampleRate: number) => Blob | convert PCM to WAV |
|
|
43
|
+
| parseWav | (buffer: ArrayBuffer) => object | obtain information about the wav file |
|
|
44
|
+
| isSpeaking | (pcm: Int16Array, sampleRate: number) => boolean | check if there is any input of audio |
|
|
39
45
|
|
|
40
46
|
### Example
|
|
41
47
|
|
|
@@ -117,3 +123,18 @@ const getWav = async (file: File) => {
|
|
|
117
123
|
const wav: Wav = Recorder.parseWav(buffer);
|
|
118
124
|
};
|
|
119
125
|
```
|
|
126
|
+
|
|
127
|
+
> isSpeaking
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
import { Recorder } from 'recorder-client';
|
|
131
|
+
|
|
132
|
+
const recorder = new Recorder({
|
|
133
|
+
sampleRate: 16000,
|
|
134
|
+
chunkSize: 1900,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
recorder.ondataavailable = (pcm) => {
|
|
138
|
+
const flag = Recorder.isSpeaking(pcm, 16000);
|
|
139
|
+
};
|
|
140
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "recorder-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "audio recording client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
32
32
|
"@types/node": "^24.3.0",
|
|
33
33
|
"happy-dom": "^18.0.1",
|
|
34
|
-
"rollup": "^4.
|
|
34
|
+
"rollup": "^4.48.0",
|
|
35
35
|
"rollup-plugin-dts": "^6.2.3",
|
|
36
36
|
"tslib": "^2.8.1",
|
|
37
|
-
"typescript": "^5.
|
|
38
|
-
"typescript-eslint-standard": "^9.
|
|
37
|
+
"typescript": "^5.9.2",
|
|
38
|
+
"typescript-eslint-standard": "^9.60.0",
|
|
39
39
|
"vitest": "^3.2.4"
|
|
40
40
|
},
|
|
41
41
|
"author": "mivui",
|