TTS: dwa głosy (PL gosia / EN ryan) wybierane po języku wypowiedzi
This commit is contained in:
1 parent
bf2eb1938a
commit
3f8f8bbe66
3 files changed
+25
-5
No files matched your search
@@ -100,7 +100,9 @@ DEFAULT_CONFIG = {
|
||||
"whisper_language": "auto",
|
||||
"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",
|
||||
"piper_model": "", # stary klucz (fallback); normalnie uzywa _pl / _en ponizej
|
||||
"piper_model_pl": "/home/pali112/models/pl_PL-gosia-medium.onnx",
|
||||
"piper_model_en": "/home/pali112/models/en_US-ryan-high.onnx",
|
||||
"play_cmd": ["pw-play"],
|
||||
"tts_enabled": True,
|
||||
}
|
||||
@@ -852,9 +854,22 @@ class XCoPilot:
|
||||
finally:
|
||||
self._speak_lock.release()
|
||||
|
||||
def _detect_lang(self, text):
|
||||
"""Zwraca 'pl' jesli tekst zawiera polskie znaki, inaczej 'en'."""
|
||||
if any(ch in text for ch in "ąćęłńóśźżĄĆĘŁŃÓŚŹŻ"):
|
||||
return "pl"
|
||||
return "en"
|
||||
|
||||
def _speak_locked(self, text):
|
||||
piper = self.config.get("piper", "/opt/piper-tts/piper")
|
||||
model = self.config.get("piper_model", "")
|
||||
# Wybierz glos wg jezyka wypowiedzi: pl -> gosia, en -> ryan.
|
||||
if self._detect_lang(text) == "pl":
|
||||
model = self.config.get("piper_model_pl") or self.config.get("piper_model", "")
|
||||
else:
|
||||
model = self.config.get("piper_model_en") or self.config.get("piper_model", "")
|
||||
if not model:
|
||||
xp.log("[XCoPilot] TTS: brak modelu piper (piper_model_pl/_en).")
|
||||
return
|
||||
import tempfile
|
||||
wav = tempfile.mktemp(suffix=".wav", prefix="xcopilot_tts_")
|
||||
env = self._clean_env()
|
||||
@@ -988,7 +1003,10 @@ class XCoPilot:
|
||||
_, self.config["voice_enabled"] = imgui.checkbox("Glos wlaczony (STT)", self.config["voice_enabled"])
|
||||
_, self.config["tts_enabled"] = imgui.checkbox("Odczytywanie odpowiedzi (TTS)", self.config["tts_enabled"])
|
||||
_, self.config["whisper_model"] = imgui.input_text("Model whisper", self.config["whisper_model"], 512)
|
||||
_, self.config["piper_model"] = imgui.input_text("Model piper", self.config["piper_model"], 512)
|
||||
_, self.config["piper_model_pl"] = imgui.input_text(
|
||||
"Glos PL (gosia)", self.config["piper_model_pl"], 512)
|
||||
_, self.config["piper_model_en"] = imgui.input_text(
|
||||
"Glos EN (ryan)", self.config["piper_model_en"], 512)
|
||||
|
||||
imgui.separator()
|
||||
imgui.text("System prompt (osobowosc i format JSON):")
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
"whisper_language": "auto",
|
||||
"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",
|
||||
"piper_model_pl": "/home/pali112/models/pl_PL-gosia-medium.onnx",
|
||||
"piper_model_en": "/home/pali112/models/en_US-ryan-high.onnx",
|
||||
"play_cmd": ["pw-play"],
|
||||
"tts_enabled": true
|
||||
}
|
||||
Reference in new issue
Block a user