Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
emcgee authored Jul 30, 2018
2 parents bfad98e + 5756254 commit 1c72ef1
Show file tree
Hide file tree
Showing 53 changed files with 903 additions and 630 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.gem
*.bundle
*.jar
*.so
Gemfile.lock
pkg/*
spec/reports
Expand Down
25 changes: 17 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
language: ruby

rvm:
- 1.9.3
- 2.0.0
- 2.1.0
- jruby
- rbx
- 2.1.10
- 2.2.10
- 2.3.7
- 2.4.4
- jruby-9.1.17.0
- jruby-head
- rbx-3
- ruby-head
jdk:
- openjdk8 # for jruby
matrix:
allow_failures:
- rvm: rbx-3
- rvm: ruby-head
sudo: false
addons:
apt:
packages:
- libpcre3
- libpcre3-dev
before_install:
- sudo apt-get install libpcre3 libpcre3-dev

- gem install bundler
notifications:
irc: "irc.freenode.org#adhearsion"
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# [develop](https://github.com/benlangfeld/ruby_speech)
* Bugfix: Fix grammar parsing error where MATCH_END is returned even when a partial match exists on a separate item

# [3.0.0](https://github.com/benlangfeld/ruby_speech/compare/v2.4.0...v3.0.0) - [2018-07-10](https://rubygems.org/gems/ruby_speech/versions/3.0.0)
* Feature: Loosen and bump Nokogiri version to ~>1.8, >=1.8.3
* Feature: Bump RSpec to 3.x and convert specs with Transpec

# [2.4.0](https://github.com/benlangfeld/ruby_speech/compare/v2.3.2...v2.4.0) - [2018-02-23](https://rubygems.org/gems/ruby_speech/versions/2.4.0)
* Feature: Permit percentage rate values for prosody tags
* Bugfix: Rulerefs referenced n-levels deep under Rulerefs should be expanded.
* Bugfix: Optimize performance of built-in number DTMF grammar
* Bugfix: Fix handling of millisecond values

# [2.3.2](https://github.com/benlangfeld/ruby_speech/compare/v2.3.1...v2.3.2) - [2014-04-21](https://rubygems.org/gems/ruby_speech/versions/2.3.2)
* Bugfix: String nodes should take non-strings and cast to a string (`#to_s`)
* Bugfix: Cleanly handle NLSML with no input tag
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![Gem Version](https://badge.fury.io/rb/ruby_speech.png)](https://rubygems.org/gems/ruby_speech)
[![Build Status](https://secure.travis-ci.org/benlangfeld/ruby_speech.png?branch=develop)](http://travis-ci.org/benlangfeld/ruby_speech)
[![Dependency Status](https://gemnasium.com/benlangfeld/ruby_speech.png?travis)](https://gemnasium.com/benlangfeld/ruby_speech)
[![Code Climate](https://codeclimate.com/github/benlangfeld/ruby_speech.png)](https://codeclimate.com/github/benlangfeld/ruby_speech)
[![Coverage Status](https://coveralls.io/repos/benlangfeld/ruby_speech/badge.png?branch=develop)](https://coveralls.io/r/benlangfeld/ruby_speech)
[![Build Status](https://secure.travis-ci.org/adhearsion/ruby_speech.png?branch=develop)](http://travis-ci.org/adhearsion/ruby_speech)
[![Dependency Status](https://gemnasium.com/adhearsion/ruby_speech.png?travis)](https://gemnasium.com/adhearsion/ruby_speech)
[![Code Climate](https://codeclimate.com/github/adhearsion/ruby_speech.png)](https://codeclimate.com/github/adhearsion/ruby_speech)
[![Coverage Status](https://coveralls.io/repos/adhearsion/ruby_speech/badge.png?branch=develop)](https://coveralls.io/r/adhearsion/ruby_speech)

# RubySpeech
RubySpeech is a library for constructing and parsing Text to Speech (TTS) and Automatic Speech Recognition (ASR) documents such as [SSML](http://www.w3.org/TR/speech-synthesis), [GRXML](http://www.w3.org/TR/speech-grammar/) and [NLSML](http://www.w3.org/TR/nl-spec/). Such documents can be constructed to be processed by TTS and ASR engines, parsed as the result from such, or used in the implementation of such engines.
Expand Down Expand Up @@ -30,8 +30,8 @@ sudo yum install pcre-devel
gem install ruby_speech

## Ruby Version Compatability
* CRuby 1.9.3+ (1.9.2 is unofficially supported, but not regularly tested)
* JRuby 1.7+
* CRuby 2.1+
* JRuby 9.1+

## Library

Expand Down Expand Up @@ -331,7 +331,7 @@ document.best_interpretation # => {
}
```

Check out the [YARD documentation](http://rdoc.info/github/benlangfeld/ruby_speech/master/frames) for more
Check out the [YARD documentation](http://rdoc.info/github/adhearsion/ruby_speech/master/frames) for more

## Features:
### SSML
Expand Down Expand Up @@ -374,10 +374,10 @@ Check out the [YARD documentation](http://rdoc.info/github/benlangfeld/ruby_spee
* `<lexicon/>`

## Links:
* [Source](https://github.com/benlangfeld/ruby_speech)
* [Source](https://github.com/adhearsion/ruby_speech)
* [Documentation](http://rdoc.info/gems/ruby_speech/frames)
* [Bug Tracker](https://github.com/benlangfeld/ruby_speech/issues)
* [CI](https://travis-ci.org/#!/benlangfeld/ruby_speech)
* [Bug Tracker](https://github.com/adhearsion/ruby_speech/issues)
* [CI](https://travis-ci.org/#!/adhearsion/ruby_speech)

## Note on Patches/Pull Requests

Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ if RUBY_PLATFORM =~ /java/
require 'rake/javaextensiontask'
Rake::JavaExtensionTask.new 'ruby_speech' do |ext|
ext.lib_dir = 'lib/ruby_speech'
ext.source_version = '1.6'
ext.target_version = '1.6'
end
else
require 'rake/extensiontask'
Expand Down
2 changes: 1 addition & 1 deletion ext/ruby_speech/RubySpeechGRXMLMatcher.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.benlangfeld.ruby_speech;
package com.adhearsion.ruby_speech;

import org.jruby.Ruby;
import org.jruby.RubyClass;
Expand Down
2 changes: 1 addition & 1 deletion ext/ruby_speech/RubySpeechService.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.benlangfeld.ruby_speech;
package com.adhearsion.ruby_speech;

import org.jruby.Ruby;
import org.jruby.RubyClass;
Expand Down
2 changes: 1 addition & 1 deletion ext/ruby_speech/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$LIBS << " -lpcre"

unless find_header('pcre.h')
abort "-----\nPCRE is missing. You must install it as per the README @ https://github.com/benlangfeld/ruby_speech\n-----"
abort "-----\nPCRE is missing. You must install it as per the README @ https://github.com/adhearsion/ruby_speech\n-----"
end

create_makefile 'ruby_speech/ruby_speech'
2 changes: 2 additions & 0 deletions lib/ruby_speech/grxml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
module RubySpeech
module GRXML
InvalidChildError = Class.new StandardError
MissingReferenceError = Class.new StandardError
ReferentialLoopError = Class.new StandardError

GRXML_NAMESPACE = 'http://www.w3.org/2001/06/grammar'

Expand Down
29 changes: 18 additions & 11 deletions lib/ruby_speech/grxml/builtins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def self.date(options = nil)
# @option options [#to_i] :maxlength Maximum length for the string of digits.
# @option options [#to_i] :length Absolute length for the string of digits.
#
# @return [RubySpeech::GRXML::Grammar] a grammar for interpreting a boolean response.
# @return [RubySpeech::GRXML::Grammar] a grammar for interpreting an integer
# response.
#
# @raise [ArgumentError] if any of the length attributes logically conflict
#
Expand Down Expand Up @@ -118,22 +119,28 @@ def self.currency(options = nil)
def self.number(options = nil)
RubySpeech::GRXML.draw mode: :dtmf, root: 'number' do
rule id: 'number', scope: 'public' do
item repeat: '0-' do
ruleref uri: '#digit'
one_of do
item { ruleref uri: '#less_than_one' }
item { ruleref uri: '#one_or_more' }
end
end

rule id: 'less_than_one' do
item { '*' }
item { ruleref uri: '#digit_series' }
end

rule id: 'one_or_more' do
item { ruleref uri: '#digit_series' }
item repeat: '0-1' do
item { '*' }
item repeat: '0-' do
ruleref uri: '#digit'
end
item(repeat: '0-1') { ruleref uri: '#digit_series' }
end
end

rule id: 'digit' do
one_of do
0.upto(9) { |d| item { d.to_s } }
end
end
rule(id: 'digit_series') { item(repeat: '1-') { ruleref uri: '#digit' } }

rule(id: 'digit') { one_of { 0.upto(9) { |d| item { d.to_s } } } }
end
end

Expand Down
30 changes: 26 additions & 4 deletions lib/ruby_speech/grxml/grammar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,39 @@ def inline
# Replaces rulerefs in the document with a copy of the original rule.
# Removes all top level rules except the root rule
#
# @raises [MissingReferenceError] if a ruleref references a rule that is
# not defined.
# @raises [ReferentialLoopError] if rulerefs create a referencial cycle.
#
# @return self
#
def inline!
xpath("//ns:ruleref", :ns => GRXML_NAMESPACE).each do |ref|
rule = rule_with_id ref[:uri].sub(/^#/, '')
ref.swap rule.dup.children
previous_uris = {}
loop do
rule = nil
uris = {}
xpath('//ns:ruleref', ns: GRXML_NAMESPACE).each do |ref|
uri = ref[:uri].sub(/^#/, '')
uris[uri] = 1
rule = rule_with_id uri
unless rule
raise MissingReferenceError,
"Ruleref '##{uri}' is referenced but not defined"
end
ref.swap rule.dup.children
end
break unless rule
if previous_uris.keys.eql? uris.keys
raise ReferentialLoopError,
'GRXML document contains cycles with ruleref(s): ' <<
uris.keys.join(', ')
end
previous_uris = uris
end

query = "./ns:rule[@id!='#{root}']"
query += "|./ns:rule[@ns:id!='#{root}']" if Nokogiri.jruby?
non_root_rules = xpath query, :ns => namespace_href
non_root_rules = xpath query, ns: namespace_href
non_root_rules.remove

self
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_speech/grxml/matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

if RUBY_PLATFORM =~ /java/
require 'jruby'
com.benlangfeld.ruby_speech.RubySpeechService.new.basicLoad(JRuby.runtime)
com.adhearsion.ruby_speech.RubySpeechService.new.basicLoad(JRuby.runtime)
end

module RubySpeech
Expand Down
3 changes: 1 addition & 2 deletions lib/ruby_speech/ssml/break.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def strength=(s)
# @return [Float]
#
def time
read_attr :time, :to_f
get_time_attribute :time
end

##
Expand All @@ -50,7 +50,6 @@ def time=(t)

def <<(*args)
raise InvalidChildError, "A Break cannot contain children"
super
end

def eql?(o)
Expand Down
14 changes: 13 additions & 1 deletion lib/ruby_speech/ssml/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,21 @@ def to_doc

private

def get_time_attribute(key)
value = read_attr(key)

if value.nil?
nil
elsif value.end_with?('ms')
value.to_f / 1000
else
value.to_f
end
end

def set_time_attribute(key, value)
raise ArgumentError, "You must specify a valid #{key} (positive float value in seconds)" unless value.is_a?(Numeric) && value >= 0
self[key] = "#{value}s"
self[key] = value == value.round ? "#{value.to_i}s" : "#{(value * 1000).to_i}ms"
end
end # Element
end # SSML
Expand Down
1 change: 0 additions & 1 deletion lib/ruby_speech/ssml/mark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def name=(other)

def <<(*args)
raise InvalidChildError, "A Mark cannot contain children"
super
end

def eql?(o)
Expand Down
13 changes: 8 additions & 5 deletions lib/ruby_speech/ssml/prosody.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,29 @@ def range=(p)
end

##
# A change in the speaking rate for the contained text. Legal values are: a relative change or "x-slow", "slow", "medium", "fast", "x-fast", or "default". Labels "x-slow" through "x-fast" represent a sequence of monotonically non-decreasing speaking rates. When a number is used to specify a relative change it acts as a multiplier of the default rate. For example, a value of 1 means no change in speaking rate, a value of 2 means a speaking rate twice the default rate, and a value of 0.5 means a speaking rate of half the default rate. The default rate for a voice depends on the language and dialect and on the personality of the voice. The default rate for a voice should be such that it is experienced as a normal speaking rate for the voice when reading aloud text. Since voices are processor-specific, the default rate will be as well.
# A change in the speaking rate for the contained text. Legal values are: a relative change or "x-slow", "slow", "medium", "fast", "x-fast", or "default". Labels "x-slow" through "x-fast" represent a sequence of monotonically non-decreasing speaking rates. When a number is used to specify a relative change it acts as a multiplier of the default rate. For example, a value of 1 means no change in speaking rate, a value of 2 means a speaking rate twice the default rate, and a value of 0.5 means a speaking rate of half the default rate. Further, changes can be specified as percentages (e.g. '10%' or '+15%'), but these are the only string entries permitted. The default rate for a voice depends on the language and dialect and on the personality of the voice. The default rate for a voice should be such that it is experienced as a normal speaking rate for the voice when reading aloud text. Since voices are processor-specific, the default rate will be as well.
#
# @return [Symbol, Float]
# @return [Symbol, Float, String]
#
def rate
value = read_attr :rate
return unless value
if VALID_RATES.include?(value.to_sym)
value.to_sym
elsif value.include? "%"
value
else
value.to_f
end
end

##
# @param [Symbol, Numeric] v
# @param [Symbol, Numeric, String] v
#
# @raises ArgumentError if v is not either a positive Numeric or one of VALID_RATES
#
def rate=(v)
raise ArgumentError, "You must specify a valid rate ([positive-number](multiplier), #{VALID_RATES.map(&:inspect).join ', '})" unless (v.is_a?(Numeric) && v >= 0) || VALID_RATES.include?(v)
raise ArgumentError, "You must specify a valid rate ([positive-number](multiplier), #{VALID_RATES.map(&:inspect).join ', '})" unless (v.is_a?(Numeric) && v >= 0) || VALID_RATES.include?(v) || (v.is_a?(String) && v.include?("%"))
self[:rate] = v
end

Expand All @@ -132,7 +134,8 @@ def rate=(v)
# @return [Integer]
#
def duration
read_attr :duration, :to_i
value = get_time_attribute :duration
value.round if value
end

##
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_speech/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module RubySpeech
VERSION = "2.3.2"
VERSION = "3.0.0"
end
13 changes: 10 additions & 3 deletions ruby_speech.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.version = RubySpeech::VERSION
s.authors = ["Ben Langfeld"]
s.email = ["[email protected]"]
s.homepage = "https://github.com/benlangfeld/ruby_speech"
s.homepage = "https://github.com/adhearsion/ruby_speech"
s.summary = %q{A Ruby library for TTS & ASR document preparation}
s.description = %q{Prepare SSML and GRXML documents with ease}

Expand All @@ -27,18 +27,25 @@ Gem::Specification.new do |s|
s.extensions = ['ext/ruby_speech/extconf.rb']
end

s.add_runtime_dependency %q<nokogiri>, ["~> 1.6"]
s.add_runtime_dependency %q<nokogiri>, ["~> 1.8", ">= 1.8.3"]
s.add_runtime_dependency %q<activesupport>, [">= 3.0.7", "< 5.0.0"]

s.add_development_dependency %q<bundler>, [">= 1.0.0"]
s.add_development_dependency %q<rspec>, ["~> 2.7"]
s.add_development_dependency %q<rspec>, ["~> 3.0"]
s.add_development_dependency %q<rspec-its>, [">= 0"]
s.add_development_dependency %q<ci_reporter>, ["~> 1.6"]
s.add_development_dependency %q<yard>, [">= 0.7.0"]
s.add_development_dependency %q<rake>, [">= 0"]
s.add_development_dependency %q<guard>, [">= 0.9.0"]
s.add_development_dependency %q<guard-rspec>, [">= 0"]
s.add_development_dependency %q<listen>, ["< 3.1.0"]
s.add_development_dependency %q<ruby_gntp>, [">= 0"]
s.add_development_dependency %q<guard-rake>, [">= 0"]
s.add_development_dependency %q<rake-compiler>, [">= 0"]
s.add_development_dependency %q<coveralls>, [">= 0"]

if RUBY_VERSION < '2.0'
s.add_development_dependency %q<term-ansicolor>, ["< 1.3.1"]
s.add_development_dependency %q<tins>, ["~> 1.6.0"]
end
end
Loading

0 comments on commit 1c72ef1

Please sign in to comment.