├── .gitignore ├── .hound.yml ├── .rspec ├── .travis.yml ├── CHANGELOG.md ├── Gemfile ├── Guardfile ├── LICENSE.md ├── README.md ├── Rakefile ├── assets ├── grammar-core.xsd ├── grammar.xsd ├── synthesis-core.xsd ├── synthesis.xsd └── xml.xsd ├── ext └── ruby_speech │ ├── RubySpeechGRXMLMatcher.java │ ├── RubySpeechService.java │ ├── extconf.rb │ └── ruby_speech.c ├── lib ├── ruby_speech.rb └── ruby_speech │ ├── generic_element.rb │ ├── grxml.rb │ ├── grxml │ ├── builtins.rb │ ├── element.rb │ ├── grammar.rb │ ├── item.rb │ ├── match.rb │ ├── matcher.rb │ ├── max_match.rb │ ├── no_match.rb │ ├── one_of.rb │ ├── potential_match.rb │ ├── rule.rb │ ├── ruleref.rb │ ├── tag.rb │ └── token.rb │ ├── nlsml.rb │ ├── nlsml │ ├── builder.rb │ └── document.rb │ ├── ssml.rb │ ├── ssml │ ├── audio.rb │ ├── break.rb │ ├── desc.rb │ ├── element.rb │ ├── emphasis.rb │ ├── mark.rb │ ├── p.rb │ ├── phoneme.rb │ ├── prosody.rb │ ├── s.rb │ ├── say_as.rb │ ├── speak.rb │ ├── sub.rb │ └── voice.rb │ ├── version.rb │ └── xml │ └── language.rb ├── ruby_speech.gemspec └── spec ├── ruby_speech ├── grxml │ ├── builtins_spec.rb │ ├── grammar_spec.rb │ ├── item_spec.rb │ ├── match_spec.rb │ ├── matcher_spec.rb │ ├── max_match_spec.rb │ ├── no_match_spec.rb │ ├── one_of_spec.rb │ ├── potential_match_spec.rb │ ├── rule_spec.rb │ ├── ruleref_spec.rb │ ├── tag_spec.rb │ └── token_spec.rb ├── grxml_spec.rb ├── nlsml_spec.rb ├── ssml │ ├── audio_spec.rb │ ├── break_spec.rb │ ├── desc_spec.rb │ ├── emphasis_spec.rb │ ├── mark_spec.rb │ ├── p_spec.rb │ ├── phoneme_spec.rb │ ├── prosody_spec.rb │ ├── s_spec.rb │ ├── say_as_spec.rb │ ├── speak_spec.rb │ ├── sub_spec.rb │ └── voice_spec.rb └── ssml_spec.rb ├── ruby_speech_spec.rb ├── spec_helper.rb └── support ├── dtmf_helper.rb ├── grammar_matchers.rb ├── match_examples.rb └── matchers.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.gem 3 | *.bundle 4 | *.jar 5 | *.so 6 | Gemfile.lock 7 | pkg/* 8 | spec/reports 9 | .yardoc 10 | doc 11 | .*.swp 12 | vendor 13 | tmp/ 14 | coverage 15 | -------------------------------------------------------------------------------- /.hound.yml: -------------------------------------------------------------------------------- 1 | LineLength: 2 | Enabled: false 3 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --colour 3 | --tty 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: xenial 2 | language: ruby 3 | rvm: 4 | - 2.1.10 5 | - 2.2.10 6 | - 2.3.8 7 | - 2.4.5 8 | - 2.5.3 9 | - 2.6.3 10 | - jruby-9.1.17.0 11 | - jruby-head 12 | - ruby-head 13 | jdk: 14 | - openjdk8 # for jruby 15 | matrix: 16 | include: 17 | - rvm: rbx-4 18 | dist: trusty 19 | name: Rubinius 20 | allow_failures: 21 | - name: Rubinius 22 | - rvm: ruby-head 23 | addons: 24 | apt: 25 | packages: 26 | - libpcre3 27 | - libpcre3-dev 28 | env: 29 | global: 30 | - JRUBY_OPTS='--debug' 31 | before_install: rvm list 32 | notifications: 33 | irc: "irc.freenode.org#adhearsion" 34 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # [3.0.1](https://github.com/benlangfeld/ruby_speech/compare/v3.0.0...v3.0.1) - [2022-02-15](https://rubygems.org/gems/ruby_speech/versions/3.0.1) 2 | * Misc: Relax dependency limits to allow newer ActiveSupport versions and thus Ruby 3.0 3 | * Bugfix: Misc performance improvements 4 | 5 | # [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) 6 | * Feature: Loosen and bump Nokogiri version to ~>1.8, >=1.8.3 7 | * Feature: Bump RSpec to 3.x and convert specs with Transpec 8 | 9 | # [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) 10 | * Feature: Permit percentage rate values for prosody tags 11 | * Bugfix: Rulerefs referenced n-levels deep under Rulerefs should be expanded. 12 | * Bugfix: Optimize performance of built-in number DTMF grammar 13 | * Bugfix: Fix handling of millisecond values 14 | 15 | # [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) 16 | * Bugfix: String nodes should take non-strings and cast to a string (`#to_s`) 17 | * Bugfix: Cleanly handle NLSML with no input tag 18 | * Bugfix: Drawing an NLSML doc should return something structured/parsed 19 | * Bugfix: Cloning SSML documents no longer turns them into GRXML docs 20 | 21 | # [2.3.1](https://github.com/benlangfeld/ruby_speech/compare/v2.3.0...v2.3.1) - [2014-02-24](https://rubygems.org/gems/ruby_speech/versions/2.3.1) 22 | * Bugfix: Phone number grammar should only allow a single instance of '*'/'x' 23 | * Bugfix: Concatenating documents containing strings across the border inserts appropriate spacing (#21). 24 | 25 | # [2.3.0](https://github.com/benlangfeld/ruby_speech/compare/v2.2.2...v2.3.0) - [2013-09-30](https://rubygems.org/gems/ruby_speech/versions/2.3.0) 26 | * Feature: Allow generation of a boolean, date, digits, currency, number, phone or time grammar including from URIs 27 | * Bugfix: Ensure that rule refs can be reused when inlining grammars 28 | 29 | # [2.2.2](https://github.com/benlangfeld/ruby_speech/compare/v2.2.1...v2.2.2) - [2013-09-03](https://rubygems.org/gems/ruby_speech/versions/2.2.2) 30 | * Bugfix: Fix an exception message to include object type 31 | 32 | # [2.2.1](https://github.com/benlangfeld/ruby_speech/compare/v2.2.0...v2.2.1) - [2013-07-02](https://rubygems.org/gems/ruby_speech/versions/2.2.1) 33 | * Bugfix: Ensure that concatenating documents doesn't mutate the originals on JRuby 34 | 35 | # [2.2.0](https://github.com/benlangfeld/ruby_speech/compare/v2.1.2...v2.2.0) - [2013-06-26](https://rubygems.org/gems/ruby_speech/versions/2.2.0) 36 | * Bugfix: Constant autoload in rbx C extensions doesn't work properly 37 | * Bugfix: No longer subclass or copy nodes, use delegation instead 38 | * Bugfix: Java 1.6 compatability 39 | * CS: Remove niceogiri dependency 40 | * CS: Remove autoloading 41 | * CS: Depend on activesupport less 42 | 43 | # [2.1.2](https://github.com/benlangfeld/ruby_speech/compare/v2.1.1...v2.1.2) - [2013-06-05](https://rubygems.org/gems/ruby_speech/versions/2.1.2) 44 | * Bugfix: Allow wrapping a pre-parsed XML node nested arbitrary deeply as an NLSML document 45 | 46 | # [2.1.1](https://github.com/benlangfeld/ruby_speech/compare/v2.1.0...v2.1.1) - [2013-05-09](https://rubygems.org/gems/ruby_speech/versions/2.1.1) 47 | * Bugfix: Support numeric SISR literal tags 48 | 49 | # [2.1.0](https://github.com/benlangfeld/ruby_speech/compare/v2.0.2...v2.1.0) - [2013-05-07](https://rubygems.org/gems/ruby_speech/versions/2.1.0) 50 | * Feature: Support for SISR literal syntax 51 | 52 | # [2.0.2](https://github.com/benlangfeld/ruby_speech/compare/v2.0.1...v2.0.2) - [2013-05-01](https://rubygems.org/gems/ruby_speech/versions/2.0.2) 53 | * Bugfix: Differentiate between GRXML match cases with are and are not maximal 54 | * A Match can accept further input while still matching, while a a MaxMatch cannot. 55 | * Matching implementation moved down to C/Java to avoid repeated regex compilation and confusing jumping about. 56 | * Bugfix: Back to functioning on JRuby with latest Nokogiri release 57 | 58 | # [2.0.1](https://github.com/benlangfeld/ruby_speech/compare/v2.0.0...v2.0.1) - [2013-04-27](https://rubygems.org/gems/ruby_speech/versions/2.0.1) 59 | * Bugfix: Build native C extension in the correct location 60 | 61 | # [2.0.0](https://github.com/benlangfeld/ruby_speech/compare/v1.1.0...v2.0.0) - [2013-04-27](https://rubygems.org/gems/ruby_speech/versions/2.0.0) 62 | * Change: Comply with MRCPv2 flavour of NLSML 63 | * Confidence is now a float in the XML representation 64 | * Models are no longer used 65 | * XForms no longer used 66 | * Now have a true namespace 67 | * Instance is in the NLSML namespace 68 | * Must support string instances 69 | * Change: Grammar matching now uses a Matcher rather than directly on the Grammar element 70 | * Feature: Grammar matching now uses native C/Java regexes with PCRE/java.util.regex for clean partial matching and SPEEEEEED 71 | * Bugfix: Item repeats now work correctly 72 | 73 | # [1.1.0](https://github.com/benlangfeld/ruby_speech/compare/v1.0.2...v1.1.0) - [2013-03-02](https://rubygems.org/gems/ruby_speech/versions/1.1.0) 74 | * Feature: NLSML building & parsing 75 | 76 | # [1.0.2](https://github.com/benlangfeld/ruby_speech/compare/v1.0.1...v1.0.2) - [2012-12-26](https://rubygems.org/gems/ruby_speech/versions/1.0.2) 77 | * Bugfix: Get test suite passing on JRuby 78 | 79 | # [1.0.1](https://github.com/benlangfeld/ruby_speech/compare/v1.0.0...v1.0.1) - [2012-10-24](https://rubygems.org/gems/ruby_speech/versions/1.0.1) 80 | * Bugfix: Don't load rubygems because it is evil 81 | * Bugfix: Allow setting language (and other) attributes on root of SSML doc when using #draw DSL 82 | 83 | # 1.0.0 - 2012-03-13 84 | * Bump major version because we have a stable API 85 | 86 | # 0.5.1 - 2012-01-09 87 | * Feature: Chaining child injection using #<< now works 88 | * Feature: Reading the repeat value for a GRXML Item now returns an Integer or a Range, rather than the plain string 89 | * Feature: Most simple GRXML grammars now return PotentialMatch when the provided input is valid but incomplete. This does not work for complex grammars including repeats and deep nesting. Fixes for these coming soon. 90 | 91 | # 0.5.0 - 2012-01-03 92 | * Feature: Add a whole bunch more SSML elements: 93 | * p & s 94 | * mark 95 | * desc 96 | * sub 97 | * phoneme 98 | * Feature: Added the ability to inline grammar rule references in both destructive and non-destructive modes 99 | * Feature: Added the ability to tokenize a grammar, turning all tokens into unambiguous `` elements 100 | * Feature: Added the ability to whitespace normalize a grammar 101 | * Feature: Added the ability to match an input string against a Grammar 102 | * Feature: Constructing a GRXML grammar with a root rule specified but not provided will raise an exception 103 | * Feature: Embedding a GRXML grammar of a mode different from the host will raise an exception 104 | * Bugfix: Fix upward traversal through a document via #parent 105 | 106 | # 0.4.0 - 2011-12-30 107 | * Feature: Add the ability to look up child elements by name/attributes easily 108 | * Feature: Allow easy access to a GRXML grammar's root rule element 109 | * Feature: Allow inlining a Grammar's rulerefs 110 | * Bugfix: Ruby 1.8 and JRuby don't do a tree-search for const_defined? 111 | * Bugfix: Don't try to pass a method call up to the DSL block binding if it doesn't respond to the method either 112 | 113 | # 0.3.4 114 | * Eager-autoload all elements so that importing will work with elements that havn't been used yet directly 115 | * Allow using the DSL with method calls out of the block 116 | * Fix inspection/comparison of some elements that don't have a language attribute 117 | 118 | # 0.3.3 119 | * Allow `SSML::Element.import` and `GRXML::Element.import` to take a string as well as a Nokogiri::XML::Node 120 | * Allow importing GRXML/SSML documents via their respective modules (eg `RubySpeech::GRXML.import ''`) 121 | 122 | # 0.3.2 123 | * Fix inheriting an `SSML::Speak`'s language. Previously an imported `` would end up with a `lang` attribute in addition to `xml:lang`, and `xml:lang` would have the default value (`en-US`). This required a Niceogiri dependency update. 124 | 125 | # 0.3.1 126 | * Get the whole test suite passing on Ruby 1.8.7 and JRuby (thanks to Taylor Carpenter!) 127 | 128 | # 0.3.0 129 | * Feature (Taylor Carpenter): Added support for GRXML documents with most elements implemented. 130 | 131 | # 0.2.2 132 | * Feature: The SSML DSL now supports embedding SSML documents, elements or strings via the `embed` method. This behaves as you might expect: 133 | 134 | ```ruby 135 | doc1 = RubySpeech::SSML.draw do 136 | string "Hi, I'm Fred. The time is currently " 137 | say_as :interpret_as => 'date', :format => 'dmy' do 138 | "01/02/1960" 139 | end 140 | end 141 | 142 | doc2 = RubySpeech::SSML.draw do 143 | voice :gender => :male, :name => 'fred' do 144 | embed doc1 145 | end 146 | end 147 | 148 | doc2.to_s 149 | ``` 150 | 151 | ```xml 152 | 153 | 154 | Hi, I'm Fred. The time is currently 155 | 156 | 01/02/1960 157 | 158 | 159 | 160 | ``` 161 | 162 | # 0.2.1 163 | * Bugfix: SSML element's children now include any text content, and text content is copied when importing/concatenating documents 164 | 165 | # 0.2.0 166 | * API Change: SSML::SayAs.new (and the DSL method `say_as`) now take `:interpret_as` in the options hash, rather than a separate first argument. This is for consistency with the other element types. 167 | * Feature: SSML elements can now be imported from a Nokogiri Node or a string 168 | * Feature: SSML elements now respond to #children with an array of SSML elements, rather than a Nokogiri NodeSet 169 | * Bugfix/Feature: Comparing SSML elements now compares children 170 | 171 | # 0.1.5 172 | * Feature: Now added support for SSML `