A method of encoding a high frequency signal relating to bandwidth expansion in speech encoding and audio encoding, the method comprising: determining a signal class of a high frequency signal of a current frame; and smoothing and scaling time envelopes of the high frequency signal of the current frame to obtain time envelopes of the high frequency signal of the current frame that require to be encoded when the high frequency signal of the current frame is a NON-TRANSIENT signal and a high frequency signal of the previous frame is a TRANSIENT signal; wherein the time envelopes of the high frequency signal of the current frame are scaled by decreasing the time envelopes of all the sub-frames of the current frame by a certain number of multiple; quantizing and encoding the time envelopes that require to be encoded, and frequency information and signal class information of the high frequency signal of the current frame, wherein the signal class information of a TRANSIENT signal is used when the signal class information of the high frequency signal of the current frame is quantized and encoded; quantizing and encoding the time envelopes, the frequency information, and the signal class information of the high frequency signal of the current frame when the high frequency signal of the current frame is a TRANSIENT signal; and quantizing and encoding the frequency information and the signal class information of the high frequency signal of the current frame when both the high frequency signal of the current frame and the high frequency signal of the previous frame are NON-TRANSIENT signals; wherein the frequency information of the high frequency signal of the current frame includes at least one of the following: frequency envelopes of the high frequency signal of the current frame, global energy information of the high frequency signal of the current frame, and amplitude information of the high frequency signal of the current frame. determining a signal class of a high frequency signal of a current frame; and smoothing and scaling time envelopes of the high frequency signal of the current frame to obtain time envelopes of the high frequency signal of the current frame that require to be encoded when the high frequency signal of the current frame is a NON-TRANSIENT signal and a high frequency signal of the previous frame is a TRANSIENT signal; wherein the time envelopes of the high frequency signal of the current frame are scaled by decreasing the time envelopes of all the sub-frames of the current frame by a certain number of multiple; quantizing and encoding the time envelopes that require to be encoded, and frequency information and signal class information of the high frequency signal of the current frame, wherein the signal class information of a TRANSIENT signal is used when the signal class information of the high frequency signal of the current frame is quantized and encoded; quantizing and encoding the time envelopes, the frequency information, and the signal class information of the high frequency signal of the current frame when the high frequency signal of the current frame is a TRANSIENT signal; and quantizing and encoding the frequency information and the signal class information of the high frequency signal of the current frame when both the high frequency signal of the current frame and the high frequency signal of the previous frame are NON-TRANSIENT signals; wherein the frequency information of the high frequency signal of the current frame includes at least one of the following: frequency envelopes of the high frequency signal of the current frame, global energy information of the high frequency signal of the current frame, and amplitude information of the high frequency signal of the current frame.