A method for controlling a turbomachine comprising a fan positioned upstream of a gas generator and delimiting a primary airflow and a secondary airflow, the primary airflow passing through said gas generator which comprises a low-pressure compressor, a high-pressure compressor, a combustion chamber, a high-pressure turbine and a low-pressure turbine, said low-pressure turbine being connected to said low-pressure compressor by a low-pressure rotation shaft and said high-pressure turbine being connected to said high-pressure compressor by a high-pressure rotation shaft, the turbomachine comprising an electric motor forming a torque injection device on the high-pressure rotation shaft, method wherein a fuel flow set point Q CMD in the combustion chamber and a torque set point TRQ CMD provided to the electric motor are determined, the control method comprising: • a step of implementing a first fuel regulation loop in order to determine the fuel flow set point Q CMD comprising: i. a step of detecting a speed transient intent TopAccel, TopDecel as a function of a difference between a current speed NH and a determined set point speed NH CONS, ii. a step of determining a transient speed set point NHTrajAccelCons, NHTrajDecelCons, iii. a step of determining a fuel correction quantity ΔQ CMD as a function of the transient speed set point NHTrajAccelCons, NHTrajDecelCons; and iv. a step of determining the fuel flow set point Q CMD as a function of the fuel correction quantity ΔQ CMD • a step of implementing a second torque regulation loop in order to determine the torque set point TRQ CMD comprising i. a step of determining a torque correction quantity ΔTRQ CMD as a function of the transient speed set point NHTrajAccelCons, NHTrajDecelCons, and ii. a step of determining the torque set point TRQ CMD as a function of the torque correction quantity ΔTRQ CMD. • a step of implementing a first fuel regulation loop in order to determine the fuel flow set point Q CMD comprising: i. a step of detecting a speed transient intent TopAccel, TopDecel as a function of a difference between a current speed NH and a determined set point speed NH CONS, ii. a step of determining a transient speed set point NHTrajAccelCons, NHTrajDecelCons, iii. a step of determining a fuel correction quantity ΔQ CMD as a function of the transient speed set point NHTrajAccelCons, NHTrajDecelCons; and iv. a step of determining the fuel flow set point Q CMD as a function of the fuel correction quantity ΔQ CMD i. a step of detecting a speed transient intent TopAccel, TopDecel as a function of a difference between a current speed NH and a determined set point speed NH CONS, ii. a step of determining a transient speed set point NHTrajAccelCons, NHTrajDecelCons, iii. a step of determining a fuel correction quantity ΔQ CMD as a function of the transient speed set point NHTrajAccelCons, NHTrajDecelCons; and iv. a step of determining the fuel flow set point Q CMD as a function of the fuel correction quantity ΔQ CMD • a step of implementing a second torque regulation loop in order to determine the torque set point TRQ CMD comprising i. a step of determining a torque correction quantity ΔTRQ CMD as a function of the transient speed set point NHTrajAccelCons, NHTrajDecelCons, and ii. a step of determining the torque set point TRQ CMD as a function of the torque correction quantity ΔTRQ CMD. i. a step of determining a torque correction quantity ΔTRQ CMD as a function of the transient speed set point NHTrajAccelCons, NHTrajDecelCons, and ii. a step of determining the torque set point TRQ CMD as a function of the torque correction quantity ΔTRQ CMD.