The law also would allow anyone to sue a Texas abortion provider or anyone who helped someone get an abortion for as much as US$10,000 ($13,800).
The law would take effect in September, but federal courts have mostly blocked states from enforcing similar measures.
"I have dreams and hopes and ambition. Every girl graduating today does. We have spent our entire lives working towards our future, and without our input and without our consent, our control over that future has been stripped away from us. I am terrified that if my contraceptives fail, I am terrified that if I am raped, then my hopes and aspirations and dreams and efforts for my future will no longer matter. I hope that you can feel how gut-wrenching that is, I hope that you can feel how dehumanising it is, to have the autonomy over your own body taken from you," she said.
Smith, who plans to study the music business at the University of Texas at Austin, said Wednesday that she had already submitted her original speech to school officials and was trying to finish an end-of-year project in the school's music room when she decided to scrap that speech.
"I couldn't keep my mind on the project. My mind kept wandering to the 'heartbeat bill' and what it meant. So, I started making some notes," she told The Associated Press.
Smith said she expected to have her microphone cut off (it wasn't) or to have her diploma withheld (it wasn't but she was told later it was considered). And she was stunned by the response to her message.
"I thought it would die right there," she said. But she saw tears in her audience midway through the speech. In the days since, video of her address posted on social media and retweeted broadly has drawn kudos from comedian Sarah Silverman, who tweeted, "Brave," and former Democratic presidential nominee Hillary Clinton, who tweeted: "This took guts. Thank you for not staying silent, Paxton."
The Richardson Independent School District, of which Lake Highlands is part, was less enthusiastic. In a statement, it said it would review student speech protocols before next year's graduation ceremonies.
"The content of each student speaker's message is the private, voluntary expression of the individual student and does not reflect the endorsement, sponsorship, position or expression of the District or its employees," it said.