There is not an easy way to capture headphone button events that I can think of, though maybe with Objc. However ole had to remove the entitlement to sct like a music player, not sure if that affects headphone buttons too.. You could just use a ui.Button, thst calls speech.stop(). If you need to be able to pause and keep playing, you might need to say one sentance at a time, since there is not a way to tell where you stopped... though you will also have to have a tight loop looking for is_speaking, since there is no way to register a completion handler for each say.
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.