View Source Say (say v0.2.1)
Lets the System say a given text via text-to-speech.
why
Why?
While programming I found it very useful to get acustic feedback from some background jobs which execute elixir code.
One concrete sample is when RiotJS markup files has to be compiled to JavaScript. This watch-compile-loop is implemented with elixir, and when a compile fails, my laptop says "riot compile error".
usage
Usage
Import Say
def foo() do
if func() do
say("success")
else
say("error in foo")
end
end
configuration-how-to-say-something
Configuration (How to say something)
You can configure the way how to say something...
via an elixir function:
config :say,
func: &IO.inspect/1via shell command:
config :say,
exec: "say"
config :say,
exec: "say"
exec_args: ~w(-v somevoice)via shell command over an SSH tunnel:
config :say,
exec: "say",
ssh_args: ~w(-p 2222 localhost)
config :say,
exec: "say",
exec_args: ~w(-v somevoice)
ssh_args: ~w(-p 2222 localhost)
ssh-tunneling-use-cases
SSH-Tunneling Use-Cases
setup-a-reverse-tunnel-into-a-local-vm
Setup a reverse tunnel into a local VM
If working on a Mac or Linux with text-to-speech and the Elixir app is inside a VM you can set a reverse tunnel from the VM host inside the VM guest over the VM_PORT, so that the upper config works:
my-mac $ ssh -p VM_PORT -NTR 2222:localhost:22 localhost
setup-a-local-tunnel-into-another-mac-linux
Setup a local tunnel into another Mac/Linux
If your Elixir development environment has no text-to-speech and you have access to a Mac or Linux box with text-to-speech, then you can setup a tunnel to the other Mac/Linux with
my-elixir $ ssh -NTL 2222:localhost:22 my-mac
os-specialities
OS specialities
On the Mac the executable
saycan be used directly.On Linux I haven't tried, but these should work https://linuxhint.com/command-line-text-speech-apps-linux/
Link to this section Summary
Link to this section Functions
@spec say(binary()) :: {:ok | :error, Collectable.t(), exit_status :: non_neg_integer()}
Lets the system say the given text.
text is expected to be a binary.
Returns a tuple containing :ok or :error, the collected result and the command exit status.
- Throws an
ArgumentErrorif:exec_argsor:ssh_argsexist but are not a list of binaries and:execexists but is not a binary. - Throws an
ArgumentErroriftextis not a binary.
examples
Examples
iex> Say.say("hello")
{:ok, "hello", 0}