medieval_latina 2.1.1 → 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: 73b3e247e6a3cd36e70b64ebffb4d4947f2f3f343a8749693269c32e6dd5f64b
4
- data.tar.gz: 21652459415b9160232035ca7a355dc0f4c1ffac0848f59b5793858e9c41fc0c
3
+ metadata.gz: 67adc073d1a06863e460da73ddfb00d371e64e532ca14f94e7216f16d1d7ecd2
4
+ data.tar.gz: cfc8ece414f505202c055606561a9e62b366c9f31431f6b5aa4bf8de40cf3eb1
5
5
  SHA512:
6
- metadata.gz: 5a2be43d8e45015049f7fd448626ff3800706c7b5b98f1792fe902788c2ba7a6d5a3c80d5e59d0415319f7432275d8eeaea294ad167e187486d07ab580128f79
7
- data.tar.gz: aba3e38916bc44b9603fd50fd27dd4c3ea94a0a7e23b46a5201f334b73c045019082fa9a2cd45970fa1891a6f50daf95b0caacee8066a3e72e8c8f39fc27a14a
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,9 +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 "builder", group: [:development, :test]
10
- gem "standard", group: [:development, :test]
data/Gemfile.lock CHANGED
@@ -1,21 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- medieval_latina (2.1.1)
4
+ medieval_latina (3.0.0)
5
5
  i18n
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.0)
11
- builder (3.2.4)
12
11
  concurrent-ruby (1.2.2)
13
12
  diff-lcs (1.3)
14
13
  i18n (1.13.0)
15
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)
16
19
  parallel (1.19.1)
17
20
  parser (2.7.1.2)
18
21
  ast (~> 2.4.0)
22
+ racc (1.7.3)
19
23
  rainbow (3.0.0)
20
24
  rake (12.3.3)
21
25
  rexml (3.2.5)
@@ -51,9 +55,8 @@ PLATFORMS
51
55
  ruby
52
56
 
53
57
  DEPENDENCIES
54
- builder
55
- i18n
56
58
  medieval_latina!
59
+ nokogiri
57
60
  rake (~> 12.0)
58
61
  rspec (~> 3.0)
59
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,7 +102,7 @@ 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
 
59
- Rebuild the lexicon file when you add new International Phonetic Alphabet pronunciations.
105
+ Rebuild the lexicon files when you add new International Phonetic Alphabet pronunciations.
60
106
  You do this by running: `bin/build`
61
107
 
62
108
  ## Contributing
data/bin/build CHANGED
@@ -1,7 +1,34 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'json'
3
4
  require "bundler/setup"
4
5
  require "medieval_latina"
5
6
  require "medieval_latina/lexicon_builder"
6
7
 
7
- MedievalLatina::LexiconBuilder.write
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