• Stars
    star
    103
  • Rank 333,046 (Top 7 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 12 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Talking hooks for long lasted cli tools

Talks gem — now your ruby and command-line tools can talk with you

Build Status http://travis-ci.org/gazay/talks https://codeclimate.com/github/gazay/talks talks API Documentation

If you want to HEAR some response from your code or command-line tools, just use this gem.

You can use this gem on MacOS X and on other linux/unix systems with espeak installed.

Now with support for notifiers through notifier gem! Check the notifier's README and find what notifier you want to use - there is support for every OS!

I added in all sections of this readme notes about usage notifier functionality. And small readme about usage with Growl notifier.

Here is a small screencast about talks

Soon we will finish the wiki and it will be (I hope) delimited and clear for understand.

Sponsored by Evil Martians

Why?

Example

You're running some really long task and you leave the desk to drink some coffee, read a book or surf the internet and you want to be notified that the task has finished its execution. You don't want to check your machine each minute. With this gem you can just add a little hook at the end of your code and when the execution ends - you will hear it in voice that you have chosen from MacOS X say function collection or from espeak collection.

Now if you forgot power on you sound on machine you can always see notifications by notifiers like Growl, Kdialog, Knotify, etc. Full list of notifiers is here.

You can find some examples of talks usage in organization ruby-talks:

Examples from other people:

How?

On MacOS X this gem is just using the native MacOS X say command line tool. On linix/unix this gem is using espeak speech synthesis.

For notifications this gem uses notifier gem.

In all examples below I've used MacOS X voice types. For espeak you can read section Using talks with espeak

Configuration

You can configure default voices and messages for talks with ~/.talksrc file or with your_project/.talksrc file. It should be written in YAML format:

~/.talksrc

default_voice: 'whisper'
engine: 'say'
notifier: 'off'            # if this option passed - you will not receive notifications at all
notifier_options:
  title: 'Not talks'
  image: 'path/to/okay.png'
detach: true               # added ' &' to command line command
notify_by_default: true    # everytime when you call Talks#say - it will call Talks#notify
voices:
  info: 'pipe'
messages:
  info: 'hello'
  warn: 'WE GONNA DIE!!!'

You can also do it in your code dynamically through Talks.config instance.

You can configure only the default voice for say method and voices and messages for 4 types of talks: info, warn, success, error

For command-line commands you can configure default voices and hook messages:

~/.talksrc

bundle:
  voice: 'vicki'
  before_message: 'Bundler again will do all right'
  after_message: "Bundler's job is done here"
  before_notify: 'This will go to notification before `before_message`'
  after_notify: 'This will go to notification after `after_message`'
# notifier: 'off' # this option will turn off notifications for this command

You can create your own default preferences for each command-line tool which you want to run with talks or talking command in front:

~/.talksrc

ls:
  voice: 'bad'
  before_message: 'Now we will see what in the directory'
  after_message: '.'
  before_notify: 'This will go to notification before `before_message`'
  after_notify: 'This will go to notification after `after_message`'
# notifier: 'off' # this option will turn off notifications for this command
cap:
  ...
vim:
  ...
scp:
  ...
... and etc

Using talks/talking command-line tool

talks or talking command-line tool wrap your command-line commands with talks hooks:

$ talking bundle install

After that talks will wrap execution of this command with voice messages. By default messages will be like 'command_name task started/ended'. You can preconfigure messages in your ~/.talksrc file or you can send options right in the talking command:

$ talking -v agnes -bm 'We gonna die!' -am 'Not sure if we can hear that' rm -rf ./
# the same
$ talking --voice agnes --before-message 'We...' --after-message 'Not...' rm -rf ./

The same with notifications:

$ talking -v agnes -bn 'We gonna die!' -an 'Not sure if we can hear that' rm -rf ./
# the same
$ talking --voice agnes --before-notify 'We...' --after-notify 'Not...' rm -rf ./

Using talks in your code

$ gem install talks

Then in your code you can require and use Talks functions:

require 'talks'

Talks.say 'Hello bro!'

# There are 4 types of voice: say or info, warn, success, error
Talks.info 'This is info'
# Talks.warn 'Some text'
# Talks.success 'Some text'
# Talks.error 'Some text'
Talks.notify 'This will be shown to you by your notifier'

Talks.say can be customized with type of message and voice by adding options to this method parameters:

Talks.say 'Hello like pipe', voice: 'pipe'
Talks.say 'Hello like error', type: :error # the same as using Talks.error

All voices which I've found in say manual:

VOICES = %w(
  agnes albert alex bad bahh bells boing bruce bubbles cellos
  deranged fred good hysterical junior kathy pipe princess ralph
  trinoids vicki victoria whisper zarvox
)

Using talks with espeak

You can configure your talks engine even to tell MacOS X to use espeak:

~/.talksrc

engine: 'espeak'

Otherwise talks will set engine by default. It will be set to say on MacOS X and to espeak on all other OS-es if command which espeak returns non-empty string.

You can even configure your language in espeak (this gem still doesn't support different languages). Voices for espeak:

Talks.voices[:espeak]
# =>
  [
    'en+m1', 'en+m2', 'en+m3', 'en+m4', 'en+m5', 'en+m6', 'en+m7',
    'en+f1', 'en+f2', 'en+f3', 'en+f4', 'en+f5', 'en+f6', 'en+f7'
  ]

Using talks with Growl

For Growl you should be a Mac user. And you should have Growl version >= 1.3.

If it's ok for you - you need to do several steps for using talks with Growl:

  • Install the growlnotify script

  • Open the Growl Preference Panel (System > Growl) and activate “Listen for incoming notifications” and “Allow remote application registration” (in Growl v1.4 present only first option - activate only her) options on the Network tab

  • I don't really remember - but maybe you should restart your machine after that :)

Now you can use talks with Growl support:

$: talking -bn 'This is before notification wich will shown with growl' ls -la

Here is the screenshot.

Who?

I did it myself.

Contributors

  • @gazay

A lot of thanks

  • @kossnocorp - for idea with notifiers and his pulls.

  • @shime - for grammar fixes in readme and better explanation of my idea.

  • @aderyabin - extended customization of talks is his idea.

  • @brainopia - bro helps me with any idea of mine. He advised me to do command line tool talks.

You can help me with this fun gem and I'll gladly add you here, or above.

License

The MIT License

More Repositories

1

gon

Your Rails variables in your JS
Ruby
3,036
star
2

ids_please

Helps to get IDs or screen names from links to social network accounts
Ruby
155
star
3

gon-sinatra

Your Sinatra variables in your JS
Ruby
83
star
4

node-emoji-clock

JavaScript
78
star
5

share_some_love

Share some love to our buddies rubyists!
Ruby
26
star
6

odnoklassniki

Ruby wrapper for Odnoklassniki API
Ruby
24
star
7

tonic

gh-pages with sass, haml, coffee (and compass)
Ruby
23
star
8

environment

Ubuntu install and setup
Shell
12
star
9

spik

Let spik with Rails!
Ruby
11
star
10

mnemonic

Simple logger to show where is leaking by many-many puts
Ruby
10
star
11

is

Small simple tool for finding points in polygons
Ruby
6
star
12

gobrain

Rails Rumble Entry for Gobrain
JavaScript
4
star
13

repka

Repka will help you easily gather stats from controllers if you use mongoid
Ruby
4
star
14

dlnd-project-02

Image classification problem with convolutional networks
Jupyter Notebook
3
star
15

diffit

A simple solution to track changes in your tables.
Ruby
2
star
16

dlnd_tv_script_generation

HTML
2
star
17

movie-alert

Repository for the RailsRumble 2009 Team 74
JavaScript
2
star
18

node-utf-format

Ⓕⓞⓡⓜⓐⓣ ᴛᴇxᴛ with utf-8 power
JavaScript
2
star
19

kubik

Sugar for kubernetes for lazy developers
2
star
20

lysa-old

Clone of https://github.com/learnyou/lysa
TeX
2
star
21

postcss-demo

Gulp application to check how all PostCSS plugins work
HTML
2
star
22

hat_on_the_head

Jupyter Notebook
1
star
23

anybitchcancode

really
1
star
24

recsys_learning

Jupyter Notebook
1
star
25

scheme48

http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours
1
star
26

bioreactor

Repository for the RailsRumble 2010 Team 69
JavaScript
1
star
27

repka_ar

Easy stats collecting with ActiveRecord (Use REPKA and MongoDB, Luke). This is PRE-ALPHA, when this will work, i'll let you know ;)
Ruby
1
star
28

friendly_admin

Friendly admin
Ruby
1
star
29

nuclear_safety

diploma project to solving nuclear safety problem
Ruby
1
star
30

dlnd-project-01

First project of dlnd
HTML
1
star
31

battletoads

Tools to generate demo applications for PostCSS plugins
Ruby
1
star
32

ruby-lang.org-templates

Translation templates for www.ruby-lang.org news
1
star
33

dlnd-project-04

Language translation project from dlnd
HTML
1
star
34

dlnd-face-generation

final project of DLND
HTML
1
star