We cared for a feral cat who was exactly the same way...the sweetest angel most of the time, but then out of the blue he would attack so violently that I had to go to the doctor for a tetanus shot and antibiotics. We named him Spike The Killer Cat From Hell. I will share what seemed to work for Spike.
First, as Frannie said, take your girl to the vet. It is likely that she has some sort of medical problem that is causing this behavior.
If it is not medical, then try this....
Talk to your vet about putting your girl on Prozac or St. John's Wort. Do not use valium as it may make her more aggressive and will cause her to be drunk and woozy. The St. John's Wort is best (if you can find the liquid) because it has no uncomfortable side effects (Prozac usually causes a queezy tummy and general yucky feelings for a few weeks, though these side effects typically go away fairly quickly). Note that it may take up to three weeks before these medications kick in AND note that you MUST give the meds to her EVERY DAY.
But....don't stop with the medication. You also need to modify her behavior -- that is, you need to help her learn that attacking is not acceptable.
In order to modify her behavior you need to follow the following steps:
1. Most importantly...learn her pre-attack signals. All cats will do some specific behavior right before an attack. Some cats twitch their tails quickly, some lay back or perk forward their ears, some make a little growl, and almost all will dilate their eyes just before an attack. Watch carefully to see what your cat does before an attack. Since she attacks when you are sleeping I strongly encourage you to keep her out of your room (or in the cage) during this process.
2. Now that you know what she does immediately before an attack, you will have to keep a careful eye on her whenever she is around. The very instant you see her do her pre-attack behavior IMMEDIATELY grab her by the scruff of the neck (she can't attack if you have her firmly by the scruff) and then put your other hand under her back legs. Carry her with all of her weight on your hand under her legs -- Although you still have one hand holding the scruff, all weight should be on her back legs. Now GENTLY toss her in the bathroom. (PLEASE just drop her into the bathroom far enough away from the door that she does not immediately run back out and attack -- don't throw her in.)
3. Leave her in the bathroom for no longer than five minutes...just long enough to get out of attack mode.
4. Finally, keep a very careful eye out to see what kind of things are going on around her when she attacks. It could be that she does this every time a cat walks outside the window. Or, it could be in response to a noisy car or motorcycle going by. Or..it may even be something like the heater turning on or some other sound that bothers her. If you can figure out what triggers the attacks, then you can change things so that she is no longer bothered by whatever is bothering her.
This will take a lot of patience and persistence. I wish you much luck!