I'm having the same issue on my Nexus 6p. Here's my experience:
When the issue mysteriously presents itself, my alarms don't have sound, my timers don't have sound, playing videos through my media app gives me an error claiming the app cannot play that file type, playing music doesn't work, YouTube videos don't have sound, my phone doesn't make the little blip noise when I lock and unlock it... Basically sound doesn't work on my phone. Period.
As a PC technician (but not an Android expert) I have, of course, instantly deduced that turning it off and on again fixes it. But it happens here and there, seemingly at random. I can always tell when my alarm won't work by listening for the blip sound when I lock my phone for the night.
I have a weird lingering feeling that this is somehow linked to Google Now's "Ok Google" detection. I think it happens as I use the voice detection more frequently. But I may be imagining correlation where there is none. It's hard to say since I have never directly seen what straight up cause.
Whatever the case, this is certainly not the fault of any single app, this looks to me like a bug in the OS.
I just updated to Nougat 7.1.1. No issues yet since the update. I saw nothing mentioning this issue in the patch notes, but I'm crossing my fingers that it got fixed somehow.