This sounds a lot like the problem I had with my 95 accord a couple years ago.
My speedometer would read around 20mph reguardless of what speed I was actually going, sometimes it would start working again randomly and then randomly it would stop working again. When the speedometer wasn’t working neither would the odometer but the cruise control still worked.
I searched around online and found where everyone kept talking about the VSS (vehicle speed sensor) for a non working speedometer issue and so I decided to replace it. That didn’t change anything, the speedometer still worked and didn’t work seemingly randomly.
Then I found a post online where someone mentioned that if the cruise control works than the VSS must be working (not sure if this is true but it made sense to me) and if that was the case than the speedometer problem was the unit itself in the instrument cluster. So I picked up an instrument cluster from a junk yard for $50 and swapped it out. That fixed it and I haven’t had an issue since. I was able to get a cluster that had milleage on the odometer very close to what my car had so that worked out well.
I’ve heard that you can pull the cluster apart and change out just the speedometer leaving the odometer in place so you don’t loose your original milleage but I didn’t try it.