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.
:const_nsynth
Constants from 'nsynth.h'.
ALL_PARALLEL CASCADE_PARALLEL IMPULSIVE NATURAL NPAR PI
:const_rflags
Constants from 'rstruct.h' -- can be used for the 'flags' accessor/keyword.
RSY_RUNNING RSY_USEAUDIO
:const_aufile
Constants from 'aufile.c'.
SUN_HDRSIZE SUN_LIN_16 SUN_LIN_8 SUN_MAGIC SUN_ULAW SUN_UNSPEC
:const
Exports the contents of all of the above 'const_*' tags.
new(%args)
Create and return a new Speech::Rsynth object, initializing it according to the keyword-argments in '%args'. See "Accessors" for a list of valid keyword arguments for %args.
start()
Start the synthesizer. This method must be called first if the 'say_*' methods are to produce any useful result.
say_string($string)
Synthesize speech from the text string $string, which may contain literal phone-strings enclosed in square brackets. See the librsynth documentation for details on recognized phone encodings.
say_file(FILEHANDLE)
Synthesize speech from the text from FILEHANDLE, which should be a Perl filehandle open for reading.
stop()
Stops the synthesizer and synchronizes all its data files. Note that these files will be overwritten if the synthesizer is subsequently re-started.
configure(%cfg)
With arguments, sets the object fields named by the keyword arguments to the indicated values. With or without arguments, returns a hash containing all accessible field values indexed by field names.
See "Accessors" for details on accessible fields.
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
Type=boolean
Whether or not to start() the synth immediately. Default=no.
* verbose
Type: integer
Verbosity level. Default=0.
* help_only
Whether or not only help messages should be printed. Default=0.
* samp_rate
Sample rate in Hz. Default=8000.
* dev_file
Type: string
Audio device filename. Default="/dev/dsp".
* linear_file
Filename for raw linear output. Default=undef (none).
* au_file
Filename for Sun/NeXT output. Default=undef (none).
* dev_fd
File descriptor for audio device. Default=-1 (none).
* linear_fd
File descriptor for raw linear file. Default=-1 (none).
* au_fd
File descriptor for Sun/NeXT file Default=-1 (none).
* mSec_per_Frame
milliseconds per frame. Default=10.
* impulse
impulse glottal source. Default=0.
* casc
number cascade formants. Default=0.
* klatt_f0_flutter
F0 flutter. Default=0.
* klatt_tilt_db
tilt dB. Default=10.
* klatt_f0_hz
F0 base frequency. Default=1330.
* speed
speed (1.0 is 'normal'). Default=1.
* frac
Type: float
parameter filter 'fraction'. Default=1.0.
* par_name
parameter filename for plot. Default=undef (none).
* jsru_name
plot file for alternate synth (JSRU). Default=undef (none).
* dict_path
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 <moocow@ling.uni-potsdam.de>
perl(1). say(1).
1 POD Error
The following errors were encountered while parsing the POD:
You can't have =items (as at line 496) unless the first thing after the =over is an =item
To install Speech::Rsynth, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Speech::Rsynth
CPAN shell
perl -MCPAN -e shell install Speech::Rsynth
For more information on module installation, please visit the detailed CPAN module installation guide.