Skip to content

Instantly share code, notes, and snippets.

@lukateras
Last active April 10, 2017 14:45
Show Gist options
  • Save lukateras/3e2670e67e95af0a9cd7 to your computer and use it in GitHub Desktop.
Save lukateras/3e2670e67e95af0a9cd7 to your computer and use it in GitHub Desktop.
-module(choir).
-export([start/0, start_world/0, say/1, say/3]).
start() -> register(?MODULE, spawn(fun loop/0)).
loop() ->
receive {Message, Voice} ->
os:cmd(io_lib:format("say -v '~s' '~s'", [Voice, Message])),
loop()
end.
world() -> [node()|nodes()].
start_world() -> rpc:multicall(world(), ?MODULE, start, []).
say(Message) -> say(Message, "Kyoko").
say(Message, Voice) -> say(Message, Voice, world()).
say(Message, Voice, [H|T]) ->
{?MODULE, H} ! {Message, Voice},
say(Message, Voice, T);
say(_, _, []) -> ok.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment