lxmf: Sideband voice messages (transcribe + Piper voice replies)
The LXMF gateway now handles Sideband push-to-talk voice messages end to end. Inbound: a PTT message carries its audio in LXMF.FIELD_AUDIO (`[audio_mode, bytes]`); `lxmf_transport.parse_audio_field` normalizes it and the adapter transcribes it into an ordinary command when `gateway.lxmf.voice.enabled` is set. HQ Opus/OGG goes through faster-whisper (requirements/transcribe.txt); non-HQ Codec2 through the optional pycodec2 bindings (requirements/codec2.txt). No microphone stack is needed. Outbound: a chat that last messaged by voice is answered with a synthesized voice message when `gateway.lxmf.voice.reply_with_voice` is on (the default). `voice_transport.build_synthesizer` speaks the reply with Piper and `voice_transport.pcm_to_opus_ogg` encodes it to OGG/Opus (48 kHz, PyAV's libopus); `lxmf_transport.audio_fields` attaches it as a Sideband HQ PTT message, with the reply text as the content so a text-only client still sees it. The reply mode follows the chat's most recent inbound message. A missing synthesizer or any synthesis/encode failure is traced and the reply falls back to text. Deps: requirements/tts.txt (piper-tts + PyAV), still no microphone. Also make LXMF replies result-only (`LxmfAdapter.result_only`, overridable via `gateway.lxmf.result_only: false`): send the skill's result line, dropping scheduler bookkeeping and the `<skill>: ok —` wrapper. Wiring: new config keys under `gateway.lxmf` (result_only) and `gateway.lxmf.voice` (reply_with_voice, max_speak_chars, reply_bitrate, tts); regenerated config.example.json; the setup interview asks how to handle voice messages and the install plan adds `install_lxmf_tts` (bootstrap installs requirements/tts.txt and downloads the reply voice); cli anchors the LXMF voice_dir to .runtime/voice/tts. Tests cover the audio field shape, the outbound queue, the adapter's voice-chat tracking and synthesis fallbacks, result-only routing, the synthesis/encode helpers, and the setup plan. Docs updated.
This commit is contained in:
1 parent
b1a7bfd272
commit
ed894bd329
21 files changed
+1804
-78
No files matched your search
@@ -87,6 +87,7 @@ def test_minimum_plan_installs_nothing_heavy():
|
||||
assert plan["install_simplex_forward"] is False
|
||||
assert plan["install_browser"] is False
|
||||
assert plan["install_voice"] is False
|
||||
assert plan["install_transcribe"] is False
|
||||
assert plan["packs"] == ["essentials"]
|
||||
assert plan["pack_requirements"] == []
|
||||
|
||||
@@ -177,6 +178,41 @@ def test_gateway_platforms_exclude_voice():
|
||||
assert plan["install_gateway_service"] is True
|
||||
|
||||
|
||||
def test_lxmf_voice_opts_into_transcription_dep():
|
||||
answers = Answers(gateways=["lxmf"], lxmf_voice=True)
|
||||
config = build_config(answers, _packs())
|
||||
assert config["gateway"]["lxmf"]["voice"]["enabled"] is True
|
||||
assert config["gateway"]["lxmf"]["voice"]["reply_with_voice"] is True
|
||||
assert validate_config(config, _packs()) == []
|
||||
|
||||
plan = build_plan(answers, _packs())
|
||||
assert plan["install_transcribe"] is True
|
||||
# A voice reply also pulls the Piper TTS deps.
|
||||
assert plan["install_lxmf_tts"] is True
|
||||
# The rerun path re-derives the same plan from the written config.
|
||||
assert plan_from_config(config, _packs())["install_transcribe"] is True
|
||||
assert plan_from_config(config, _packs())["install_lxmf_tts"] is True
|
||||
|
||||
|
||||
def test_lxmf_voice_transcribe_only_skips_tts_dep():
|
||||
answers = Answers(gateways=["lxmf"], lxmf_voice=True, lxmf_voice_reply=False)
|
||||
config = build_config(answers, _packs())
|
||||
assert config["gateway"]["lxmf"]["voice"]["enabled"] is True
|
||||
assert config["gateway"]["lxmf"]["voice"]["reply_with_voice"] is False
|
||||
plan = build_plan(answers, _packs())
|
||||
assert plan["install_transcribe"] is True
|
||||
assert plan["install_lxmf_tts"] is False
|
||||
assert plan_from_config(config, _packs())["install_lxmf_tts"] is False
|
||||
|
||||
|
||||
def test_lxmf_without_voice_does_not_install_transcription():
|
||||
answers = Answers(gateways=["lxmf"])
|
||||
config = build_config(answers, _packs())
|
||||
assert config["gateway"]["lxmf"]["voice"]["enabled"] is False
|
||||
assert build_plan(answers, _packs())["install_transcribe"] is False
|
||||
assert build_plan(answers, _packs())["install_lxmf_tts"] is False
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Interview branching
|
||||
# --------------------------------------------------------------------------- #
|
||||
@@ -201,6 +237,7 @@ def test_interview_collects_authoring_endpoints_and_packs():
|
||||
"bob", # nextcloud username
|
||||
"pw", # nextcloud app password
|
||||
"b", # gateways: lxmf
|
||||
"3", # lxmf voice: transcribe + reply with voice
|
||||
"Europe/Paris", # timezone
|
||||
]
|
||||
)
|
||||
@@ -223,6 +260,8 @@ def test_interview_collects_authoring_endpoints_and_packs():
|
||||
assert answers.packs == ["essentials", "simplex", "nextcloud"]
|
||||
assert answers.nextcloud_url == "https://nc.example"
|
||||
assert answers.gateways == ["lxmf"]
|
||||
assert answers.lxmf_voice is True
|
||||
assert answers.lxmf_voice_reply is True
|
||||
assert answers.timezone == "Europe/Paris"
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user