mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
fix: shared audio clicked and clipped in the voice mix
The shared source is mixed in at -6 dB so music near full scale doesn't clip with the voice on top. With AEC3 its blocks made the extra queue run short now and then, which was padded with silence (clicks); it now skips once and stays a frame ahead, capped to bound latency. Drops the temporary diagnostics: Edge delivered silence for Windows system audio even without the mic open, so the hint now points to sharing a tab. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
93b809ff9a
commit
4752971f31
6 files changed
+15
-24
No files matched your search
+3
-18
@@ -8743,26 +8743,11 @@ function AppInner() {
|
||||
tabAudioRef.current = stream;
|
||||
micCaptureRef.current?.setExtraAudio(stream);
|
||||
setTabAudioOn(true);
|
||||
// Windows system audio only covers the default output device; music on
|
||||
// another device arrives as pure silence, with nothing else to tell why.
|
||||
setTimeout(async () => {
|
||||
// Windows system audio can arrive as pure silence (seen in Edge, with or
|
||||
// without the mic open), with nothing else to tell why.
|
||||
setTimeout(() => {
|
||||
if (tabAudioRef.current !== stream || !micCaptureRef.current || micCaptureRef.current.extraPeak >= 1e-4) return;
|
||||
appendLog({ text: t("tabAudio.silent"), kind: "error" });
|
||||
// ponytail: temporary diagnostics - tells "browser delivers silence"
|
||||
// apart from "the mixer loses it"; drop once the Edge report is solved.
|
||||
const probe = new AudioContext();
|
||||
void probe.resume();
|
||||
const analyser = probe.createAnalyser();
|
||||
probe.createMediaStreamSource(new MediaStream([track])).connect(analyser);
|
||||
await new Promise((r) => setTimeout(r, 1500));
|
||||
const data = new Float32Array(analyser.fftSize);
|
||||
analyser.getFloatTimeDomainData(data);
|
||||
const direct = data.reduce((m, v) => Math.max(m, Math.abs(v)), 0);
|
||||
appendLog({
|
||||
text: `Diag: direct=${direct.toFixed(5)} mixer=${micCaptureRef.current?.extraPeak.toFixed(5)} muted=${track.muted} state=${track.readyState} enabled=${track.enabled} probe=${probe.state} settings=${JSON.stringify(track.getSettings())}`,
|
||||
kind: "error",
|
||||
});
|
||||
void probe.close();
|
||||
}, 5000);
|
||||
};
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
"tabAudio.start": "Ton eines Tabs oder Fensters in den Sprachkanal geben (mit Kopfhörer kein Echo)",
|
||||
"tabAudio.stop": "Ton-Freigabe beenden",
|
||||
"tabAudio.noAudio": "Es wurde kein Ton freigegeben. Im Auswahldialog einen Tab oder ein Fenster wählen und den Ton einschalten.",
|
||||
"tabAudio.silent": "Der geteilte Ton ist seit 5 Sekunden still. Bei „Systemaudio“ nimmt der Browser nur das Windows-Standard-Wiedergabegerät auf. Läuft die Musik auf einem anderen Gerät, kommt nichts an.",
|
||||
"tabAudio.silent": "Vom geteilten Ton kommt seit 5 Sekunden nichts an. Systemaudio liefert nicht auf jedem Windows-Rechner Ton. Teile stattdessen einen Browser-Tab, zum Beispiel Spotify im Web oder YouTube, mit eingeschaltetem „Tab-Audio teilen“.",
|
||||
"toolbar.muteSound": "Ton stummschalten (Ausgabe stumm)",
|
||||
"toolbar.unmuteSound": "Ton aktivieren (Ausgabe an)",
|
||||
"toolbar.chooseOutputDevice": "Wiedergabegerät wählen",
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
"tabAudio.start": "Share tab or window audio into the voice channel (headphones avoid an echo)",
|
||||
"tabAudio.stop": "Stop sharing audio",
|
||||
"tabAudio.noAudio": "No audio was shared. In the picker, choose a tab or window and turn on its audio.",
|
||||
"tabAudio.silent": "The shared audio has been silent for 5 seconds. With \"system audio\" the browser only captures the Windows default playback device; music playing on another device doesn't come through.",
|
||||
"tabAudio.silent": "Nothing has come through from the shared audio for 5 seconds. System audio doesn't deliver sound on every Windows machine; share a browser tab instead (e.g. Spotify on the web or YouTube) with \"Share tab audio\" turned on.",
|
||||
"toolbar.muteSound": "Mute sound (deafen)",
|
||||
"toolbar.unmuteSound": "Unmute sound (undeafen)",
|
||||
"toolbar.chooseOutputDevice": "Choose output device",
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
"tabAudio.start": "صدای یک زبانه یا پنجره را در کانال صوتی پخش کن (با هدفون پژواک ایجاد نمیشود)",
|
||||
"tabAudio.stop": "توقف اشتراک صدا",
|
||||
"tabAudio.noAudio": "صدایی به اشتراک گذاشته نشد. در پنجره انتخاب، یک زبانه یا پنجره را انتخاب و صدای آن را روشن کنید.",
|
||||
"tabAudio.silent": "صدای اشتراکگذاشتهشده ۵ ثانیه است که بیصداست. با «صدای سیستم»، مرورگر فقط دستگاه پخش پیشفرض ویندوز را ضبط میکند؛ موسیقیای که روی دستگاه دیگری پخش شود منتقل نمیشود.",
|
||||
"tabAudio.silent": "۵ ثانیه است که از صدای اشتراکگذاشتهشده چیزی نمیرسد. صدای سیستم روی همهٔ رایانههای ویندوزی صدا نمیدهد؛ بهجای آن یک زبانهٔ مرورگر (مثلاً Spotify وب یا YouTube) را با روشن بودن «اشتراک صدای زبانه» به اشتراک بگذارید.",
|
||||
"toolbar.muteSound": "بیصدا کردن صدا (کر کردن)",
|
||||
"toolbar.unmuteSound": "فعال کردن صدا",
|
||||
"toolbar.chooseOutputDevice": "انتخاب دستگاه خروجی",
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
"tabAudio.start": "将标签页或窗口的声音共享到语音频道(戴耳机可避免回声)",
|
||||
"tabAudio.stop": "停止共享声音",
|
||||
"tabAudio.noAudio": "没有共享声音。请在选择窗口中选择标签页或窗口,并开启其声音。",
|
||||
"tabAudio.silent": "共享的声音已静音 5 秒。使用“系统音频”时,浏览器只录制 Windows 默认播放设备;在其他设备上播放的音乐不会被传送。",
|
||||
"tabAudio.silent": "共享的声音已 5 秒没有任何内容。系统音频并非在每台 Windows 电脑上都有声音;请改为共享浏览器标签页(例如网页版 Spotify 或 YouTube),并开启“共享标签页音频”。",
|
||||
"toolbar.muteSound": "关闭声音(拒听)",
|
||||
"toolbar.unmuteSound": "开启声音(取消拒听)",
|
||||
"toolbar.chooseOutputDevice": "选择输出设备",
|
||||
|
||||
+8
-2
@@ -169,12 +169,18 @@ export class MicCapture {
|
||||
this.extraPeak = Math.max(this.extraPeak, Math.abs(extra[i]));
|
||||
}
|
||||
}
|
||||
// AEC3's blocks make the two queues jitter against each other. Padding
|
||||
// a short extra queue with silence clicks; skip it once instead, which
|
||||
// leaves it a frame ahead from then on. Cap the lead to bound latency.
|
||||
if (this.pendingExtra.length > 4 * FRAME_SAMPLES) this.pendingExtra.splice(0, this.pendingExtra.length - 2 * FRAME_SAMPLES);
|
||||
while (this.pending.length >= FRAME_SAMPLES) {
|
||||
const frame = this.pending.splice(0, FRAME_SAMPLES);
|
||||
const extra = this.pendingExtra.splice(0, FRAME_SAMPLES);
|
||||
const extra = this.pendingExtra.length >= FRAME_SAMPLES ? this.pendingExtra.splice(0, FRAME_SAMPLES) : [];
|
||||
const int16 = new Int16Array(FRAME_SAMPLES);
|
||||
for (let i = 0; i < FRAME_SAMPLES; i++) {
|
||||
const clamped = Math.max(-1, Math.min(1, frame[i] + (extra[i] ?? 0)));
|
||||
// Shared music is mastered near full scale; at -6 dB it leaves room
|
||||
// for the voice on top instead of clipping.
|
||||
const clamped = Math.max(-1, Math.min(1, frame[i] + (extra[i] ?? 0) * 0.5));
|
||||
int16[i] = clamped < 0 ? clamped * 32768 : clamped * 32767;
|
||||
}
|
||||
this.onFrame(int16ToBase64(int16));
|
||||
|
||||
Reference in new issue
Block a user