Not exactly in the spirit of advertising the use of public transport...... cycle?
This person is nothing if not innovative ... and came up with the idea of catching the 265 bus from place-of-work to Bath, and then the late 271 from Bath to Melksham.
22:30 Trowbridge (Centre) / 23:12 to 23:20 in Bath, 00:01 in Melksham. 91 minutes for a 10 minute rail journey. That's current - there are changes to the 265 on 23rd August and I don't know if the connection will still work.
Previous journey is at about 18:45 from person's place of work / 19:42 to 20:00 in Bath, 20:41 in Melksham. Better on Monday to Friday to catch the 19:38 train to Melksham at 19:47; no service after 18:38 from Trowbridge on Saturdays from next month, though.
P.S. Cycling from Hilperton to Semington in the dark along the road is something I would question on safety grounds; cycling along an unlit canal towpath (the alternative) is something I wouldn't recommend on the ground you would get very wet if you hit something in the dark and came off.