Help-Site Computer Manuals
  Algorithms & Data Structures   Programming Languages   Revision Control
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Object-based wrapper around the C<sclite> tool from the NIST SCTK.

Speech::Recognizer::ScLite - Object-based wrapper around the C<sclite> tool from the NIST SCTK.


Speech::Recognizer::ScLite - Object-based wrapper around the sclite tool from the NIST SCTK.


  # gather the correct and hypothesized readings any way you like. 

  # here I assume you have them in two text files that can be parsed

  # successfully by the toy sub read_trans below.

  my (%correct_readings) = read_trans('correct.txt');

  my (%hyp_readings) = read_trans('hypotheses.txt');

  # real work begins here

  use Speech::Recognizer::ScLite;

  # alter the default ('sclite') executable-name or a path to it


                                 '/usr/site/bin/SCTK-1-04/sclite-1-04' );

  my ($scorer) = 

    Speech::Recognizer::ScLite->new( 'result_location' => './test_17',

                                     id => 'Sex'); 

                                     # that oughtta increase the CPAN hits

  foreach my $line (sort keys %hyp_readings) {

    # construct an object to represent this version

    # construct any sort key you want. Here we assume that we're

    # interested in breaking out the files based on which directory

    # they're in.

    my ($l) = 


                                         ref => $correct_readings{$line},

                                         hyp => hyp_readings{$line},

                                         sort_key => getSort($line)




  } # end of looping over the filenames.

  # computes actual ASR performance, given above information


  # dumps a wordy report into the ->result_location;

  #  $scorer->report(); # currently a no-op since score() invokes

  # reporting function within the sclite utility itself


  # toy subs defined below for the sake of the completeness of the

  # example. 

  sub read_trans {

    my (%transcriptions);

    open (FILE, shift); # or die, of course

    while (<FILE>) {


      my ($trans, $file) = split;

      $transcriptions{$file} = $trans;


    close FILE; # or die, of course

    return %transcriptions;


  # this toy sort routine returns the sex of the speaker as the sort

  # key, rather than the (default) speaker directory.

  sub getSort {

    my ($filename) = shift;

    return ($filename =~ /female/i ? 'Female' : 'Male');



Provides an object-oriented interface to the sclite tool provided in the NIST SCTK, which is available from here:

It is intended to expose all the basic functionality of the sclite command line and

This is motivated by several reasons:

  • A few other tools exist, but most of them are explicitly designed to work with particular input forms, e.g.:
  • Managing large numbers of commandline options can be painful.

  • The sclite tool assumes that one particular sort of the data is interesting -- sorting by the ``speaker'' of the waveform. This is not necessarily the most interesting sort -- and it's certainly not the only interesting sort. This tool provides the ability to sort by whatever sort key you're interested in, not the ``speaker''.

    The sort should be transparent to the user.

  • Parsing text data is not really that hard in Perl, but why should more than one person figure all this out? This will allow other researchers to easily use the sclite tool with results from any format -- they need only solve the problem of extracting the text appropriately.


Class methods

->new([ attribute => value ]*)
Class method. Creates a new instance of this class. Takes as arguments any number of attribute-value pairs, where attribute is one of the data (see Data access methods below).

Gets/sets the location of the executable sclite engine.

Returns reference to the object with id == id.

Returns list of valid ids.

Returns list of existing instances.

Executes score() on all instances.

Action methods

->lines_push(Speech::Recognizer::ScLite::Line instance)
Adds a new datum to this ScLite object.

Clears list of lines that were added through addLine().

Does the work of actually scoring the various Line objects and computing the summaries.

Currently, this version shells out in order to execute this command. It would be nice to fix this.

Places the score report in the directory previously identified by result_location (or its default).

It is required that you call score() before you call report() on a given instance. (This should be obvious to the users.)

NOTE: This function is currently a no-op since early revisions of this code invoke an option to sclite that dumps a report during score().

Data access methods

Gets/sets the directory in which the results are to be put, after score() is called. Note that this target, in the future, will be populated with files after report() is called instead.

Gets/sets the identifier for this score. Results files use this name as a stem.

TO DO (planned)

  • Implement base code, using assumption that compiled executable exists. This includes adding the additional features of sort order.

    Still remaining at this phase:

    • Make sure that functions and options of the sclite executable are all visible through the OOP interface.

  • Add code to parse the output files, and store the data in Perl-ish data structures, to make it easier to put together reports in alternate formats.

  • Rebuild to use the sclite C code directly (through XS).


  1. 01
  2. Original version; created by h2xs 1.21 with options

=head1 AUTHOR

Jeremy Kahn, <>