I'd like to have a function in Python for splitting a given string containing pinyin into its syllables. The following two code blocks show how the function is intended to work.
tàngsuǒ débùchángshī fēngtǔrénqíng huǎngrán dà wù
tàng suǒ fēng tǔ rén qíng dé bù cháng shī huǎng rán dà wù
The function should support pinyin of all Chinese characters. I emphasize this because I have noticed that some software that input pinyin can't type the syllables shown in the code block below.
shài hūlüè ǹg ang hng
shài hū lüè ǹg ang hng
For the record, I'm considering the pinyin that is taught in the HSK Standard Course book series (i.e. pinyin of Standard Mandarin).