Generalized inflation with a gravitational wave background