Why are nitriles less basic than amides?

Like nitriles have a localised lone pair which amides do not have, as their lone pair is delocalised and still amides are more basic. Why?
I could not find any satisfactory explanation so please explain in detail.


