medieval_latina 2.0.5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f310cf2079aed1bdaa591c79e409ccef4ec3103b1f0f358f3dd67dc834d2d42f
4
- data.tar.gz: beced7869d04c3bfb10a565aa5cb2f2f6302d4709826d96e2cd01907db57f155
3
+ metadata.gz: 67adc073d1a06863e460da73ddfb00d371e64e532ca14f94e7216f16d1d7ecd2
4
+ data.tar.gz: cfc8ece414f505202c055606561a9e62b366c9f31431f6b5aa4bf8de40cf3eb1
5
5
  SHA512:
6
- metadata.gz: 2efc132b60e9d2cc4379c78162acd4f8a031619cab150c00553a61d0480ba23592955e4334806b6a36c89720dfc747cc2fc58c7745a8f27f3e29be05acf8f16f
7
- data.tar.gz: 6c750f532cde017ca033243c3321a5bbc26a2e9a896e2e8031a264b095f3c7a5739d4c9e5af27beaff91eb09db15a0589af92b263e71f2c9ea3d80b4ad349459
6
+ metadata.gz: 7c3e709b58bce1ca4d8bdce5c166a15f5eafa7a0db327452389b991ee7cfec1f242b39aee6814d9f5fab508c19413a7dbf1bcad38df77da92f7efc22a0315b86
7
+ data.tar.gz: d931c5f2b959b70c11fd9e4da3d3b970e48f34a2bba6fb47639b1e6c787137d8e62e92d3ccacf9230ff08c63f71666c2fbe56d3ebe50e772eadbd1297fc9f1a6
data/.DS_Store ADDED
Binary file
@@ -19,16 +19,12 @@ jobs:
19
19
  - macos
20
20
  - ubuntu
21
21
  ruby:
22
- - 2.7
23
22
  - 3.0
24
23
  - 3.1
25
24
  - 3.2
25
+ - 3.3
26
26
  allow_failures:
27
27
  - false
28
- include:
29
- - os: ubuntu
30
- ruby: ruby-head
31
- allow_failures: true
32
28
  env:
33
29
  BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
34
30
  ALLOW_FAILURES: "${{ matrix.allow_failures }}"
data/.standard.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  fix: true
2
2
  parallel: true
3
- ruby_version: 2.6
3
+ ruby_version: 3.0
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.2.0
1
+ ruby 3.3.0
data/Gemfile CHANGED
@@ -2,8 +2,3 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in medieval_latina.gemspec
4
4
  gemspec
5
-
6
- gem "i18n"
7
- gem "rake", "~> 12.0"
8
- gem "rspec", "~> 3.0"
9
- gem "standard", group: [:development, :test]
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- medieval_latina (2.0.5)
4
+ medieval_latina (3.0.0)
5
5
  i18n
6
6
 
7
7
  GEM
@@ -12,9 +12,14 @@ GEM
12
12
  diff-lcs (1.3)
13
13
  i18n (1.13.0)
14
14
  concurrent-ruby (~> 1.0)
15
+ mini_portile2 (2.8.6)
16
+ nokogiri (1.16.4)
17
+ mini_portile2 (~> 2.8.2)
18
+ racc (~> 1.4)
15
19
  parallel (1.19.1)
16
20
  parser (2.7.1.2)
17
21
  ast (~> 2.4.0)
22
+ racc (1.7.3)
18
23
  rainbow (3.0.0)
19
24
  rake (12.3.3)
20
25
  rexml (3.2.5)
@@ -50,8 +55,8 @@ PLATFORMS
50
55
  ruby
51
56
 
52
57
  DEPENDENCIES
53
- i18n
54
58
  medieval_latina!
59
+ nokogiri
55
60
  rake (~> 12.0)
56
61
  rspec (~> 3.0)
57
62
  standard
data/README.md CHANGED
@@ -21,12 +21,57 @@ Or install it yourself as:
21
21
 
22
22
  ## Usage
23
23
 
24
+ ### Help English language text-to-speech engines pronounce Latin
24
25
  ```ruby
25
26
  ["caelum", "omnia", "pugno"].each { |word| puts MedievalLatina[word] }
26
27
  => "chayloom"
27
28
  => "ohm-nia"
28
29
  => "poon-yoh"
29
30
 
31
+ sentence = MedievalLatina["sed libera nos a malo"]
32
+ => "sayd leebayrah nohs ah mahloh"
33
+ ```
34
+ ```javascript
35
+ let sentence = "...";
36
+ responsiveVoice.speak(sentence, "UK English Female");
37
+ ```
38
+ ### Generate lexicons to override text-to-speech pronunciation
39
+ ```ruby
40
+ polly = Aws::Polly::Client.new
41
+ s3 = Aws::S3::Client.new
42
+
43
+ sentence = "PATER NOSTER qui es in caelis"
44
+
45
+ words = sentence.split(" ")
46
+ pronunciations = MedievalLatina.pronunciations_for(words)
47
+ lexicon = MedievalLatina::LexiconBuilder.new(pronunciations).call
48
+
49
+ name = "CustomLatin"
50
+ polly.put_lexicon(name: name, content: lexicon.to_s)
51
+
52
+ # Synthesize speech using the lexicons
53
+ response = polly.synthesize_speech(
54
+ lexicon_names: [name],
55
+ text: sentence,
56
+ output_format: "mp3",
57
+ voice_id: "Joanna"
58
+ )
59
+
60
+ # Read the audio data and store it in a variable
61
+ audio_data = response.audio_stream.read
62
+
63
+ bucket_name = "foo"
64
+ object_key = "bar/pater-noster.mp3"
65
+
66
+ s3.put_object(
67
+ bucket: bucket_name,
68
+ key: object_key,
69
+ body: audio_data
70
+ )
71
+ ```
72
+
73
+ ### Latin langauge helper methods
74
+ ```ruby
30
75
  MedievalLatina.verb?("voco")
31
76
  => true
32
77
 
@@ -48,6 +93,7 @@ MedievalLatina.noun?("canis")
48
93
  After checking out the repo, run `bin/setup` to install dependencies.
49
94
  Then, run `rake spec` to run the tests.
50
95
  You can also run `bin/console` for an interactive prompt that will allow you to experiment.
96
+ Maintain project style by running `bin/lint` before commiting changes.
51
97
 
52
98
  To install this gem onto your local machine, run `bundle exec rake install`.
53
99
 
@@ -56,6 +102,9 @@ To release a new version:
56
102
  2. Run `bin/setup` to increment the version in the lock file
57
103
  3. Run `bundle exec rake release`
58
104
 
105
+ Rebuild the lexicon files when you add new International Phonetic Alphabet pronunciations.
106
+ You do this by running: `bin/build`
107
+
59
108
  ## Contributing
60
109
 
61
110
  Bug reports and pull requests are welcome on GitHub at https://github.com/jaysonvirissimo/medieval_latina.
data/bin/build ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'json'
4
+ require "bundler/setup"
5
+ require "medieval_latina"
6
+ require "medieval_latina/lexicon_builder"
7
+
8
+ def create_pls_file(file_path, words)
9
+ document = MedievalLatina::LexiconBuilder.new(words).call
10
+
11
+ File.open(file_path, 'w') do |file|
12
+ document.write(file, 2)
13
+ file.write("\n")
14
+ end
15
+ end
16
+
17
+ file_path = File.join(File.dirname(__FILE__), '..', 'data', 'dictionary.json')
18
+ pronunciation_guide = JSON
19
+ .parse(File.read(file_path))
20
+ .each_with_object({}) do |(word, metadata), hash|
21
+ if metadata["ipa"]
22
+ hash[word] = metadata["ipa"]
23
+ end
24
+ end
25
+
26
+ # Split the words across multiple PLS files
27
+ lexicons_dir = File.join(File.dirname(__FILE__), '..', 'lexicons')
28
+ size = pronunciation_guide.size
29
+ number = size / 256
30
+ fraction = size / number
31
+ pronunciation_guide.each_slice(fraction).to_a.each_with_index do |array, index|
32
+ formatted_index = sprintf("%02d", index)
33
+ create_pls_file(File.join(lexicons_dir, "Latin#{formatted_index}.pls"), array.to_h)
34
+ end
data/bin/lint ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ standardrb --fix