You can walk (or cycle) this section of the Kennet and Avon canal in either direction. There’s a train station at Bradford-on-Avon and plenty of buses to Devizes. I’ve detailed the route from Bath to Bradford-on-Avon in this article.
In April 2021, I took the bus from Bath to Devizes (#272) and walked all the way back (around 37km). Definitely possible on a summer day when there is more light, with a lunch stop at Bradford-on-Avon (around 20km).
Devizes is a small town with plenty of places to get coffee and food. There are well-kept public toilets (20p in cash) sign-posted from the main square and on the way to the canalside where the Devizes Wharf has more amenities.