Freak of Nature by Julia Crane
Donate Body to Science. Check.
When seventeen-year-old Kaitlyn checked the box, she never suspected she’d have her life–and her body–stolen from her. She awakens one day in a secret laboratory to discover that her body is now half-robot and is forced to hide her own secret: that she still has human emotions and a human mind. If the scientists who made her find out, they’ll erase what remains of who she was.
Kaitlyn finds an unlikely ally in Lucas, a handsome, brilliant scientist who can’t get over the guilt he feels knowing she was once a vibrant, beautiful young woman. He never expected a science project to affect him the way she does. As he tries to help her rediscover her past, he finds himself falling for the brave girl struggling to find her place and acceptance between the human and computer worlds.
The scene above that you spoiled is mentioned in this review.
It's all about her hiding and dealing with her new life when out of nowhere there's a rape going on. No clues or anything (which could've been included earlier in the book). The synopsis on goodreads says "*For mature teens due to some sexual content." Now, it says some sexual content, and earlier in the story, there was the prospect of sex, I figured that was it and would happen again and again until the lovebirds could finally get it done. Rather, Kaitlyn is remembering how she died to save a woman being raped. While this is very noble of her "some sexual content is not enough of warning when the book contains (while not too explicit) a rape scene and threats.
Found by searching for
site:goodreads.com "turned into a robot" memories