NAME

Speak - Convert text to speech using Google's engine and play it on speakers

VERSION

Author

Andrew DeFaria <Andrew@DeFaria.com>

Revision

$Revision: 1.04 $

Created
Modified

Fri 06 Sep 2026 08:30:00 AM PST

SYNOPSIS

This module offers subroutines to convert text into speach and speak them.

DESCRIPTION

This module exports subroutines to process text to speach and speak them.

ROUTINES

The following routines are exported:

speak($msg, $log, $lang, $persona)

Convert $msg to speech.

Parameters:

$msg:

Message to speak. If $msg is defined and scalar then that is the message to speak. If it is a file handle then the text will be read from that file. Otherwise the text in the clipboard will be used.

$log

If provided, errors and messages will be logged to the logfile, otherwise to speak.log

$lang

Language code (e.g. 'en', 'en-gb', 'en-au'). Defaults to $ENV{SPEAK_LANG} or 'en'.

$persona

Optional. The persona name to use for the voice. If provided, the MCP server is used instead of standard TTS.

Returns:

Nothing

say_persona($self, $text, $persona)

Experimental subroutine that requires an MCP server. Converts the given $text to speech using the specified $persona voice.

$self

Object reference (if called as a method) or class name.

$text

The text message to be spoken.

$persona

The persona name to use for the voice. The system will look for a file named lc($persona) with extensions like .mp3, .wav, or .flac in the voices directory. If not found, it defaults to default.mp3.

CONFIGURATION AND ENVIRONMENT

SPEAK_LANG: Language code (e.g. 'en', 'en-gb', 'en-au'). See etc/speak.conf for available languages. Defaults to $ENV{SPEAK_LANG} or 'en'.

SPEAK_PERSONA: Default persona to use for the voice (e.g. 'Arnold'). If set, the MCP TTS engine is used by default.

SPEAK_SERVER: MCP TTS primary server hostname or IP address.

SPEAK_PORT: MCP TTS primary server port number.

SPEAK_WAN_SERVER: MCP TTS WAN/external server hostname for failover when off-LAN.

SPEAK_WAN_PORT: MCP TTS WAN/external server port number (defaults to 443).

SPEAK_WAN_SCHEME: MCP TTS WAN/external server scheme ('https' or 'http').

SPEAK_MUTE: If set to a true value, speech output is muted. Alternatively, if a file exists at $ENV{HOME}/.speak/shh or /etc/speak/shh, speech is muted.

To silence Speak for while simply touch $ENV{HOME}/.speak/shh
or /etc/speak/shh file. To unsilence Speak, remove the file.

Configuration File

Speak supports a configuration file located at $ENV{HOME}/.speak/speak.conf or /etc/speak/speak.conf.

Format: language: en-gb # other options...

Supported keys: language - Default language code for speech generation. persona - Default persona to use for the MCP voice engine. server - MCP server hostname or IP address. port - MCP server port number. wan_server - Public WAN server hostname for failover when off-LAN. wan_port - Public WAN server port number. wan_scheme - Public WAN URL scheme (http/https).

DEPENDENCIES

Perl Modules

Clipboard

LWP::UserAgent

URI::Escape

BUGS AND LIMITATIONS

There are no known bugs in this module.

Please report problems to Andrew DeFaria <Andrew@DeFaria.com>.

LICENSE AND COPYRIGHT

This Perl Module is freely available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This Perl Module is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (http://www.gnu.org/copyleft/gpl.html) for more details.

You should have received a copy of the GNU General Public License along with this Perl Module; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. reserved.