mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
Mic clicks as regular sounds, own clicks off by default
The two clicks now live in the sound settings (toggle, test, custom file, soundpack import via mic_click_on/off) instead of being fixed tones in the voice player. Own mic clicks start off. 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
97421ff2de
commit
341a1644a6
9 files changed
+49
-19
No files matched your search
+3
-12
@@ -447,25 +447,16 @@ export class AudioPlayer {
|
||||
|
||||
/** Plays a short sine-wave test tone through the same volume/output-device routing as voice playback. */
|
||||
playTestTone(): void {
|
||||
this.beep(440, 0.6, 0.3);
|
||||
}
|
||||
|
||||
/** Short tick when someone starts (higher) or stops (lower) talking. */
|
||||
playMicClick(start: boolean): void {
|
||||
this.beep(start ? 1400 : 900, 0.03, 0.15);
|
||||
}
|
||||
|
||||
private beep(freq: number, duration: number, volume: number): void {
|
||||
const osc = this.context.createOscillator();
|
||||
osc.type = "sine";
|
||||
osc.frequency.value = freq;
|
||||
osc.frequency.value = 440;
|
||||
const toneGain = this.context.createGain();
|
||||
toneGain.gain.value = volume;
|
||||
toneGain.gain.value = 0.3;
|
||||
osc.connect(toneGain);
|
||||
toneGain.connect(this.gain);
|
||||
const now = this.context.currentTime;
|
||||
osc.start(now);
|
||||
osc.stop(now + duration);
|
||||
osc.stop(now + 0.6);
|
||||
osc.onended = () => {
|
||||
osc.disconnect();
|
||||
toneGain.disconnect();
|
||||
|
||||
Reference in new issue
Block a user