The Queen made an impromptu speech during a tour of a hospice in Swindon.