@lvce-editor/renderer-process 30.45.0 → 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 +25 -6
- package/package.json +1 -1
|
@@ -10183,6 +10183,20 @@ 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 {
|
|
10188
10202
|
audioConstraints,
|
|
@@ -10219,7 +10233,9 @@ const startWebRtcAudioStream = async options => {
|
|
|
10219
10233
|
const micStream = await navigator.mediaDevices.getUserMedia({
|
|
10220
10234
|
audio: audioConstraints ?? true
|
|
10221
10235
|
});
|
|
10222
|
-
const inputAudioRecorder =
|
|
10236
|
+
const inputAudioRecorder = {
|
|
10237
|
+
instance: startInputAudioRecorder(micStream, audioDebugPort)
|
|
10238
|
+
};
|
|
10223
10239
|
if (trackAudioData && audioCtx) {
|
|
10224
10240
|
micAnalyzer = setupLevelMeter(audioCtx, micStream);
|
|
10225
10241
|
}
|
|
@@ -10227,8 +10243,8 @@ const startWebRtcAudioStream = async options => {
|
|
|
10227
10243
|
const dc = pc.createDataChannel('oai-events');
|
|
10228
10244
|
dc.addEventListener('message', e => {
|
|
10229
10245
|
port.postMessage(e.data);
|
|
10230
|
-
if (
|
|
10231
|
-
inputAudioRecorder
|
|
10246
|
+
if (isSpeechStoppedEvent(e.data)) {
|
|
10247
|
+
restartInputAudioRecorder(inputAudioRecorder, micStream, audioDebugPort);
|
|
10232
10248
|
}
|
|
10233
10249
|
});
|
|
10234
10250
|
port.onmessage = event => {
|
|
@@ -10298,9 +10314,12 @@ const stopWebRtcAudioStream = async uid => {
|
|
|
10298
10314
|
connection.ontrack = null;
|
|
10299
10315
|
connection.close();
|
|
10300
10316
|
dataChannel.close();
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
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();
|
|
10304
10323
|
}
|
|
10305
10324
|
for (const t of micStream.getTracks()) {
|
|
10306
10325
|
t.stop();
|