As a rule of thumb, the prefix ex- is pronounced with /ks/ when the prefix is stressed.:
When this prefix is not stressed, then if the first sound in the root (the part after the prefix) begins with a voiced sound, the prefix will be pronounced with /gz/:
This is still true, of course if the prefix is followed by a silent /h/ in the writing. In this case of course, the first sound in the root is a vowel sound:
If the prefix is followed by an unvoiced sound, then it will be pronounced with /ks/
- ex'pect /ɪkˈspekt/
- ex'tol /ɪkˈstəʊl/
- ex'hale /eks'heɪl/
- ex'ceed /ɪkˈsiːd/
- ex'foliate /eksˈfəʊlieɪt/
In the words above we see roots beginning with the following voiceless sounds respectively /p, t, h, s, f/ and so the prefix used /ks/ instead of /gz/.
There is a different prefix in English exo- meaning 'outer' or 'outside'. The meaning is similar to ex- which tends to mean 'out of' or 'from'. The prefix exo- is always pronounced with /ks/. It is a Greek prefix. Another Greek prefix, hex(a), meaning 'six', is also pronounced with /ks/:
X at the end of a word nearly always represents the sounds /ks/.
Very few words in English begin with X. Those that do are mostly from Greek and tend to be pronounced with /z/:
- xanthar gum