@lvce-editor/renderer-process 30.44.4 → 30.45.1
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/dist/rendererProcessMain.js +27 -7
- package/package.json +1 -1
|
@@ -10183,8 +10183,23 @@ const startInputAudioRecorder = (micStream, audioDebugPort) => {
|
|
|
10183
10183
|
recorder.start();
|
|
10184
10184
|
return recorder;
|
|
10185
10185
|
};
|
|
10186
|
+
const restartInputAudioRecorder = (inputAudioRecorder, micStream, audioDebugPort) => {
|
|
10187
|
+
const recorder = inputAudioRecorder.instance;
|
|
10188
|
+
if (!recorder || recorder.state !== 'recording') {
|
|
10189
|
+
return;
|
|
10190
|
+
}
|
|
10191
|
+
recorder.onstop = () => {
|
|
10192
|
+
recorder.onstop = null;
|
|
10193
|
+
if (inputAudioRecorder.instance !== recorder) {
|
|
10194
|
+
return;
|
|
10195
|
+
}
|
|
10196
|
+
inputAudioRecorder.instance = startInputAudioRecorder(micStream, audioDebugPort);
|
|
10197
|
+
};
|
|
10198
|
+
recorder.stop();
|
|
10199
|
+
};
|
|
10186
10200
|
const startWebRtcAudioStream = async options => {
|
|
10187
10201
|
const {
|
|
10202
|
+
audioConstraints,
|
|
10188
10203
|
audioDebugPort,
|
|
10189
10204
|
elementLocator,
|
|
10190
10205
|
port,
|
|
@@ -10216,9 +10231,11 @@ const startWebRtcAudioStream = async options => {
|
|
|
10216
10231
|
}
|
|
10217
10232
|
};
|
|
10218
10233
|
const micStream = await navigator.mediaDevices.getUserMedia({
|
|
10219
|
-
audio: true
|
|
10234
|
+
audio: audioConstraints ?? true
|
|
10220
10235
|
});
|
|
10221
|
-
const inputAudioRecorder =
|
|
10236
|
+
const inputAudioRecorder = {
|
|
10237
|
+
instance: startInputAudioRecorder(micStream, audioDebugPort)
|
|
10238
|
+
};
|
|
10222
10239
|
if (trackAudioData && audioCtx) {
|
|
10223
10240
|
micAnalyzer = setupLevelMeter(audioCtx, micStream);
|
|
10224
10241
|
}
|
|
@@ -10226,8 +10243,8 @@ const startWebRtcAudioStream = async options => {
|
|
|
10226
10243
|
const dc = pc.createDataChannel('oai-events');
|
|
10227
10244
|
dc.addEventListener('message', e => {
|
|
10228
10245
|
port.postMessage(e.data);
|
|
10229
|
-
if (
|
|
10230
|
-
inputAudioRecorder
|
|
10246
|
+
if (isSpeechStoppedEvent(e.data)) {
|
|
10247
|
+
restartInputAudioRecorder(inputAudioRecorder, micStream, audioDebugPort);
|
|
10231
10248
|
}
|
|
10232
10249
|
});
|
|
10233
10250
|
port.onmessage = event => {
|
|
@@ -10297,9 +10314,12 @@ const stopWebRtcAudioStream = async uid => {
|
|
|
10297
10314
|
connection.ontrack = null;
|
|
10298
10315
|
connection.close();
|
|
10299
10316
|
dataChannel.close();
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10317
|
+
const recorder = inputAudioRecorder.instance;
|
|
10318
|
+
inputAudioRecorder.instance = undefined;
|
|
10319
|
+
if (recorder && recorder.state !== 'inactive') {
|
|
10320
|
+
recorder.ondataavailable = null;
|
|
10321
|
+
recorder.onstop = null;
|
|
10322
|
+
recorder.stop();
|
|
10303
10323
|
}
|
|
10304
10324
|
for (const t of micStream.getTracks()) {
|
|
10305
10325
|
t.stop();
|