Section 12. Except as provided in section twenty-eight of chapter two hundred and eighteen and in section twenty of chapter two hundred and nineteen, if a husband is convicted of an assault upon his wife, the court may, in addition to the other penalties imposed, or in lieu thereof, order him to recognize with surety or sureties to keep the peace for any term of not more than two years, and may at any time revoke such order or reduce the amount required or order that the recognizance be taken without surety.