Machine learning algorithms for forming Homophones from input dataset word
I have very limited knowledge about homophones generator.
I feel to make a homophone detector, one should focus more on the phonetics of the word rather than the spellings.

try to make a word-phonetics list dataset and then train a model.
focus on Levenstein/fuzzy/edit distance between the phonetics of words.

eg - two, too and to all have the same phonetics - T UW .
try this website to find phonetics - http://www.speech.cs.cmu.edu/cgi-bin/cmudict?in=to
they have already mapped the words and phonetics.
I think finding homophones in non-english languages would be an uphill task.