项目作者: max-power

项目描述 :
Phonetic Spelling: Whiskey - Tango - Foxtrot
高级语言: Ruby
项目地址: git://github.com/max-power/phonetic.git
创建时间: 2017-11-10T06:21:41Z
项目社区:https://github.com/max-power/phonetic

开源协议:

下载


Phonetic Spelling

NATO, LAPD and lots more

Papa - Hotel - Oscar - November - Echo - Tango - India - Charlie
Sierra - Papa - Echo - Lima - Lima - India - November - Golf


Installation

Add this line to your application’s Gemfile:

  1. gem 'phonetic'

And then execute:

  1. $ bundle

Or install it yourself as:

  1. $ gem install phonetic

Usage

  1. msg = Phonetic::Speller.new.spell('WTF')
  2. puts msg.join(' - ') # 'Whiskey - Tango - Foxtrot'
  3. msg = Phonetic::Speller.new(Phonetic::Alphabet::DE).spell('ABC')
  4. puts msg.join(', ') # 'Anton, Berta, Cäsar'

Make your own Alphabet

  1. binary_alphabet = ('A'..'Z').map { |a| [a.downcase, a.ord.to_s(2)] }.to_h
  2. Phonetic::Speller.new(binary_alphabet).spell('ABC').join # "100000110000101000011"

Say it! (macOS only)

For a list of Voices on macOS see voices.csv

  1. Phonetic::Speaker.new('Anna').say(msg)
  2. dutch_speakers = %w(Xander Ellen).map { |v| Phonetic::Speaker.new(v) }.cycle
  3. Phonetic::Alphabet::NL.each_value { |word| dutch_speakers.next.say(word) }
  4. spanish_speakers = %w(Diego Jorge Juan Monica Paulina).map { |v| Phonetic::Speaker.new(v) }
  5. Phonetic::Alphabet::ES.each_value { |word| spanish_speakers.sample.say(word) }