IPA is a representation of sound; therefore "transforming to IPA" implies converting text to sound. That task is harder than it seems, because writing systems are underdetermined – they don't include all the relevant information for pronunciation. You need language-specific knowledge to pronounce things:
Just compare heart, beard, and heard,
Dies and diet, lord and word,
Sword and sward, retain and Britain.
(Mind the latter, how it's written.)
Now I surely will not plague you
With such words as plaque and ague.
But be careful how you speak:
Say break and steak, but bleak and streak;
Cloven, oven, how and low,
Script, receipt, show, poem, and toe.
And even dictionaries aren't enough, since sounds may change in context (British speakers may say fear as /fiə/, but fear of as /fiəɹɒv/).
There are nonetheless attempts at automatically converting text to sound (from which you can derive proper IPA). These are called text-to-speech (TTS) systems. They aren't perfect, but are getting better these days (as you must have noticed if you ever pressed "play" on Google Translate).
Your best bet at converting text from a language into IPA is to look for a) a TTS system for that language, which b) has the option to output as IPA. For example, this is the Mandarin Chinese output of the TTS system espeak in my Linux machine:
$ espeak --ipa -v zh 你好
nˈiɜ xˈɑu2
$ espeak --ipa -v zh 知者樂水,仁者樂山.
ts.ˈi.5 ts.ˈo-2 lˈə5 s.wˈei2
əː1 ts.ˈo-2 lˈə5 s.ˈa5n
Notice that the espeak
output has some idiosyncrasies; it marks stress before vowels, but in the case of Chinese this feature is pointless/a bug; it marks so-called "retroflex" (backed) sibilants with a .
, rather than IPA /ʂ/ etc.; and it uses pīnyīn tone numbers, rather than IPA tone marks. These could be easily solved in post-processing. More problematic is the fact that TTS isn't perfect, and errors may creep in (/əː1/?). I find it's generally better to try and find TTS systems specifically made for that language, rather than broad ones like espeak
.