Working with afre_cleantext filter and G'MIC plugin

Most of the reference code is available in his gmic filter, called afre_cleantext, which is available here: gmic-community/afre.gmic at master · dtschump/gmic-community · GitHub

Have you tried it?