So let's start with the usual argument here that talking animals aren't on-topic, as established in the following meta discussion: Are anthropomorphic animals by themselves enough to deem a work fantasy?
Now let's look at the situation we have in The Jungle Book, mostly based on the Disney animated version.
When do talking animals make a work on-topic?
Their speaking was somehow fantastical to the other characters.
The talking rats in Ratatouille would certainly fall into the latter category. There's no specific evidence of how they became intelligent but it's clear from the scenes in the film that animal sentience certainly isn't a normal feature of that universe.
But what if animals aren't the ones that can talk to humans?
Mowgli is unique in the fact that HE can talk to animals. As far as we are concerned, animals can't talk to humans, only to Mowgli. It's clear the animals stay away from humans, because humans are dangerous to them. But if in-world they could simply walk up to humans and say "sup, don't shoot", the entire story of The Jungle Book wouldn't make any sense.
Also from my understanding of the book, the animals are actually nervous around Mowgli, because HE is weird to them.
Having a main character who can talk to animals seems pretty much in line with fantasy to me.