The court will apply a "totality of circumstances" test in assessing the voluntariness of the statement. The court will weigh the police conduct and circumstances of the interrogation ( were there threats, physical force, coercion, etc.)and also consider factors unique to the accused ( age, mental state, etc). Examples of cases involving involuntary statements include statements given after physical trauma(Brown v Mississippi)prolonged detention(Ashcraft v Tennessee), etc.
The person making the confession is first asked by a judge or a person of juris prudence if he/she is making the statement/confession on his/her own violition or under duress.The Judge/person of juris prudence follows this line of questioning through out the process to protect the rights of the person making the initial confession/statement.This procedure is used when a person making such confession/statement in allocuting or other court proceedings.The law always wants to make sure everything is on a level playing field for all, esp the one making the confession/statement so that there is no question later on, which could give grounds for appeal.