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 smoothed first, and then the smoothed time envelopes of the high frequency signal of the current frame are scaled; or wherein the time envelopes of the high frequency signal of the current frame are scaled first, and then the scaled time envelopes of the high frequency signal of the current frame are smoothed; and quantizing and encoding the time envelopes of the high frequency signal of the current frame 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; 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 is the frequency envelopes 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 smoothed first, and then the smoothed time envelopes of the high frequency signal of the current frame are scaled; or wherein the time envelopes of the high frequency signal of the current frame are scaled first, and then the scaled time envelopes of the high frequency signal of the current frame are smoothed; and quantizing and encoding the time envelopes of the high frequency signal of the current frame 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; 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 is the frequency envelopes of the high frequency signal of the current frame.