The 9th level spell Shapechange gives you many of the traits of the creature who's form you assume:
... You also retain all of your skill and saving throw proficiencies, in addition to gaining those of the creature. If the creature has the same proficiency as you and the bonus listed in its statistics is higher than yours, use the creature's bonus in place of yours.
You retain the benefit of any features from your class, race, or other source and can use them, provided that your new form is physically capable of doing so. You can't use any special senses you have (for example, darkvision) unless your new form also has that sense. You can only speak if the creature can normally speak. - (PHB 275)
Speech seems to be tied to the creature's ability somewhat, but it only speaks about proficiencies you get from that form. In normal English we speak of being proficient in a language, so this could be considered to include language "proficiencies" (though they're not explicitely referred to as such in the PHB to my knowlege). Features (of which languages otherwise might be considered a member) only appear to come from your own sources.
This answer suggests that True Polymorph might work, though it trades some of its power for the range of 30 ft instead of Self. On the other hand, it makes no hard claims that this would work RAW. Not surprisingly, its question is related - if Shapechange works, it's a valid answer. If not, other solutions (which obviously are) would be interesting to include here.
Critical Role came up against this, and for interest Matt Mercer's ruling is below (spoiler):
In Vox Machina Go to Hell Matt Mercer ruled that Shapechange would not grant the languages known by the assumed form.