kja 0.1.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/kja.rb +100 -16
  4. data.tar.gz.sig +0 -0
  5. metadata +53 -29
  6. metadata.gz.sig +1 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 58eab7e173815f14823d340b841006386ed41617
4
- data.tar.gz: 788a8dca39d274d68e4a0171c3cabb4acb259ae3
2
+ SHA256:
3
+ metadata.gz: cf0f96cfdf4fabf09605e847917fea00ccd6d2e422653d2f5c654c4401a4d929
4
+ data.tar.gz: 117cae0553d930f9a1fe67fb632aa62ae608d191f708a6d67669c1b9045bdb26
5
5
  SHA512:
6
- metadata.gz: 42540c77cf106ef243fc4a5695bc6c76dd316813a2818785b2eb511180aaa515792b722e60e5f5c55bed0b396942897671d67453d08b42e674d0df238b529cdf
7
- data.tar.gz: ab59e32e8f1e82481c80a7a8fe6a6ecd5656a40e972007299c705204f60d7b8043f7e045f67ff84eb95f6fcde4afab39d0840ce7398b01133022990e28e8443d
6
+ metadata.gz: 45143316db18a8a22201d1bdabcd374c967f42f7d3ffa9a1a9e493e0424575378f253daaaca0e238b36c40baf24875fb2620e0e53c1b22753e58cd115ebabcac
7
+ data.tar.gz: 0ad0b442e3d3cdedd23e99087057fcbe244f955d133f8d80fdb4d10bd8b74e6bccd42d27d3aecb10ca959a0a28dd9d408f05b8fbdc92174d44f97304046307db
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/kja.rb CHANGED
@@ -2,8 +2,11 @@
2
2
 
3
3
  # file: kja.rb
4
4
 
5
+ require 'dynarex'
5
6
  require 'tempfile'
6
- require 'rxfhelper'
7
+ require 'rxfreader'
8
+ require 'kj_reading'
9
+
7
10
 
8
11
  # description: Intended for use with the kj gem
9
12
  #
@@ -24,34 +27,115 @@ require 'rxfhelper'
24
27
 
25
28
  class Kja
26
29
 
27
- def initialize(audio_player: '/usr/bin/ogg123 -q',
28
- ogg_baseurl: 'http://rorbuilder.info/r/ruby/kja/ogg')
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)
29
33
 
30
34
  @ogg_baseurl, @audio_player = ogg_baseurl, audio_player
35
+ @debug = debug
36
+
37
+ end
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
+
52
+ def duration(s)
53
+
54
+ book_title, chapter_title, verse_no = fracture(s)
55
+
56
+ url = @ogg_baseurl + '/' + File.join(book_title, chapter_title, 'dir.xml')
57
+
58
+ dx = Dynarex.new url
59
+ ogg = dx.find_by_name chapter_title + '_' + verse_no + '.ogg'
60
+ ogg.description[/\d+\.\d+$/].to_f
61
+
62
+ end
63
+
64
+ def speak(title)
65
+
66
+ a = KjReading.verses title
67
+
68
+ a.each do |x|
69
+
70
+ filename = download_ogg(x.title)
71
+ command = @audio_player + ' ' + filename
72
+ system command
73
+
74
+ end
31
75
 
32
76
  end
33
77
 
34
- def speak(s)
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
+
119
+ private
120
+
121
+ def fracture(s)
35
122
 
36
123
  book_no, book_title, chapter_no, verse_no = \
37
- s.downcase.match(/^(?:(\d) )?([\w ]+) (\d+):(\d+)/).captures
124
+ s.downcase.match(/(?:(\d) )?([\w ]+) (\d+):(\d+)$/).captures
38
125
 
126
+ book_title.gsub!(/\s/,'_')
39
127
  book_title = book_no + '_' + book_title if book_no
40
128
  chapter_title = book_title + '_' + chapter_no
41
- verse_title = chapter_title + '_' + verse_no
42
129
 
43
- ogg_filepath = File.join(book_title, chapter_title, verse_title + '.ogg')
44
- url = @ogg_baseurl + '/' + ogg_filepath
45
- audio, _ = RXFHelper.read(url)
46
-
47
- tmpfile = Tempfile.new('kva')
48
- file = File.new(tmpfile.path,'w')
49
- file.puts audio
50
- file.close
130
+ return [book_title, chapter_title, verse_no]
131
+ end
51
132
 
52
- command = @audio_player + ' ' + tmpfile.path
53
- system command
133
+ def fetch_ogg_filepath(s)
134
+
135
+ book_title, chapter_title, verse_no = fracture(s)
136
+ verse_title = chapter_title + '_' + verse_no
54
137
 
138
+ File.join(book_title, chapter_title, verse_title + '.ogg')
55
139
  end
56
140
 
57
141
  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.1.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,51 +10,76 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
13
+ MIIEljCCAv6gAwIBAgIBATANBgkqhkiG9w0BAQsFADBIMRIwEAYDVQQDDAlnZW1t
14
14
  YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE3MDYxMTEzMTUzMVoXDTE4MDYxMTEzMTUzMVowSDESMBAG
15
+ 8ixkARkWAmV1MB4XDTIyMDcxNTA3NTY0OVoXDTIzMDcxNTA3NTY0OVowSDESMBAG
16
16
  A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAK7GZ3j4h3A8ZZRfP2QrDoCpKcSrlz8TP6/swOSGfdRlEvgKSJW7bh0ux8U3
19
- /pGQiqPNPGoXSZ1cOCzTDhxOxH4X7EFCWhcJmPoi8v7ikbjKajsIMId/X8QT+/dU
20
- GG1pI8luFMk60aQTccEIFJhnZeFEPL7RC21svJSTkIb6/7ZbA3jt1KZDwXwJCRAr
21
- Ila1P7iB+ZRvl6r+zHjhgLoAPaJSEP1FyV1+h/F2A73T9wpHqvDaCt+wFcBryYba
22
- EQGfKs68qZEYVVhAXipMrP7noyFblbBnBIs/emrpHfLcM372UcuDz9e2518ysrXd
23
- 7JwAxJHVYa5vlw94+I79hECEiY8CAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
- DwQEAwIEsDAdBgNVHQ4EFgQUMffNiOr7xRYcI8Yzu833wn86Cp4wJg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GmgKGGmvzRJb2jajF4koBFdewxfxW1sbehgwvBxWMVRUOrPsIVwfBPox
26
+ pPtSPwIDAQABo4GKMIGHMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
27
+ BBSe8lWA6J1ZcIQAKZPSoBL93+XQqjAmBgNVHREEHzAdgRtnZW1tYXN0ZXJAamFt
28
+ ZXNyb2JlcnRzb24uZXUwJgYDVR0SBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
29
+ c29uLmV1MA0GCSqGSIb3DQEBCwUAA4IBgQAn2FL/3bLh1VhxGF0EU+oeAhKsOPFH
30
+ Ks2DhTw4S51ya4lAyJ0XKHft+TXWhFwG8q3by3icQsQC+dkhvhGhQ1X6UNLfdxPg
31
+ umwUfmcDKv9SUrJRUhh8FE3JzrIZ6hQaSwVg4onK/8aHinlN1fdlF/NTI7xJWBF3
32
+ lx7gtn3xeHlRRQ0LFyHafa6pqbOmGc9OXd0lx3YSia+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: 2017-06-11 00:00:00.000000000 Z
39
+ date: 2022-07-15 00:00:00.000000000 Z
35
40
  dependencies:
36
41
  - !ruby/object:Gem::Dependency
37
- name: rxfhelper
42
+ name: dynarex
38
43
  requirement: !ruby/object:Gem::Requirement
39
44
  requirements:
40
45
  - - "~>"
41
46
  - !ruby/object:Gem::Version
42
- version: '0.4'
47
+ version: '1.9'
43
48
  - - ">="
44
49
  - !ruby/object:Gem::Version
45
- version: 0.4.2
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: '0.4'
57
+ version: '1.9'
53
58
  - - ">="
54
59
  - !ruby/object:Gem::Version
55
- version: 0.4.2
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: james@jamesrobertson.eu
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
- rubyforge_project:
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 rorbuilder.info
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
- S���f![��n�jd��m�b��g���Ⴣ�/������.�i!4�3�*_�4��NTM��lޏȑA&�(��������G1,
2
- �>2�J�t&"�TR�� �邬��<^�dİ���ˬ��;I�]WٮVȥueNdE7`S���<_6���7��}���-�lJ�L�>tjJ����Q�wkCv�~�h��؝xQ8T �0��y��-l����ӥ�R8������bk�GC��?EJ=��ts���w�C��Q��m
1
+ �%�