acappella 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/bin/acappella-client +2 -1
- data/bin/acappella-server +13 -2
- data/lib/acappella.rb +1 -0
- data/lib/acappella/option_parser.rb +22 -8
- data/lib/acappella/server.rb +2 -1
- data/lib/acappella/set_list.rb +2 -2
- data/lib/acappella/singer.rb +17 -3
- data/lib/acappella/version.rb +1 -1
- data/lib/acappella/voice_type.rb +15 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb789efe1546c8327f8f9bf712dd7099109a9cfa
|
4
|
+
data.tar.gz: 60001dbdc4f4646ff4ce93222f7cbe388d3d138e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75acf468845b8b6726310c2041dec46ffa56b91fc01bfe8432401dc853546aa8b24e1ce15323a6598f67e5b8170e357770feff9fc60a09c1170d33f90c378085
|
7
|
+
data.tar.gz: 88309aacfce2c3f477b2ae75951e4fd7cda277783e3e8260e11b1e1a8737243efd67419f34077165520f7e9de79849cc856dba210bf0b2ee86abcdbd81535981
|
data/README.md
CHANGED
@@ -10,22 +10,23 @@ $ gem install acappella
|
|
10
10
|
|
11
11
|
## USAGE
|
12
12
|
|
13
|
-
1. Please perform the following in server side terminal.
|
13
|
+
### 1. Please perform the following in server side terminal.
|
14
14
|
|
15
15
|
```
|
16
16
|
$ acappella-server
|
17
|
-
acappella 0.0
|
17
|
+
acappella 0.1.0 starting on druby://localhost:8989
|
18
18
|
Run `acappella-server --help` for more startup options
|
19
19
|
Ctrl-C to shutdown server
|
20
20
|
```
|
21
21
|
|
22
|
-
2. Please perform the following in client side terminal.
|
22
|
+
### 2. Please perform the following in client side terminal.
|
23
23
|
|
24
24
|
```
|
25
25
|
$ acappella-client
|
26
26
|
Connect to druby://localhost:8989
|
27
|
+
Run `acappella-client --help` for more startup options
|
27
28
|
Ctrl-D to exit
|
28
|
-
> words you want to talk
|
29
|
+
> words you want to talk
|
29
30
|
```
|
30
31
|
|
31
32
|
Server speak characters that client was typing.
|
data/bin/acappella-client
CHANGED
@@ -6,7 +6,8 @@ $:.unshift(lib_path)
|
|
6
6
|
require 'acappella'
|
7
7
|
require 'readline'
|
8
8
|
|
9
|
-
|
9
|
+
option_parser = ACappella::OptionParser.new
|
10
|
+
options = option_parser.parse!(ARGV) rescue exit(false)
|
10
11
|
|
11
12
|
client = ACappella::Client.new(options)
|
12
13
|
|
data/bin/acappella-server
CHANGED
@@ -5,8 +5,19 @@ $:.unshift(lib_path)
|
|
5
5
|
|
6
6
|
require 'acappella'
|
7
7
|
|
8
|
-
|
8
|
+
option_parser = ACappella::OptionParser.new
|
9
|
+
option_parser.add_option('-v', '--voice=VAL')
|
9
10
|
|
10
|
-
|
11
|
+
options = option_parser.parse!(ARGV) rescue exit(false)
|
12
|
+
|
13
|
+
begin
|
14
|
+
server = ACappella::Server.new(options)
|
15
|
+
rescue ACappella::VoiceTypeError => e
|
16
|
+
quoted_voice_names = ACappella::VoiceType::VOICE_VARIATIONS.map {|v| "'#{v}'" }
|
17
|
+
|
18
|
+
puts "#{e.message} --voice=VAL accepts #{quoted_voice_names.join(', ')}."
|
19
|
+
|
20
|
+
exit(false)
|
21
|
+
end
|
11
22
|
|
12
23
|
server.start
|
data/lib/acappella.rb
CHANGED
@@ -2,19 +2,33 @@ require 'optparse'
|
|
2
2
|
|
3
3
|
module ACappella
|
4
4
|
class OptionParser
|
5
|
-
def
|
6
|
-
opt = ::OptionParser.new
|
5
|
+
def initialize
|
6
|
+
@opt = ::OptionParser.new
|
7
7
|
|
8
|
-
options = {}
|
8
|
+
@options = {}
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
@added_options = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_option(short, long, desc = '')
|
14
|
+
@added_options << [short, long, desc]
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse!(argv)
|
18
|
+
@opt.on('-h', '--host=VAL') {|v| @options[:host] = v }
|
19
|
+
@opt.on('-p', '--port=VAL') {|v| @options[:port] = v }
|
20
|
+
|
21
|
+
@added_options.each do |added_option|
|
22
|
+
short, long, desc = added_option
|
23
|
+
|
24
|
+
@opt.on(short, long, desc) {|v| @options[:voice] = v }
|
25
|
+
end
|
12
26
|
|
13
|
-
opt.parse!(argv)
|
27
|
+
@opt.parse!(argv)
|
14
28
|
|
15
|
-
options
|
29
|
+
@options
|
16
30
|
rescue ::OptionParser::MissingArgument => e
|
17
|
-
puts opt.help
|
31
|
+
puts @opt.help
|
18
32
|
|
19
33
|
raise e
|
20
34
|
end
|
data/lib/acappella/server.rb
CHANGED
@@ -6,6 +6,7 @@ module ACappella
|
|
6
6
|
def initialize(options = {})
|
7
7
|
host = options[:host] || 'localhost'
|
8
8
|
port = options[:port] || '8989'
|
9
|
+
voice = options[:voice] || ACappella::VoiceType::DEFAULT_VOICE
|
9
10
|
|
10
11
|
@uri = URI.parse("druby://#{host}:#{port}").to_s
|
11
12
|
|
@@ -13,7 +14,7 @@ module ACappella
|
|
13
14
|
|
14
15
|
@songwriter = Songwriter.new(@set_list)
|
15
16
|
|
16
|
-
@singer = Singer.new
|
17
|
+
@singer = Singer.new(voice)
|
17
18
|
end
|
18
19
|
|
19
20
|
def start
|
data/lib/acappella/set_list.rb
CHANGED
data/lib/acappella/singer.rb
CHANGED
@@ -1,17 +1,31 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
|
1
3
|
module ACappella
|
2
4
|
class Singer
|
5
|
+
def initialize(voice)
|
6
|
+
raise ACappella::VoiceTypeError.new("can't sing voice.") unless valid_voice?(voice)
|
7
|
+
|
8
|
+
@voice = voice
|
9
|
+
end
|
10
|
+
|
3
11
|
def sing(lyrics)
|
4
12
|
logging(lyrics)
|
5
13
|
|
6
|
-
|
14
|
+
shellescaped_args = [@voice, lyrics].shelljoin
|
15
|
+
|
16
|
+
system("say -v #{shellescaped_args}")
|
7
17
|
end
|
8
18
|
|
9
19
|
private
|
10
20
|
|
21
|
+
def valid_voice?(voice)
|
22
|
+
ACappella::VoiceType::VOICE_VARIATIONS.include?(voice)
|
23
|
+
end
|
24
|
+
|
11
25
|
def logging(lyrics)
|
12
|
-
|
26
|
+
sang_at = Time.now.strftime('%Y-%m-%d %H:%M:%S')
|
13
27
|
|
14
|
-
puts [
|
28
|
+
puts [sang_at, lyrics].join("\t")
|
15
29
|
end
|
16
30
|
end
|
17
31
|
end
|
data/lib/acappella/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
module ACappella
|
2
|
+
class VoiceTypeError < StandardError; end
|
3
|
+
|
4
|
+
class VoiceType
|
5
|
+
DEFAULT_VOICE = 'Bruce'
|
6
|
+
|
7
|
+
FEMALE_VOICES = %w(Agnes Kathy Princess Vicki Victoria)
|
8
|
+
MALE_VOICES = %w(Bruce Fred Junior Ralph)
|
9
|
+
NOVELTY_VOICES = [
|
10
|
+
'Albert', 'Bad News', 'Bahh', 'Bells', 'Boing', 'Bubbles', 'Cellos', 'Deranged', 'Good News', 'Hysterical', 'Pipe Organ', 'Trinoids', 'Whisper', 'Zarvox'
|
11
|
+
]
|
12
|
+
|
13
|
+
VOICE_VARIATIONS = FEMALE_VOICES + MALE_VOICES + NOVELTY_VOICES
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acappella
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi ITO
|
@@ -31,6 +31,7 @@ files:
|
|
31
31
|
- lib/acappella/singer.rb
|
32
32
|
- lib/acappella/songwriter.rb
|
33
33
|
- lib/acappella/version.rb
|
34
|
+
- lib/acappella/voice_type.rb
|
34
35
|
homepage: http://github.com/koic/acappella
|
35
36
|
licenses:
|
36
37
|
- MIT
|