Naprawa STT: pw-record zamiast parecord + SIGINT do poprawnego domknięcia WAV

This commit is contained in:
pali112 committed 2026-10-20 17:22:13 +02:00
1 parent d113e81506
commit 93b7a53432
1 file changed
+5 -3
+5 -3
View File
@@ -65,7 +65,7 @@ DEFAULT_CONFIG = {
"whisper_cli": "/usr/bin/whisper-cli",
"whisper_model": "/home/pali112/models/ggml-small.bin",
"whisper_language": "auto",
"record_cmd": ["parecord", "--format=s16le", "--rate=16000", "--channels=1"],
"record_cmd": ["pw-record", "--format=s16", "--rate=16000", "--channels=1"],
"piper": "/opt/piper-tts/piper",
"piper_model": "/home/pali112/.local/share/piper-voices/en_US-lessac-medium.onnx",
"play_cmd": ["aplay", "-q"],
@@ -558,7 +558,7 @@ class XSayATC:
return
import tempfile
self._record_file = tempfile.mktemp(suffix=".wav", prefix="xsayatc_")
cmd = list(self.config.get("record_cmd", ["parecord", "--format=s16le", "--rate=16000", "--channels=1"]))
cmd = list(self.config.get("record_cmd", ["pw-record", "--format=s16", "--rate=16000", "--channels=1"]))
cmd.append(self._record_file)
try:
self._record_proc = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
@@ -575,11 +575,13 @@ class XSayATC:
self._recording = False
if self._record_proc is not None:
try:
self._record_proc.terminate()
# SIGINT kaze pw-record poprawnie domknac plik WAV
self._record_proc.send_signal(2) # 2 = SIGINT
try:
self._record_proc.wait(timeout=3)
except Exception:
self._record_proc.kill()
self._record_proc.wait(timeout=2)
except Exception:
pass
self._record_proc = None