win32-loquendo 1.2.0-x86-mingw32 → 1.2.1-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDk1MDQ3MTJjMDMzNmZkMTZiOWM4M2M5YWFjZGM0YTQxZDIxZjk3NQ==
4
+ OWMyZTk0OWFkZmE0MTUyMDZlNmE5NTc0NDU2YTg2YzNkYzQ0N2E1Yw==
5
5
  data.tar.gz: !binary |-
6
- MmI0YjE1MjU0ZmFmYzk3ODkyNWNjOWI3YmZhMjFiMzQwOTIyNmU3OQ==
6
+ ZjI4MjU3NDc5ZDRiNTVlZmJkMTBkZmZhYTU1MGFjZWU5MDlhNWVmZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZTNmNWRjNDg5YTliODc0MDY3OTg2NTg1NDc5NGVhMmQ0NTgzMTM0MzE0NGNl
10
- N2RkMmFlMzM5NzNiZWEyMzI3NTQ5ODJjOTEwYmUyNmI3OTc4ZDA3MzUxZWI2
11
- OGRkNzczYzQ4YWY2NjQ5NzlmNTdkM2Y0MDA5YzNlZDYxMDExOTI=
9
+ ZTdjYjgxOWU1MWE5ZjkzODBjY2JjYWFmMDgyOWY5MDA5ZTQyNzEzYjljYTlm
10
+ OWJjNGM2ZDIyZDBiOTRiYTkxNzA5OWRiYTQyOTk4OTIzMjYwMzY3ZGQyNWU2
11
+ MmQ3ZTZjZjVjMWZjNjFkZmM4MDg2NTkxODVhN2MwOTRmYzFkYTU=
12
12
  data.tar.gz: !binary |-
13
- NDZkMDUwZGU5YjY4ZDk0YjQzYWNhMTM3ZGMzYzZiNGRhNDZhNTcxZDNiMDUz
14
- MjE0OTllYzA4NGZkODc4MDNmNjk0YmNlMmVjN2E2OGE2NWVjMjcyMGJmNmUz
15
- YmExZTkzODJkNTI0YzY4YWY0OTk5ZDgwOTI1NDNhNjk5ZjYzYzg=
13
+ ZDVhZDA3ZmMyNTVkYmEwNzk0NzU0MWRjMDAxMzA3ZjMyMmNkMmJjZmE2MTY2
14
+ YmQxNWQxOTliMmQ3NWQ4ZDdjMzg3YTBjOWZjZWY2YzdhNmY5MTQyZTBiMmI0
15
+ MTFiNTA4MGJlODk4YzYzODQ4Yzc4Y2JhY2M1Zjk5NzVlNDc3ZTA=
@@ -1,6 +1,11 @@
1
1
  require 'ffi'
2
2
  require 'win32/registry'
3
3
  require 'tempfile'
4
+ begin
5
+ require 'highline/system_extensions'
6
+ rescue Gem::LoadError
7
+ # not installed
8
+ end
4
9
 
5
10
  module Win32
6
11
  module Loquendo
@@ -133,7 +138,12 @@ module Win32
133
138
  end
134
139
 
135
140
  def render_speech(text, device)
136
- text = text.read if text.respond_to? :read
141
+ if text == STDIN && text.tty? && Object.const_defined?('HighLine')
142
+ text = read_unbuffered(text)
143
+ elsif text.respond_to?(:read)
144
+ text = text.read
145
+ end
146
+ text = break_long_lines(text)
137
147
  unless LoqTTS7.ttsRead(@reader_ptr, text, true, false, 0) == 0
138
148
  raise LoquendoException, "Failed to playing audio via #{device} library"
139
149
  end
@@ -143,6 +153,52 @@ module Win32
143
153
  end
144
154
  end
145
155
 
156
+ # Workaround for [windows] console, where only about 100 chars can be
157
+ # entered / buffered for each line before the console hangs. Highline
158
+ # allows us to use infinitely long lines.
159
+ def read_unbuffered(io)
160
+ h = HighLine::SystemExtensions
161
+ s = ""
162
+ while true
163
+ c = h.get_character
164
+ case c
165
+ when 3 then exit(1) # ^C
166
+ when 4,26 then break # ^D or ^Z
167
+ when 8 # BACKSPACE
168
+ print "\b \b"
169
+ s.chop!
170
+ when 10,13 # CR or LF
171
+ puts
172
+ s << "\n"
173
+ else
174
+ print c.chr
175
+ s << c
176
+ end
177
+ end
178
+ s
179
+ end
180
+
181
+ # Loquendo API doesn't support lines longer than 135 characters
182
+ def break_long_lines(s, maxlen=120)
183
+ lines = []
184
+ line = ""
185
+ s.split.each do |word|
186
+ if line.length + word.length + 1 > maxlen
187
+ lines << line unless line.empty?
188
+ while word.length > maxlen # A single word is longer than allowed
189
+ segments = word.scan(/.{1,#{maxlen}}/)
190
+ lines << segments.shift
191
+ word = segments.join
192
+ end
193
+ line = word
194
+ else
195
+ line << (line.empty? ? word : " #{word}")
196
+ end
197
+ end
198
+ lines << line
199
+ lines.join("\n")
200
+ end
201
+
146
202
  def load_voice(voice)
147
203
  unless LoqTTS7.ttsLoadPersona(@reader_ptr, voice, nil, nil) == 0
148
204
  LoqTTS7.ttsDeleteSession(nil)
@@ -1,5 +1,5 @@
1
1
  module Win32
2
2
  module Loquendo
3
- VERSION = "1.2.0"
3
+ VERSION = "1.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-loquendo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Jonas Tingeborn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-12 00:00:00.000000000 Z
11
+ date: 2014-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi