If after changing a dirty diaper and disposing of the diaper, there remains a foul odor, one needs to distance oneself far enough to where the odor ends, before reciting a Davar Shebikedushah. However, if the diaper is still in the room, one must distance oneself four amos from where the odor ends.
If there is a foul odor in a room, for example from the diaper that was changed in that room, and one sprayed an air freshener to block the smell, it is enough to distance oneself to where the odor cannot be smelled as long as the tangible source is no longer there. One who has difficulty smelling, for example one who is congested, should still keep to the above halachos, but in a scenerio where one is unable to, can recite a Davar Shebikedushah where they are.