Yes this works for the secret and deep speech temporarily
Once you have occupied the humanoid form of the intellect devourer, you gain it's knowledge and deep speech:
It knows everything the creature knew, including spells and languages.
However, you would lose access to deep speech if you exit the body and dispel true polymorph as you would no longer have the Body Thief feature. You could likely memorize a portion of the language but memorizing the entire language would essentially be training for that language.
That said, the secret would be easy to either memorize or just communicate to the party once you have stolen the intellect devourer's polymorphed body.
But why go to all this trouble
All that said, it would be considerably easier to aquire the secret and deep speech a different way.
The 2nd level detect thoughts thoughts spell could extract the secret without a save in some cases (like if you knew deep speech and were interrogating it):
You initially learn the surface thoughts of the creature - what is most on its mind in that moment... Questions verbally directed at the target creature naturally shape the course of its thoughts, so this spell is particularly effective as part of an interrogation.
...or in the worst case, on a failed wisdom save:
If you probe deeper, the target must make a Wisdom saving throw. If it fails, you gain insight into its reasoning (if any), its emotional state, and something that looms large in its mind (such as something it worries over, loves, or hates).
You could get deep speech just by training:
You can spend time between adventures learning a new language or training with a set of tools. Your DM might allow additional training options.
First, you must find an instructor willing to teach you. The DM determines how long it takes, and whether one or more ability checks are required.
The training lasts for 250 days and costs 1 gp per day. After you spend the requisite amount of time and money, you learn the new language or gain proficiency with the new tool.
...or via a combination of the 1st level comprehend languages and/or the 3rd level tongues spell if you need it in a pinch.