Skip to content

Add Python output modules - #1105

Open
daxmawal wants to merge 1 commit into
brailcom:masterfrom
daxmawal:python-module-foundations
Open

Add Python output modules#1105
daxmawal wants to merge 1 commit into
brailcom:masterfrom
daxmawal:python-module-foundations

Conversation

@daxmawal

@daxmawal daxmawal commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR is a follow-up to #1104 and adds reusable helpers for implementing Speech Dispatcher output modules in Python.
Disclosure: Codex assisted with code review and testing.

Follow-up work

Planned follow-up PRs will:

  1. Python output module protocol implementation (module_main and module_process) and server-side audio transport.
  2. add the Pocket TTS output module.
  3. implement the remaining features, including sound icons, STOP, PAUSE, and complete custom debug logging.

if cur_item != "log_level":
return -1

match = re.match(r"\s*([+-]?[0-9]+)", cur_value)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find equivalent to strtol()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can simply call int() and return -1 if an exception is caught

Comment thread src/modules/speechd_python_modules/module_readline.py
@daxmawal

Copy link
Copy Markdown
Contributor Author

The Python tests have been successfully run and are available here.

self.data = bytearray()
self.no_lf = 0

def module_readline(source=None, block=True):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, module_readline is already available in libspeechd_module, I'd say we can just use it instead of reimplementing it (and thus having to maintain both).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is different from module_strip_ssml, as module_readline is available under a BSD license while the existing implementation of module_strip_ssml is available under LGPL.

What I'm thinking is that the python module helper can leverage libspeechd_module to manage the protocol etc. and translate the eventual calls into python calls, plus some helpers to make things easier for module implementors.

CustomDebugFile = None


def module_loglevel_set(cur_item, cur_value):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this, however, we indeed want to have for module_process.c to call it

if Debug == 3:
Debug = 1
else:
Debug = 0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to mimic module_util's way of emitting debug information. Better use a pythonic way

@sthibaul

Copy link
Copy Markdown
Collaborator

Python output module protocol implementation (module_main and module_process)

As mentioned above, module_process can be taken from libspeechd_module. We can just make the python module expose the few C functions module_* functions to interact with it. That'll avoid having to maintain several implementations of the core protocol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants