glaemscribe 1.1.14 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +5 -5
  2. data/bin/glaemscribe +21 -17
  3. data/glaemresources/charsets/cirth_ds.cst +540 -0
  4. data/glaemresources/charsets/eldamar.cst +210 -0
  5. data/glaemresources/charsets/sarati_eldamar.cst +256 -0
  6. data/glaemresources/charsets/tengwar_ds_annatar.cst +2868 -0
  7. data/glaemresources/charsets/tengwar_ds_eldamar.cst +2729 -0
  8. data/glaemresources/charsets/tengwar_ds_elfica.cst +2742 -0
  9. data/glaemresources/charsets/tengwar_ds_parmaite.cst +2726 -0
  10. data/glaemresources/charsets/tengwar_ds_sindarin.cst +2722 -0
  11. data/glaemresources/charsets/tengwar_freemono.cst +217 -0
  12. data/glaemresources/charsets/tengwar_guni_annatar.cst +2948 -0
  13. data/glaemresources/charsets/tengwar_guni_eldamar.cst +2809 -0
  14. data/glaemresources/charsets/tengwar_guni_elfica.cst +2809 -0
  15. data/glaemresources/charsets/tengwar_guni_parmaite.cst +2813 -0
  16. data/glaemresources/charsets/tengwar_guni_sindarin.cst +2808 -0
  17. data/glaemresources/charsets/tengwar_telcontar.cst +225 -0
  18. data/glaemresources/charsets/unicode_gothic.cst +64 -0
  19. data/glaemresources/charsets/unicode_runes.cst +121 -0
  20. data/glaemresources/modes/{adunaic.glaem → adunaic-tengwar-glaemscrafu.glaem} +14 -2
  21. data/glaemresources/modes/{blackspeech.glaem → blackspeech-tengwar-general_use.glaem} +13 -3
  22. data/glaemresources/modes/english-cirth-espeak.glaem +687 -0
  23. data/glaemresources/modes/english-tengwar-espeak.glaem +814 -0
  24. data/glaemresources/modes/japanese-tengwar.glaem +776 -0
  25. data/glaemresources/modes/{khuzdul.glaem → khuzdul-cirth-moria.glaem} +4 -1
  26. data/glaemresources/modes/lang_belta-tengwar-dadef.glaem +248 -0
  27. data/glaemresources/modes/{futhorc.glaem → old_english-futhorc.glaem} +0 -0
  28. data/glaemresources/modes/{mercian.glaem → old_english-tengwar-mercian.glaem} +22 -12
  29. data/glaemresources/modes/{westsaxon.glaem → old_english-tengwar-westsaxon.glaem} +20 -11
  30. data/glaemresources/modes/{futhark-runicus.glaem → old_norse-futhark-runicus.glaem} +0 -0
  31. data/glaemresources/modes/{futhark-younger.glaem → old_norse-futhark-younger.glaem} +0 -0
  32. data/glaemresources/modes/{quenya.glaem → quenya-tengwar-classical.glaem} +32 -50
  33. data/glaemresources/modes/raw-cirth.glaem +154 -0
  34. data/glaemresources/modes/raw-tengwar.glaem +46 -23
  35. data/glaemresources/modes/{rlyehian.glaem → rlyehian-tengwar.glaem} +14 -3
  36. data/glaemresources/modes/{sindarin-daeron.glaem → sindarin-cirth-daeron.glaem} +55 -14
  37. data/glaemresources/modes/{sindarin-beleriand.glaem → sindarin-tengwar-beleriand.glaem} +154 -28
  38. data/glaemresources/modes/{sindarin.glaem → sindarin-tengwar-general_use.glaem} +86 -25
  39. data/glaemresources/modes/{telerin.glaem → telerin-tengwar-glaemscrafu.glaem} +16 -6
  40. data/glaemresources/modes/{westron.glaem → westron-tengwar-glaemscrafu.glaem} +18 -8
  41. data/lib/api/charset.rb +67 -7
  42. data/lib/api/charset_parser.rb +14 -1
  43. data/lib/api/constants.rb +3 -4
  44. data/lib/api/fragment.rb +26 -5
  45. data/lib/api/if_tree.rb +70 -8
  46. data/lib/api/macro.rb +40 -0
  47. data/lib/api/mode.rb +66 -19
  48. data/lib/api/mode_parser.rb +117 -14
  49. data/lib/api/object_additions.rb +23 -1
  50. data/lib/api/option.rb +17 -2
  51. data/lib/api/post_processor/outspace.rb +44 -0
  52. data/lib/api/post_processor/resolve_virtuals.rb +25 -9
  53. data/lib/api/resource_manager.rb +1 -0
  54. data/lib/api/rule_group.rb +170 -26
  55. data/lib/api/sheaf_chain_iterator.rb +1 -1
  56. data/lib/api/transcription_pre_post_processor.rb +8 -5
  57. data/lib/api/transcription_processor.rb +15 -12
  58. data/lib/api/tts.rb +51 -0
  59. data/lib/glaemscribe.rb +36 -31
  60. data/lib_espeak/espeakng.for.glaemscribe.nowasm.sync.js +35 -0
  61. data/lib_espeak/glaemscribe_tts.js +505 -0
  62. metadata +76 -24
@@ -43,8 +43,8 @@ module Glaemscribe
43
43
  @transcription_tree = TranscriptionTreeNode.new(nil,nil)
44
44
 
45
45
  # Add WORD_BOUNDARY and WORD_BREAKER in the tree
46
- @transcription_tree.add_subpath(WORD_BOUNDARY, [""])
47
- @transcription_tree.add_subpath(WORD_BREAKER, [""])
46
+ @transcription_tree.add_subpath(WORD_BOUNDARY_TREE, [""])
47
+ @transcription_tree.add_subpath(WORD_BREAKER, [""])
48
48
 
49
49
  rule_groups.each{ |rgname, rg|
50
50
  rg.finalize(trans_options)
@@ -73,7 +73,7 @@ module Glaemscribe
73
73
  }
74
74
  end
75
75
 
76
- def apply(l)
76
+ def apply(l, debug_context)
77
77
  ret = []
78
78
  current_group = nil
79
79
  accumulated_word = ""
@@ -81,14 +81,14 @@ module Glaemscribe
81
81
  l.split("").each{ |c|
82
82
  case c
83
83
  when " ", "\t"
84
- ret += transcribe_word(accumulated_word)
84
+ ret += transcribe_word(accumulated_word, debug_context)
85
85
  ret += ["*SPACE"]
86
86
 
87
87
  accumulated_word = ""
88
88
  when "\r"
89
89
  # Ignore
90
90
  when "\n"
91
- ret += transcribe_word(accumulated_word)
91
+ ret += transcribe_word(accumulated_word, debug_context)
92
92
  ret += ["*LF"]
93
93
 
94
94
  accumulated_word = ""
@@ -97,24 +97,27 @@ module Glaemscribe
97
97
  if c_group == current_group
98
98
  accumulated_word += c
99
99
  else
100
- ret += transcribe_word(accumulated_word)
100
+ ret += transcribe_word(accumulated_word, debug_context)
101
101
  current_group = c_group
102
102
  accumulated_word = c
103
103
  end
104
104
  end
105
105
  }
106
106
  # Just in case
107
- ret += transcribe_word(accumulated_word)
107
+ ret += transcribe_word(accumulated_word, debug_context)
108
108
  ret
109
109
  end
110
110
 
111
- def transcribe_word(word)
111
+ def transcribe_word(word, debug_context)
112
112
  res = []
113
- word = WORD_BOUNDARY + word + WORD_BOUNDARY
113
+ word = WORD_BOUNDARY_TREE + word + WORD_BOUNDARY_TREE
114
114
  while word.length != 0
115
- r, len = @transcription_tree.transcribe(word)
116
- word = word[len..-1]
117
- res += r
115
+ tokens, len = @transcription_tree.transcribe(word)
116
+ word = word[len..-1]
117
+ eaten = word[0..len-1]
118
+ res += tokens
119
+
120
+ debug_context.processor_pathes << [eaten, tokens, tokens]
118
121
  end
119
122
  # Return token list
120
123
  res
data/lib/api/tts.rb ADDED
@@ -0,0 +1,51 @@
1
+ module Glaemscribe
2
+ module API
3
+
4
+ class TTS
5
+
6
+ TTS_ENGINE_PATH = File.dirname(__FILE__) + "/../../lib_espeak/espeakng.for.glaemscribe.nowasm.sync.js"
7
+ TTS_MODULE_PATH = File.dirname(__FILE__) + "/../../lib_espeak/glaemscribe_tts.js"
8
+
9
+ def self.loaded?
10
+ !@context.nil?
11
+ end
12
+
13
+ def self.load_engine
14
+ return if @context
15
+
16
+ @context = ::MiniRacer::Context.new
17
+
18
+ @context.attach 'console.log', proc{|o| puts o}
19
+ @context.attach 'print', proc{|o| puts o}
20
+
21
+ espeak_lib = File.open(TTS_ENGINE_PATH,"rb").read
22
+ @context.eval(espeak_lib)
23
+
24
+ tts_module = File.open(TTS_MODULE_PATH,"rb").read
25
+ @context.eval(tts_module)
26
+
27
+ @voice_list = @context.eval("Glaemscribe.TTS.voice_list()")
28
+ # puts "TTS Engine loaded."
29
+ end
30
+
31
+ def self.voice_list
32
+ load_engine if !@context
33
+ @voice_list
34
+ end
35
+
36
+ def self.ipa(text, voice, has_raw_mode)
37
+ load_engine if !@context
38
+ @context.eval("var esp = new Glaemscribe.TTS(); esp.synthesize_ipa(#{text.inspect},{voice:'#{voice}', has_raw_mode: #{has_raw_mode}})")
39
+ end
40
+
41
+ def self.wav(text, voice, has_raw_mode)
42
+ load_engine if !@context
43
+ @context.eval("var esp = new Glaemscribe.TTS(); esp.synthesize_wav(#{text.inspect},{voice:'#{voice}', has_raw_mode: #{has_raw_mode}})")
44
+ end
45
+
46
+ def self.option_name_to_voice(option_name)
47
+ option_name.downcase.gsub(/^espeak_voice_/,'').gsub('_','-')
48
+ end
49
+ end
50
+ end
51
+ end
data/lib/glaemscribe.rb CHANGED
@@ -28,46 +28,51 @@ require "FileUtils" if !defined? FileUtils
28
28
 
29
29
  module Glaemscribe
30
30
  module API
31
- API_PATH = File.dirname(__FILE__)
31
+ API_PATH = File.dirname(__FILE__) + "/api/"
32
32
 
33
- require API_PATH + "/api/debug.rb"
34
- require API_PATH + "/api/constants.rb"
35
- require API_PATH + "/api/object_additions.rb"
33
+ require API_PATH + "debug.rb"
34
+ require API_PATH + "constants.rb"
35
+ require API_PATH + "object_additions.rb"
36
36
 
37
- require API_PATH + "/api/fragment.rb"
38
- require API_PATH + "/api/sheaf_chain_iterator.rb"
39
- require API_PATH + "/api/sheaf_chain.rb"
40
- require API_PATH + "/api/sheaf.rb"
37
+ require API_PATH + "fragment.rb"
38
+ require API_PATH + "sheaf_chain_iterator.rb"
39
+ require API_PATH + "sheaf_chain.rb"
40
+ require API_PATH + "sheaf.rb"
41
41
 
42
- require API_PATH + "/api/rule.rb"
43
- require API_PATH + "/api/sub_rule.rb"
44
- require API_PATH + "/api/rule_group.rb"
42
+ require API_PATH + "rule.rb"
43
+ require API_PATH + "sub_rule.rb"
44
+ require API_PATH + "rule_group.rb"
45
+ require API_PATH + "macro.rb"
45
46
 
46
- require API_PATH + "/api/eval.rb"
47
- require API_PATH + "/api/if_tree.rb"
47
+ require API_PATH + "eval.rb"
48
+ require API_PATH + "if_tree.rb"
48
49
 
49
- require API_PATH + "/api/transcription_tree_node.rb"
50
+ require API_PATH + "transcription_tree_node.rb"
50
51
 
51
- require API_PATH + "/api/transcription_pre_post_processor.rb"
52
- require API_PATH + "/api/transcription_processor.rb"
52
+ require API_PATH + "transcription_pre_post_processor.rb"
53
+ require API_PATH + "transcription_processor.rb"
53
54
 
54
- require API_PATH + "/api/charset.rb"
55
- require API_PATH + "/api/mode.rb"
56
- require API_PATH + "/api/option.rb"
55
+ require API_PATH + "charset.rb"
56
+ require API_PATH + "mode.rb"
57
+ require API_PATH + "option.rb"
57
58
 
58
- require API_PATH + "/api/resource_manager.rb"
59
- require API_PATH + "/api/glaeml.rb"
60
- require API_PATH + "/api/glaeml_shellwords.rb"
61
- require API_PATH + "/api/mode_parser.rb"
62
- require API_PATH + "/api/charset_parser.rb"
59
+ require API_PATH + "resource_manager.rb"
60
+ require API_PATH + "glaeml.rb"
61
+ require API_PATH + "glaeml_shellwords.rb"
62
+ require API_PATH + "mode_parser.rb"
63
+ require API_PATH + "charset_parser.rb"
63
64
 
64
- require API_PATH + "/api/pre_processor/elvish_numbers.rb"
65
- require API_PATH + "/api/pre_processor/downcase.rb"
66
- require API_PATH + "/api/pre_processor/substitute.rb"
67
- require API_PATH + "/api/pre_processor/rxsubstitute.rb"
68
- require API_PATH + "/api/pre_processor/up_down_tehta_split.rb"
69
- require API_PATH + "/api/post_processor/reverse.rb"
70
- require API_PATH + "/api/post_processor/resolve_virtuals.rb"
65
+ require API_PATH + "pre_processor/elvish_numbers.rb"
66
+ require API_PATH + "pre_processor/downcase.rb"
67
+ require API_PATH + "pre_processor/substitute.rb"
68
+ require API_PATH + "pre_processor/rxsubstitute.rb"
69
+ require API_PATH + "pre_processor/up_down_tehta_split.rb"
70
+
71
+ require API_PATH + "post_processor/outspace.rb"
72
+ require API_PATH + "post_processor/reverse.rb"
73
+ require API_PATH + "post_processor/resolve_virtuals.rb"
74
+
75
+ require API_PATH + "tts.rb"
71
76
 
72
77
  end
73
78
  end