On Windows there's the Speech Recognition API, which is very easy to use, as in a few function calls, and you're all set.
https://msdn.microsoft.com/en-us/library/jj127860.aspx
Otherwise, albeit slower, you can use Google Cloud Speech API, or IBM Watson, and Amazon's Alexa Voice Server to do the same with internet connection.
You can always redirect audio output into audio capture device (you can do that on windows with the audio loopback device, and most OSes support a way of doing this), in which case all the audio output of your computer, such as YouTube audio, can be captured by the said APIs.
Unfortunately I don't specifically know a dedicated application for this, but for Windows this might contain what you need.
https://www.microsoft.com/en-us/download/details.aspx?id=27224
Otherwise a bit of programming skill, it should be easy to do it — I would be surprise if no one hasn't yet.
An extensive list of speech recognition software, some of which may contain the ability to save text output to a file I found here:
https://en.wikipedia.org/wiki/Speech_recognition_software_for_Linux
and
https://en.wikipedia.org/wiki/List_of_speech_recognition_software