fixed bug: gain should now correctly affect whisper models as intended
This commit is contained in:
61
murmur.py
61
murmur.py
@@ -737,10 +737,69 @@ class DeviceAPI:
|
|||||||
self.recorder.stop_and_save()
|
self.recorder.stop_and_save()
|
||||||
return False # now "not recording"
|
return False # now "not recording"
|
||||||
|
|
||||||
|
def _find_matching_input_for_output(self) -> Optional[int]:
|
||||||
|
"""
|
||||||
|
Versucht, für das aktuell gewählte Output-Device (self.output_index)
|
||||||
|
ein gleichnamiges Input-Device zu finden (typisch bei Loopback-Treibern).
|
||||||
|
Gibt den Input-Device-Index zurück oder None.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
if self.output_index is None or self.output_index < 0:
|
||||||
|
return None
|
||||||
|
devs = sd.query_devices()
|
||||||
|
out_name = devs[self.output_index]["name"]
|
||||||
|
|
||||||
|
# 1) exakter Name
|
||||||
|
for i, d in enumerate(devs):
|
||||||
|
if d.get("max_input_channels", 0) > 0 and d["name"] == out_name:
|
||||||
|
return i
|
||||||
|
|
||||||
|
low = out_name.lower()
|
||||||
|
|
||||||
|
# 2) case-insensitive exakter Name
|
||||||
|
for i, d in enumerate(devs):
|
||||||
|
if d.get("max_input_channels", 0) > 0 and d["name"].lower() == low:
|
||||||
|
return i
|
||||||
|
|
||||||
|
# 3) Prefix-Match (robuster für unterschiedliche Bezeichnungen)
|
||||||
|
for i, d in enumerate(devs):
|
||||||
|
if d.get("max_input_channels", 0) > 0 and d["name"].lower().startswith(low):
|
||||||
|
return i
|
||||||
|
|
||||||
|
return None
|
||||||
|
except Exception:
|
||||||
|
return None
|
||||||
|
|
||||||
def _start_stt(self):
|
def _start_stt(self):
|
||||||
|
"""
|
||||||
|
Startet den STT-Client-Prozess.
|
||||||
|
Neu: bevorzugt den POST-GAIN Loopback als STT-Quelle, wenn ein passendes
|
||||||
|
Input-Device zum aktuell gewählten Output-Device existiert. Fallback: raw input.
|
||||||
|
"""
|
||||||
|
# Standard: rohes Eingabegerät
|
||||||
|
capture_index = self.input_index
|
||||||
|
|
||||||
|
# Versuch: passendes Loopback-Input zu aktuellem Output finden
|
||||||
|
loop_idx = self._find_matching_input_for_output()
|
||||||
|
if loop_idx is not None:
|
||||||
|
capture_index = loop_idx
|
||||||
|
try:
|
||||||
|
devs = sd.query_devices()
|
||||||
|
print(f"[ASR] capturing POST-GAIN from loopback input #{loop_idx} ({devs[loop_idx]['name']})",
|
||||||
|
file=sys.stderr)
|
||||||
|
except Exception:
|
||||||
|
print(f"[ASR] capturing POST-GAIN from loopback input #{loop_idx}", file=sys.stderr)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
devs = sd.query_devices()
|
||||||
|
print(f"[ASR] capturing RAW from input #{self.input_index} ({devs[self.input_index]['name']})",
|
||||||
|
file=sys.stderr)
|
||||||
|
except Exception:
|
||||||
|
print(f"[ASR] capturing RAW from input #{self.input_index}", file=sys.stderr)
|
||||||
|
|
||||||
self.client_proc = Process(
|
self.client_proc = Process(
|
||||||
target=_stt_worker,
|
target=_stt_worker,
|
||||||
args=(self.input_index, self.queue, self.translate_enabled, self.src_lang_id),
|
args=(capture_index, self.queue, self.translate_enabled, self.src_lang_id),
|
||||||
daemon=True
|
daemon=True
|
||||||
)
|
)
|
||||||
self.client_proc.start()
|
self.client_proc.start()
|
||||||
|
|||||||
Reference in New Issue
Block a user