Hillary Clinton struck a balance Friday as she addressed thousands of African American churchgoers, decrying both the recent fatal shootings of black men by police and the sniper attack that killed five officers in Dallas.

Clinton called the Dallas deaths "vicious and appalling" while telling a convention of African Methodist Episcopal Church members that "implicit bias" exists in how police deal with black people.

"What can leaders and people of faith say about events like these? It's hard to even know where to start," Clinton said. "For now, let's focus on what we already know deep in our hearts. We know there is something wrong with our country. There is too much violence. Too much hate. Too much senseless killing. And too many people who are dead who shouldn't be."

Clinton said she would, if elected president, include in her first federal budget money to train police officers in how to deal with all communities, calling it a "national priority."

She also praised the Dallas officers who came under fire while patrolling and protecting a peaceful protest sparked by two recent police shootings of African American men in Baton Rouge, La., and near St. Paul, Minn.

"Remember what they were doing? They were protecting a peaceful march," Clinton said. "There is nothing more vital to democracy than that. And they died for that."

Clinton spoke to an appreciative, if restrained, audience at the Pennsylvania Convention Center, where the African Methodist Episcopal Church is hosting its 50th Quadrennial Session of its General Conference. The conference drew an estimated 30,000 church members. Mother Bethel A.M.E. Church, founded in 1787 in Philadelphia, was the first outpost for the church.

As Clinton spoke, protesters decrying the shootings by police filled the streets just blocks from the convention hall.

The conference's organizers said businessman Donald Trump, the presumptive Republican nominee, had also been invited to speak. A conference spokeswoman was uncertain if Trump's campaign, which canceled events Friday in the shootings' aftermath, had replied to the invitation.

Clinton, too, canceled an appearance Friday in Scranton, where she had been scheduled to campaign with Vice President Biden. But she kept her date with the A.M.E. Church conference and let it be known hours beforehand that she would speak about the shootings which, for the moment at least, have cast a pall over other issues in the presidential contest.

She took the stage in an already charged political atmosphere that the Quinnipiac University Poll last week called "a mean-spirited, scorched-earth campaign" between two candidates disliked or not trusted by a majority of voters.

That national poll of 1,610 registered voters found the fall race between the presumptive rivals "too close to call" amid a "deeply divided" electorate.

But the poll found no such division among African Americans: 91 percent of those voters backed Clinton, while 1 percent preferred Trump. White voters in the poll backed Trump, 47 to 34 percent.

Trump canceled a speech Friday in Miami on Hispanic issues. He instead released a statement calling the shootings in Dallas "a coordinated, premeditated assault" on police. He also termed the police shootings of Alton Sterling in Baton Rouge and Philando Castile in suburban St. Paul "senseless" and a reminder of how much more needs to be done to ensure Americans feel safe in their communities.

Clinton did not mention Trump's name or make any comment about their contentious race in her speech here. Instead, she cited President Obama's response to the violence: "We are better than this."

Among her thousands of listeners was Felicia Commodore, 33, an assistant professor from Silver Spring, Md., who teaches at Old Dominion University in Norfolk, Va. Commodore said she appreciated that Clinton "focused on people, not politics."

"She acknowledged the tragedies and the issues, but more than anything she lifted up something that's been on all our minds," Commodore said.

Michael Scroggins, 43, a pastor from Bigelow, Ark., said Clinton's speech means a lot to him - as long as she's still speaking that way in August and October and next year, if she becomes president.

"I've never heard a major candidate speak about social reform in as much entirety as she did," Scroggins said. "She used this moment to address the real issues."

Clinton's 28-minute speech was often met with polite applause. She wove biblical scripture throughout, drawing an enthusiastic response when she closed with what she called a favorite verse from the Book of Galatians. "Let us not grow weary in doing good," Clinton said as the crowd roared. "For in good season we will reap if we do not lose heart."