Solution 1:

I’m adding this answer because no one seems to have used IPA, or explained the matter simply. The word has three standard pronunciations, which vary by context.

The definite article ‘the’ is normally pronounced /ðə/ before a consonant sound and /ði/ before a vowel sound. Neither of these is a stressed syllable.

However, it also has a ‘stressed’ pronunciation used for emphasis, which is always /ðiː/ no matter what sound should follow it. The vowel here is held longer than in the unstressed version.

That’s really all there is to it.

Solution 2:

If the following word starts with a vowel it's pronounced like 'thee'.

For other details I would recommend Pronunciation of the voiced & voiceless "TH" sound.