You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-2Lines changed: 23 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,7 @@ Creates a recorder instance.
52
52
-**originalSampleRateOverride** - (*optional*) Override the ogg opus 'input sample rate' field. Google Speech API requires this field to be `16000`.
53
53
-**resampleQuality** - (*optional*) Value between 0 and 10 which determines latency and processing for resampling. `0` is fastest with lowest quality. `10` is slowest with highest quality. Defaults to `3`.
54
54
-**streamPages** - (*optional*) `dataAvailable` event will fire after each encoded page. Defaults to `false`.
55
+
-**reuseWorker** - (*optional*) If true, the worker is not automatically destroyed when `stop` is called. Instead, it is reused for subsequent `start` calls and must be explicitly destroyed after stopping by calling `destroyWorker`. Defaults to `false`.
55
56
56
57
57
58
#### Config options for WAV recorder
@@ -64,10 +65,10 @@ Creates a recorder instance.
64
65
65
66
66
67
```js
67
-
rec.pause()
68
+
rec.pause([flush])
68
69
```
69
70
70
-
**pause** will keep the stream and monitoring alive, but will not be recording the buffers. Will call the `onpause` callback when paused. Subsequent calls to **resume** will add to the current recording.
71
+
**pause** will keep the stream and monitoring alive, but will not be recording the buffers. If `flush` is `true` and `streamPages` is set, any pending encoded frames of data will be flushed, and it will return a promise that only resolves after the frames have been flushed to `ondataavailable`. Will call the `onpause` callback when paused. Subsequent calls to **resume** will add to the current recording.
71
72
72
73
```js
73
74
rec.resume()
@@ -99,6 +100,26 @@ rec.stop()
99
100
100
101
**stop** will cease capturing audio and disable the monitoring and mic input stream. Will request the recorded data and then terminate the worker once the final data has been published. Will call the `onstop` callback when stopped.
101
102
103
+
```js
104
+
rec.destroyWorker()
105
+
```
106
+
107
+
**destroyWorker** will destroy the worker freeing up the browser resources. If the recorder is re-started, a new worker will be created. Note that `destroyWorker` is automatically called when stopping unless `reuseWorker` is true.
108
+
109
+
```js
110
+
rec.loadWorker()
111
+
```
112
+
113
+
**loadWorker** triggers pre-loading of the worker. This can reduce the startup latency when calling `start`. Call `destroyWorker` to clean the worker when the recorder is stopped/not started, or it will be automatically cleaned up after stopping unless `reuseWorker` is true.
114
+
115
+
---------
116
+
#### Instance Fields
117
+
118
+
```js
119
+
rec.encodedSamplePosition
120
+
```
121
+
122
+
Reads the currently encoded sample position (the number of samples up to and including the most recent data provided to `ondataavailable`). For Opus, the encoded sample rate is always 48kHz, so a time position can be determined by dividing by 48000.
0 commit comments