@lvce-editor/renderer-process 30.42.2 → 30.43.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 +45 -1
- package/package.json +1 -1
|
@@ -8608,8 +8608,14 @@ const handleFocusOut = event => {
|
|
|
8608
8608
|
}
|
|
8609
8609
|
const uid = fromEvent(event);
|
|
8610
8610
|
if (!relatedTarget && target && isInsideTitleBarMenu(target)) {
|
|
8611
|
+
if (!target.isConnected) {
|
|
8612
|
+
return;
|
|
8613
|
+
}
|
|
8611
8614
|
queueMicrotask(() => {
|
|
8612
|
-
|
|
8615
|
+
const {
|
|
8616
|
+
activeElement
|
|
8617
|
+
} = document;
|
|
8618
|
+
if (!activeElement || !isInsideTitleBarMenu(activeElement)) {
|
|
8613
8619
|
closeMenu$1(uid);
|
|
8614
8620
|
}
|
|
8615
8621
|
});
|
|
@@ -10069,8 +10075,33 @@ const setupLevelMeter = (audioCtx, stream) => {
|
|
|
10069
10075
|
source.connect(analyser);
|
|
10070
10076
|
return analyser;
|
|
10071
10077
|
};
|
|
10078
|
+
const isSpeechStoppedEvent = data => {
|
|
10079
|
+
if (typeof data !== 'string') {
|
|
10080
|
+
return false;
|
|
10081
|
+
}
|
|
10082
|
+
try {
|
|
10083
|
+
const event = JSON.parse(data);
|
|
10084
|
+
return event?.type === 'input_audio_buffer.speech_stopped';
|
|
10085
|
+
} catch {
|
|
10086
|
+
return false;
|
|
10087
|
+
}
|
|
10088
|
+
};
|
|
10089
|
+
const startInputAudioRecorder = (micStream, audioDebugPort) => {
|
|
10090
|
+
if (!audioDebugPort) {
|
|
10091
|
+
return undefined;
|
|
10092
|
+
}
|
|
10093
|
+
const recorder = new MediaRecorder(micStream);
|
|
10094
|
+
recorder.ondataavailable = event => {
|
|
10095
|
+
if (event.data.size > 0) {
|
|
10096
|
+
audioDebugPort.postMessage(event.data);
|
|
10097
|
+
}
|
|
10098
|
+
};
|
|
10099
|
+
recorder.start();
|
|
10100
|
+
return recorder;
|
|
10101
|
+
};
|
|
10072
10102
|
const startWebRtcAudioStream = async options => {
|
|
10073
10103
|
const {
|
|
10104
|
+
audioDebugPort,
|
|
10074
10105
|
elementLocator,
|
|
10075
10106
|
port,
|
|
10076
10107
|
trackAudioData,
|
|
@@ -10103,6 +10134,7 @@ const startWebRtcAudioStream = async options => {
|
|
|
10103
10134
|
const micStream = await navigator.mediaDevices.getUserMedia({
|
|
10104
10135
|
audio: true
|
|
10105
10136
|
});
|
|
10137
|
+
const inputAudioRecorder = startInputAudioRecorder(micStream, audioDebugPort);
|
|
10106
10138
|
if (trackAudioData && audioCtx) {
|
|
10107
10139
|
micAnalyzer = setupLevelMeter(audioCtx, micStream);
|
|
10108
10140
|
}
|
|
@@ -10110,6 +10142,9 @@ const startWebRtcAudioStream = async options => {
|
|
|
10110
10142
|
const dc = pc.createDataChannel('oai-events');
|
|
10111
10143
|
dc.addEventListener('message', e => {
|
|
10112
10144
|
port.postMessage(e.data);
|
|
10145
|
+
if (inputAudioRecorder?.state === 'recording' && isSpeechStoppedEvent(e.data)) {
|
|
10146
|
+
inputAudioRecorder.requestData();
|
|
10147
|
+
}
|
|
10113
10148
|
});
|
|
10114
10149
|
port.onmessage = event => {
|
|
10115
10150
|
const {
|
|
@@ -10126,8 +10161,10 @@ const startWebRtcAudioStream = async options => {
|
|
|
10126
10161
|
await pc.setLocalDescription(offer);
|
|
10127
10162
|
pcs[uid] = {
|
|
10128
10163
|
audioCtx,
|
|
10164
|
+
audioDebugPort,
|
|
10129
10165
|
connection: pc,
|
|
10130
10166
|
dataChannel: dc,
|
|
10167
|
+
inputAudioRecorder,
|
|
10131
10168
|
micAnalyzer,
|
|
10132
10169
|
micStream,
|
|
10133
10170
|
port,
|
|
@@ -10164,8 +10201,10 @@ const stopWebRtcAudioStream = async uid => {
|
|
|
10164
10201
|
// TODO use disposableMap maybe?
|
|
10165
10202
|
const {
|
|
10166
10203
|
audioCtx,
|
|
10204
|
+
audioDebugPort,
|
|
10167
10205
|
connection,
|
|
10168
10206
|
dataChannel,
|
|
10207
|
+
inputAudioRecorder,
|
|
10169
10208
|
micStream,
|
|
10170
10209
|
port,
|
|
10171
10210
|
remoteAudio
|
|
@@ -10174,10 +10213,15 @@ const stopWebRtcAudioStream = async uid => {
|
|
|
10174
10213
|
connection.ontrack = null;
|
|
10175
10214
|
connection.close();
|
|
10176
10215
|
dataChannel.close();
|
|
10216
|
+
if (inputAudioRecorder && inputAudioRecorder.state !== 'inactive') {
|
|
10217
|
+
inputAudioRecorder.ondataavailable = null;
|
|
10218
|
+
inputAudioRecorder.stop();
|
|
10219
|
+
}
|
|
10177
10220
|
for (const t of micStream.getTracks()) {
|
|
10178
10221
|
t.stop();
|
|
10179
10222
|
}
|
|
10180
10223
|
port.close();
|
|
10224
|
+
audioDebugPort?.close();
|
|
10181
10225
|
remoteAudio.srcObject = null;
|
|
10182
10226
|
if (audioCtx) {
|
|
10183
10227
|
await audioCtx.close();
|