View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Bryan Jurish > Speech-Rsynth > Speech::Rsynth



Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  


Speech::Rsynth -- Perl interface to 'librsynth' Klatt-style speech synthesis C library.


  use Speech::Rsynth;
  # Constructor
  $rs = Speech::Rsynth->new(%cfg);         # create a new synth object

  # Synthesis
  $rs->start;                              # start synthesis
  $rs->say_string("test 1 2 3");           # synthesize string
  $rs->say_file(STDIN);                    # synthesize a whole file
  $rs->stop;                               # stop synthesis (synchronizes)

  # Configuration
  %cfg = $rs->configure;                   # get all synth configuration data
  $rs->configure(%cfg);                    # set (partial) synth configuration

  # Accessors : Flags
  $bool = $rs->use_audio;  $rs->use_audio($bool);   # do/don't send to audio device
  $bool = $rs->running;    $rs->running($bool);     # get/set active-flag

  # Accessors : General
  $level = $rs->verbose;   $rs->verbose($level);    # get/set verbosity level
  $bool = $rs->help_only;  $rs->help_only($bool);   # get/set help-flag

  # Accessors: Audio Properties
  $hertz = $rs->samp_rate; $rs->samp_rate($hertz);  # get/set sample-rate

  # Accessors: Audio Filenames
  $file = $rs->dev_file;    $rs->dev_file($file);     # get/set audio device filename
  $file = $rs->linear_file; $rs->linear_file($file);  # get/set raw linear filename
  $file = $rs->au_file;     $rs->au_file($file);      # get/set Sun/NeXT filename

  # Accessors: File Descriptors
  $fd = $rs->dev_fd;        $rs->dev_fd($fd);         # get/set audio device fd
  $fd = $rs->linear_fd;     $rs->linear_fd($fd);      # get/set raw linear fd
  $fd = $rs->au_fd;         $rs->au_fd($fd);          # get/set Sun/NeXT fd

  # Accessors: Klatt Guts
  $ms = $rs->mSec_per_Frame;   $rs->mSec_per_Frame($ms);  # milliseconds per frame
  $bool = $rs->impulse;        $rs->impulse($bool);       # impulse glottal source
  $n = $rs->casc;              $rs->casc($n);             # number cascade formants
  $n = $rs->klatt_f0_flutter;  $rs->klatt_f0_flutter($n); # F0 flutter
  $dB = $rs->klatt_tilt_db;    $rs->klatt_tilt_db($dB);   # tilt dB
  $hz = $rs->klatt_f0_hz;      $rs->klatt_f0_hz($hz);     # F0 base frequency

  # Accessors: Holmes
  $n = $rs->speed;             $rs->speed($n);            # speed (1.0 is 'normal')
  $f = $rs->frac;              $rs->frac($f);             # parameter filter 'fraction'
  $file = $rs->par_name;       $rs->par_name($file);      # parameter filename for plot
  $file = $rs->jsru_name;      $rs->jsru_name($file);     # plot file for alternate synth (JSRU)

  # Accessors: Dictionary
  $path = $rs->dict_path;      $rs->dict_path($path);     # full path to GDBM dictionary file

  # Accessors: low-level
  $flags = $rs->flags;         $rs->flags($flags);        # get/set flags mask


Speech::Rsynth is a Perl OO interface to my adaptation of Nick Ing-Simmons' "rsynth" speech synthesizer package, itself based on Jon Iles' implementation of a Klatt formant synthesizer. It currently provides only basic Text-to-Speech (TTS) capabilities, with output to file(s) of several formats, as well as directly to an audio device.

Currently tested only under linux.


A number constants may be exported; they are listed here by tag.






The following is a list of accessible fields of Speech::Rsynth objects. Fields may be read out individually for a Speech::Rsynth object $rs by calling $rs->NAME(), where NAME is the field name, and may be set individually by calling $rs->NAME($new_value). The field names also function as keyword arguments to the new() and configure() methods, described above.

* use_audio

 Type: boolean

Whether or not to output directly to the audio device. Default=no.

* running


Whether or not to start() the synth immediately. Default=no.

* verbose

 Type: integer

Verbosity level. Default=0.

* help_only

 Type: boolean

Whether or not only help messages should be printed. Default=0.

* samp_rate

 Type: integer

Sample rate in Hz. Default=8000.

* dev_file

 Type: string

Audio device filename. Default="/dev/dsp".

* linear_file

 Type: string

Filename for raw linear output. Default=undef (none).

* au_file

 Type: string

Filename for Sun/NeXT output. Default=undef (none).

* dev_fd

 Type: integer

File descriptor for audio device. Default=-1 (none).

* linear_fd

 Type: integer

File descriptor for raw linear file. Default=-1 (none).

* au_fd

File descriptor for Sun/NeXT file Default=-1 (none).

* mSec_per_Frame

 Type: integer

milliseconds per frame. Default=10.

* impulse

 Type: boolean

impulse glottal source. Default=0.

* casc

 Type: integer

number cascade formants. Default=0.

* klatt_f0_flutter

 Type: integer

F0 flutter. Default=0.

* klatt_tilt_db

 Type: integer

tilt dB. Default=10.

* klatt_f0_hz

 Type: integer

F0 base frequency. Default=1330.

* speed

 Type: integer

speed (1.0 is 'normal'). Default=1.

* frac

 Type: float

parameter filter 'fraction'. Default=1.0.

* par_name

 Type: string

parameter filename for plot. Default=undef (none).

* jsru_name

 Type: string

plot file for alternate synth (JSRU). Default=undef (none).

* dict_path

 Type: string

full path to GDBM dictionary file. Default=undef (none).

* flags

 Type: integer (mask)

mask of synth status flags. default=0.


There are still some globals left in librsynth which may interfere with multiple synths running simultaneously.

The filename fields should disappear, and the fd fields should be replaced by something perl-friendly, like filehandles.

More control over synthesis-time parameters would be real nice.

Probably many, many more.


perl by Larry Wall.

"say" program and original rsynth package by Nick Ng-Simmons.


Bryan Jurish <>


perl(1). say(1).

syntax highlighting: