Was this on an Airbus?
The first high-pitched noise you hear is an electric motor that closes the cargo door but since you say it was near take-off I'd suggest it's the power transfer unit that you are hearing.
Originally Posted by Wikipedia
In aviation, a
power transfer unit (PTU) is a device that transfers
hydraulic power from one of an aircraft's hydraulic systems to another in the event that second system has failed or been turned off.
[1]The PTU is used when, for example, there is right hydraulic system pressure but no left hydraulic system pressure. In this example, the PTU transfers hydraulic power from the right hydraulic system to the left hydraulic system. A PTU consists of a hydraulic motor paired with a hydraulic pump via a shaft.
[2] As the connection is purely mechanical, there is no intermixing of
hydraulic fluid between the left and right hydraulic systems during PTU operation.
This can either sound like an angry, barking dog or a whine depending on hydraulic loads.