kja 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data/lib/kja.rb +81 -23
- data.tar.gz.sig +0 -0
- metadata +52 -28
- metadata.gz.sig +1 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cf0f96cfdf4fabf09605e847917fea00ccd6d2e422653d2f5c654c4401a4d929
|
4
|
+
data.tar.gz: 117cae0553d930f9a1fe67fb632aa62ae608d191f708a6d67669c1b9045bdb26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45143316db18a8a22201d1bdabcd374c967f42f7d3ffa9a1a9e493e0424575378f253daaaca0e238b36c40baf24875fb2620e0e53c1b22753e58cd115ebabcac
|
7
|
+
data.tar.gz: 0ad0b442e3d3cdedd23e99087057fcbe244f955d133f8d80fdb4d10bd8b74e6bccd42d27d3aecb10ca959a0a28dd9d408f05b8fbdc92174d44f97304046307db
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/kja.rb
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
5
|
require 'dynarex'
|
6
6
|
require 'tempfile'
|
7
|
+
require 'rxfreader'
|
8
|
+
require 'kj_reading'
|
7
9
|
|
8
10
|
|
9
11
|
# description: Intended for use with the kj gem
|
@@ -25,41 +27,97 @@ require 'tempfile'
|
|
25
27
|
|
26
28
|
class Kja
|
27
29
|
|
28
|
-
def initialize(audio_player: '/usr/bin/ogg123 -q',
|
29
|
-
ogg_baseurl: 'http://
|
30
|
+
def initialize(audio_player: '/usr/bin/ogg123 -q',
|
31
|
+
ogg_baseurl: 'http://a0.jamesrobertson.me.uk/' \
|
32
|
+
+ 'rorb/r/ruby/kja/ogg', debug: false)
|
30
33
|
|
31
34
|
@ogg_baseurl, @audio_player = ogg_baseurl, audio_player
|
35
|
+
@debug = debug
|
32
36
|
|
33
37
|
end
|
34
|
-
|
38
|
+
|
39
|
+
def download_ogg(s)
|
40
|
+
|
41
|
+
ogg_filepath = fetch_ogg_filepath(s)
|
42
|
+
url = @ogg_baseurl + '/' + ogg_filepath
|
43
|
+
audio, _ = RXFReader.read(url)
|
44
|
+
|
45
|
+
tmpfile = Tempfile.new('kva')
|
46
|
+
File.write tmpfile.path + '.ogg', audio
|
47
|
+
|
48
|
+
return tmpfile.path + '.ogg'
|
49
|
+
|
50
|
+
end
|
51
|
+
|
35
52
|
def duration(s)
|
36
|
-
|
37
|
-
book_title, chapter_title, verse_no = fracture(s)
|
38
|
-
|
53
|
+
|
54
|
+
book_title, chapter_title, verse_no = fracture(s)
|
55
|
+
|
39
56
|
url = @ogg_baseurl + '/' + File.join(book_title, chapter_title, 'dir.xml')
|
40
57
|
|
41
58
|
dx = Dynarex.new url
|
42
|
-
ogg = dx.find_by_name chapter_title + '_' + verse_no + '.ogg'
|
59
|
+
ogg = dx.find_by_name chapter_title + '_' + verse_no + '.ogg'
|
43
60
|
ogg.description[/\d+\.\d+$/].to_f
|
44
61
|
|
45
|
-
end
|
62
|
+
end
|
46
63
|
|
47
|
-
def speak(
|
64
|
+
def speak(title)
|
48
65
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
tmpfile = Tempfile.new('kva')
|
54
|
-
File.write tmpfile.path, audio
|
66
|
+
a = KjReading.verses title
|
67
|
+
|
68
|
+
a.each do |x|
|
55
69
|
|
56
|
-
|
57
|
-
|
70
|
+
filename = download_ogg(x.title)
|
71
|
+
command = @audio_player + ' ' + filename
|
72
|
+
system command
|
73
|
+
|
74
|
+
end
|
58
75
|
|
59
76
|
end
|
60
|
-
|
77
|
+
|
78
|
+
|
79
|
+
def download(s, outfile=nil)
|
80
|
+
|
81
|
+
puts 'downloading ...' if @debug
|
82
|
+
|
83
|
+
a = KjReading.verses s
|
84
|
+
|
85
|
+
downloads = a.map do |x|
|
86
|
+
download_ogg(x.title)
|
87
|
+
end
|
88
|
+
|
89
|
+
puts 'converting to wav: ' + downloads.inspect if @debug
|
90
|
+
|
91
|
+
wavfiles = downloads.map do |oggfile|
|
92
|
+
|
93
|
+
wavfile = oggfile.sub(/\.ogg$/,'.wav')
|
94
|
+
EasyAudioUtils.new(oggfile, wavfile).convert
|
95
|
+
sleep 1.4
|
96
|
+
File.basename(wavfile)
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
puts 'concatenating wav files ...' if @debug
|
101
|
+
|
102
|
+
# concat wav files
|
103
|
+
#
|
104
|
+
fullwavfile = Tempfile.new('kva').path + '.wav'
|
105
|
+
puts 'creating fullwavfile:' + fullwavfile.inspect if @debug
|
106
|
+
EasyAudioUtils.new(out: fullwavfile, working_dir: \
|
107
|
+
File.dirname(fullwavfile)).concat(wavfiles, sample_rate: 22050)
|
108
|
+
|
109
|
+
# convert wav to ogg
|
110
|
+
#
|
111
|
+
fulloggfile = outfile || fullwavfile.sub(/\.wav$/, '.ogg')
|
112
|
+
puts 'creating fulloggfile: ' + fulloggfile.inspect if @debug
|
113
|
+
EasyAudioUtils.new(fullwavfile, fulloggfile).convert
|
114
|
+
|
115
|
+
'downloaded ' + fulloggfile
|
116
|
+
|
117
|
+
end
|
118
|
+
|
61
119
|
private
|
62
|
-
|
120
|
+
|
63
121
|
def fracture(s)
|
64
122
|
|
65
123
|
book_no, book_title, chapter_no, verse_no = \
|
@@ -68,16 +126,16 @@ class Kja
|
|
68
126
|
book_title.gsub!(/\s/,'_')
|
69
127
|
book_title = book_no + '_' + book_title if book_no
|
70
128
|
chapter_title = book_title + '_' + chapter_no
|
71
|
-
|
129
|
+
|
72
130
|
return [book_title, chapter_title, verse_no]
|
73
131
|
end
|
74
|
-
|
132
|
+
|
75
133
|
def fetch_ogg_filepath(s)
|
76
134
|
|
77
135
|
book_title, chapter_title, verse_no = fracture(s)
|
78
136
|
verse_title = chapter_title + '_' + verse_no
|
79
137
|
|
80
|
-
File.join(book_title, chapter_title, verse_title + '.ogg')
|
138
|
+
File.join(book_title, chapter_title, verse_title + '.ogg')
|
81
139
|
end
|
82
140
|
|
83
141
|
end
|
@@ -87,4 +145,4 @@ if __FILE__ == $0 then
|
|
87
145
|
kja = Kja.new(audio_player: '/usr/bin/ogg123 -q')
|
88
146
|
kja.speak(ARGV[0])
|
89
147
|
|
90
|
-
end
|
148
|
+
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kja
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,28 +10,33 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIEljCCAv6gAwIBAgIBATANBgkqhkiG9w0BAQsFADBIMRIwEAYDVQQDDAlnZW1t
|
14
14
|
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
-
|
15
|
+
8ixkARkWAmV1MB4XDTIyMDcxNTA3NTY0OVoXDTIzMDcxNTA3NTY0OVowSDESMBAG
|
16
16
|
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
-
EjAQBgoJkiaJk/
|
18
|
-
|
19
|
-
/
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoC
|
18
|
+
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9OXd0lx3YSia+CO8neZoor9q6eYcSiipsd
|
33
|
+
kgYOH5UsMHGt0Ir4kx45mvRQsCc+uTtO8PTXVJ4HwDygPlrj4eUrQHDJZp+c1T3k
|
34
|
+
Cx+uD+KmsS0PAxLgztrNvv4GRMxIr0eXpRea2HvX3kAkzC68v6M9R0tczWzpYuf/
|
35
|
+
hyP4rr90xWTMpBbCWCljzCCE068eKCOoYFhGLEQfuZ+w3bjFLx+u4pTOQdfhK9dq
|
36
|
+
n6o7BhDy9zrdH807AvfNd7InQgMgGUGq75tHatBTStNKF7ng7zTIPYHWc7YUDamV
|
37
|
+
c/p/VO0efUKyKAHzOQQe8VZzcgh6e7jVIws=
|
33
38
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
39
|
+
date: 2022-07-15 00:00:00.000000000 Z
|
35
40
|
dependencies:
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: dynarex
|
@@ -39,22 +44,42 @@ dependencies:
|
|
39
44
|
requirements:
|
40
45
|
- - "~>"
|
41
46
|
- !ruby/object:Gem::Version
|
42
|
-
version: '1.
|
47
|
+
version: '1.9'
|
43
48
|
- - ">="
|
44
49
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.
|
50
|
+
version: 1.9.11
|
46
51
|
type: :runtime
|
47
52
|
prerelease: false
|
48
53
|
version_requirements: !ruby/object:Gem::Requirement
|
49
54
|
requirements:
|
50
55
|
- - "~>"
|
51
56
|
- !ruby/object:Gem::Version
|
52
|
-
version: '1.
|
57
|
+
version: '1.9'
|
53
58
|
- - ">="
|
54
59
|
- !ruby/object:Gem::Version
|
55
|
-
version: 1.
|
60
|
+
version: 1.9.11
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: kj_reading
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0.3'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 0.3.0
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0.3'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 0.3.0
|
56
81
|
description:
|
57
|
-
email:
|
82
|
+
email: digital.robertson@gmail.com
|
58
83
|
executables: []
|
59
84
|
extensions: []
|
60
85
|
extra_rdoc_files: []
|
@@ -79,9 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
104
|
- !ruby/object:Gem::Version
|
80
105
|
version: '0'
|
81
106
|
requirements: []
|
82
|
-
|
83
|
-
rubygems_version: 2.6.8
|
107
|
+
rubygems_version: 3.3.7
|
84
108
|
signing_key:
|
85
109
|
specification_version: 4
|
86
|
-
summary: Downloads and plays King James Bible OGG files from
|
110
|
+
summary: Downloads and plays King James Bible OGG files from jamesrobertson.me.uk
|
87
111
|
test_files: []
|
metadata.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
�_#F����|E;���}���G�FYJ%��f��Գ�c3�lg��ڞH^Ki��� :Q����d�S賮����8�Õf1�>S�ŵӉk�m�D A����t �O.��V;H����0�52�/�*�:߽���̕[�Q��G�?!XWݧ�&��!�5<fF��Щ�^#��mȿQ�B��t^���f��4\��
|
1
|
+
�%�
|