A few corrections and modifications to your code. Also, next time, please use the Code Tags, they make reading code a lot easier. Please note the remarked statement. (the one that starts with a ; )
Usage: /testvoice (should run the code that you originally started with, but in all rooms that you are in and over all connected servers.
/testvoice <room> (should run the code that you originally started with, over all servers, but just for the named room)

I'm currently unable to test this, so I hope it works.

Code:
alias testvoice {
  var %connection = $scon(0)
  while %connection {
    .scon -at1 testvoice2 $1
    dec %connection
  }
}
alias testvoice2 {
  var %room = $iif($1,$1,$comchan($me,0))
  var %mmalltarg = %room, %i = $nick(%room,0), %mmint, %mblock = ON
  while %i {
    ;where is the variable %mmsec being set?
    inc %mmint %mmsec
    if ($nick(%room,%i) isvoice %room) {
      echo $me $nick(%room,%i)
    }
    dec %i
  }
  var %totmmall = %mmint / %mmsec
}