OTTAWA -- The federal government plans to rely on electronic monitoring, telephone reporting and community supervision to avoid locking up migrants while they await immigration hearings.

The government has spelled out details of how it will try to find alternatives to jailing newcomers to Canada, including use of voice recognition and monitoring technology to track people released in the community.

The $138-million overhaul is intended to ensure detention is a last resort.

The Canada Border Services Agency detains thousands of new arrivals who are considered a flight risk or a danger to the public and those whose identities cannot be confirmed.

The Canadian Red Cross Society has found numerous shortcomings at facilities for immigrant detainees, including overcrowding and lack of mental health care.

Prior to Tuesday's federal announcement, the only way a migrant could be released from detention was if they posted a financial guarantee and agreed to conditions.

Now, there will be three alternatives.

A new community case management system will see the CBSA working with organizations such as the Salvation Army, the John Howard Society of Canada and the Toronto Bail Program to help supervise up to 800 people after they are released.

A new voice reporting system will use biometric voice recognition technology that could lead to 10,000 people reporting their whereabouts using global positioning features through cellphones or landlines.

An electronic monitoring pilot program will also be started in the Toronto area, and it will initially be used with 20 higher-risk releases.

The CBSA has hired 14 new officers to review the cases and help determine who can be released.

The changes were made in consultation with refugee advocates, including the United Nations High Commissioner for Refugees, to find better ways to deal with vulnerable people, and reduce the number of children in custody while still meeting Canada's national security needs.

Last year, 162 minors were detained or housed with their parents in holding centres.

The UNHCR representative in Canada said the new measures constituted a major step in treating vulnerable migrants more humanely.

"Keeping children and their families out of detention and ensuring families stay together is in the best of interests of children," Jean-Nicolas Beuze, the UNHCR representative in Canada, said in a statement.

"UNHCR believes that there are effective ways to manage borders and guarantee security without resorting to the detention of people who are seeking safety in Canada."

The Canadian program was first announced in 2016, long before the political firestorm over U.S. President Donald Trump's recent "zero tolerance" policy for illegal border crossings that has seen immigrant parents separated from their children in that country.