Module: Typecast
- Defined in:
- lib/typecast/client.rb,
lib/typecast/errors.rb,
lib/typecast/models.rb,
lib/typecast/version.rb,
lib/typecast/composer.rb,
lib/typecast/timestamps.rb
Defined Under Namespace
Modules: Models Classes: ApiError, BadRequestError, Client, InternalServerError, NotFoundError, PausePart, PaymentRequiredError, RateLimitError, SpeechComposer, TextPart, UnauthorizedError, UnprocessableEntityError
Constant Summary collapse
- VERSION =
"0.1.0"- PAUSE_TOKEN =
/<\|(\d+(?:\.\d+)?)s\|>/.freeze
Class Method Summary collapse
Class Method Details
.parse_pause_markup(text) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/typecast/composer.rb', line 11 def self.parse_pause_markup(text) parts = [] last_index = 0 text.to_s.scan(PAUSE_TOKEN) do |match| match_data = Regexp.last_match if match_data.begin(0) > last_index parts << TextPart.new(kind: "text", text: text[last_index...match_data.begin(0)]) end parts << PausePart.new(kind: "pause", seconds: match[0].to_f) last_index = match_data.end(0) end if last_index < text.length parts << TextPart.new(kind: "text", text: text[last_index..-1]) end parts end |