As we all know there are many homophones in the English language, for non-english speakers we might pose the same question "how can I understand which word they are trying to use?"
Did you bring her flowers?
Did you bring her flour?
Although they sound similar in daily conversation, but I believe I won't make you feel confused because they are used in different contexts, the same thing goes for pinyin, we won't misunderstand what you are trying to say normally, even they are the same Pinyin with the same tone.
If you bring your girlfriend flour, I would follow up with a question "Is she working in a bakery?" to avoid misunderstanding, right?