Audio::SPX - Perl interface to the Sphinx audio library.


Speech-Recognizer-SPX documentation  | view source Contained in the Speech-Recognizer-SPX distribution.

Index


NAME

Top

Audio::SPX - Perl interface to the Sphinx audio library.

SYNOPSIS

Top

  use Audio::SPX;
  my $ad = Audio::SPX->open_sps(16000);

  $ad->start_rec or die "start_rec failed";
  $ad->stop_rec or die "stop_rec failed";
  my $samples = $ad->read($buf, $max);

  my $cad = Audio::SPX::Continuous->init($ad);
  my $cad = Audio::SPX::Continuous->init_nbfh($fh, $sps);
  my $cad = Audio::SPX::Continuous->init_raw($fh, $sps);

  $cad->calib;
  $cad->calib_loop($buf);
  $cad->set_thresh($sil, $sp);
  $cad->set_params($delta_sil, $delta_speech, $min_noise,
		   $max_noise, $winsize, $speech_onset,
		   $sil_onset, $leader, $trailer);
  my ($delta_sil, $delta_speech, $min_noise, $max_noise,
      $winsize, $speech_onset, $sil_onset, $leader, $trailer)
         = $cad->get_params;

  # If init_raw was used, this will consume the data in $buf, then
  # write back any non-slience data.  Yes, this feature is
  # undocumented in the Sphinx headers.  Yes, it's very useful.
  my $samples = $cad->read($buf, $max);

  $cad->reset;
  $cad->detach;
  $cad->attach($ad);
  $cad->read_ts;
  $cad->set_logfp(\*FH);

DESCRIPTION

Top

Warning! This interface is suboptimal and is therefore probably going to change, both in the Perl module and the underlying library.

BUGS

Top

The only supported sample rate for Audio::SPX is 16kHz (Audio::SPX::Continuous should be fine with others). init_sps() will simply fail rudely if you try something else... which means it isn't really very useful. I suggest either opening the audio device yourself, setting non-blocking mode (beware, some sound drivers don't like this...) and passing it to the init_nbfh method in Audio::SPX::Continuous, or using init_raw and managing the audio device yourself.

There isn't enough documentation yet, partly because the API is somewhat in flux, and partly because I haven't figured out what some of this stuff does either :-)

AUTHOR

Top

David Huggins-Daines <dhuggins@cs.cmu.edu>

SEE ALSO

Top

perl(1), Speech::Recognizer::SPX


Speech-Recognizer-SPX documentation  | view source Contained in the Speech-Recognizer-SPX distribution.