Yes, you can do that. Take care that whole spices don’t burn. Keep flame low while sauteeing them. The smokey taste & flavour will get into the final dish if you burn them, making it hard to remove.