#! /usr/local/bin/perl

# This script will be called by speechplay to play a speech file on a sun machine
#
# If -v is given then the number immediately folling the -v is used as the volume.
# If the -x is given then the external speaker is used.

if (($#ARGV < 0) || ($#ARGV > 2)) {
  print "Usage: playonsun <speechfile> [-v<volume>] [-x]\n";
  exit(-1);
}

$speechfile = shift(@ARGV);

$ext = "";
$vol = 100;

foreach $arg (@ARGV) {
  if ($arg =~ /-v(\d*)/) {
    $vol = $1;
  }
  elsif ($arg =~ /-x/) {
    $ext = "-x";
  }
}

$ENV{"DISPLAY"} = ":0.0";


system("/projects/cslu/speech/new/bin/sun4/autogain $speechfile /usr/tmp/$$gain.adc");
system("/projects/cslu/speech/new/bin/sun4/sparcplay $ext -v $vol /usr/tmp/$$gain.adc");
system("/usr/bin/rm /usr/tmp/$$gain.adc");



