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
+25
-1
@@ -166,7 +166,31 @@ CORE_SCHEMA: dict[str, Any] = {'tau': {'default': 0.6, 'type': 'float', 'doc': '
|
||||
'storage_path': {'default': '', 'type': 'str'},
|
||||
'home_channel': {'default': '', 'type': 'str'},
|
||||
'reply_prefix': {'default': '', 'type': 'str'},
|
||||
'text_batch_delay': {'default': 0.8, 'type': 'float'}},
|
||||
'text_batch_delay': {'default': 0.8, 'type': 'float'},
|
||||
# Reply with the skill's result line only (drop queue/
|
||||
# urgency chatter and the `<skill>: ok —` wrapper).
|
||||
'result_only': {'default': True, 'type': 'bool'},
|
||||
# Transcribe Sideband push-to-talk voice messages
|
||||
# (FIELD_AUDIO) into commands and (when reply_with_voice)
|
||||
# answer a voice chat with a Piper voice reply. Needs only
|
||||
# faster-whisper (requirements/transcribe.txt) plus
|
||||
# piper-tts + PyAV (requirements/tts.txt) for replies,
|
||||
# not the microphone stack.
|
||||
'voice': {'enabled': {'default': False, 'type': 'bool'},
|
||||
'reply_with_voice': {'default': True, 'type': 'bool'},
|
||||
'max_speak_chars': {'default': 600, 'type': 'int'},
|
||||
'reply_bitrate': {'default': 24000, 'type': 'int'},
|
||||
'stt': {'model': {'default': 'base.en', 'type': 'str'},
|
||||
'device': {'default': 'cpu', 'type': 'str'},
|
||||
'compute_type': {'default': 'int8', 'type': 'str'},
|
||||
'language': {'default': 'en', 'type': 'str'}},
|
||||
'tts': {'voice': {'default': 'en_US-lessac-medium',
|
||||
'type': 'str'},
|
||||
'voice_dir': {'default': '', 'type': 'str'},
|
||||
'speaker_id': {'default': 0, 'type': 'int'},
|
||||
'length_scale': {'default': 1.0,
|
||||
'type': 'float'},
|
||||
'volume': {'default': 1.0, 'type': 'float'}}}},
|
||||
'voice': {'enabled': {'default': False, 'type': 'bool'},
|
||||
'chat_id': {'default': 'voice', 'type': 'str'},
|
||||
'display_name': {'default': 'voice', 'type': 'str'},
|
||||
|
||||
Reference in new issue
Block a user