Idea #1 – This discussion of ways to conditionally include code on different platforms seems like it might have some ideas you could use.
Idea #2 – Is this for AnkiDroid or AnkiMobile? In AnkiDroid, have you tried using the legacy Android-specific <tts> tags? AnkiDroid User Manual
Idea #3 – You haven’t posted your TTS code. What happens if you use a TTS language/voice that only exists on that device, and no fallback voice? Field Replacements - Anki Manual