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 +4 -4
- data/.DS_Store +0 -0
- data/.github/workflows/tests.yml +1 -5
- data/.standard.yml +1 -1
- data/.tool-versions +1 -1
- data/Gemfile +0 -6
- data/Gemfile.lock +7 -4
- data/README.md +47 -1
- data/bin/build +28 -1
- data/bin/lint +6 -0
- data/data/dictionary.json +4982 -0
- data/lexicons/Latin00.pls +2210 -0
- data/lexicons/Latin01.pls +2210 -0
- data/lexicons/Latin02.pls +2210 -0
- data/lexicons/Latin03.pls +2210 -0
- data/lexicons/Latin04.pls +2210 -0
- data/lexicons/Latin05.pls +2210 -0
- data/lexicons/Latin06.pls +2210 -0
- data/lexicons/Latin07.pls +2210 -0
- data/lexicons/Latin08.pls +2210 -0
- data/lexicons/Latin09.pls +10 -0
- data/lib/medieval_latina/lexicon.rb +27 -0
- data/lib/medieval_latina/lexicon_builder.rb +27 -44
- data/lib/medieval_latina/version.rb +1 -1
- data/lib/medieval_latina.rb +51 -20
- data/medieval_latina.gemspec +5 -1
- metadata +74 -6
- data/lexicon.pls +0 -5718
- data/lib/medieval_latina/dictionary.rb +0 -2928
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67adc073d1a06863e460da73ddfb00d371e64e532ca14f94e7216f16d1d7ecd2
|
4
|
+
data.tar.gz: cfc8ece414f505202c055606561a9e62b366c9f31431f6b5aa4bf8de40cf3eb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c3e709b58bce1ca4d8bdce5c166a15f5eafa7a0db327452389b991ee7cfec1f242b39aee6814d9f5fab508c19413a7dbf1bcad38df77da92f7efc22a0315b86
|
7
|
+
data.tar.gz: d931c5f2b959b70c11fd9e4da3d3b970e48f34a2bba6fb47639b1e6c787137d8e62e92d3ccacf9230ff08c63f71666c2fbe56d3ebe50e772eadbd1297fc9f1a6
|
data/.DS_Store
ADDED
Binary file
|
data/.github/workflows/tests.yml
CHANGED
@@ -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
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 3.
|
1
|
+
ruby 3.3.0
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,21 +1,25 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
medieval_latina (
|
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
|
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
|
-
|
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
|