ssml_builder 1.0.0
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 +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +570 -0
- data/Rakefile +1 -0
- data/lib/ssml_builder.rb +12 -0
- data/lib/ssml_builder/builder.rb +216 -0
- data/lib/ssml_builder/core_extensions/string.rb +171 -0
- data/lib/ssml_builder/version.rb +3 -0
- metadata +120 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: b6275634506fb3476e569a6b0cd789d8fc7a9462
         | 
| 4 | 
            +
              data.tar.gz: c20cea303828a8d84c8764d40d482d2ad6be889f
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 30af32c16859e824e531f197eee273de962af05093dcea91f94ae45e5040fa2a6e94dda0b9d5f0a361119380d008560862b5cec004097a67c51924272369a479
         | 
| 7 | 
            +
              data.tar.gz: 5a1b4610510873be755789c0afb1b32e50f8e9787106f51106bcc56ffc0dc7d3e1fa89fde50f9d2ecd70224e8dd0869ba907c6af5e5460c6c7bb5a994e03c3fc
         | 
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            Copyright (c) 2017 Paul McMahon
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            MIT License
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 7 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            +
            the following conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,570 @@ | |
| 1 | 
            +
            # SSML Builder (for Amazon Alexa)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            This gem implements a full suite of tools for working with SSML particularly with Amazon's Alexa. For full SSML documentation, please see:
         | 
| 4 | 
            +
            [Amazon SSML Reference](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            ## Installation
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            ### For Ruby Projects:
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            Add this line to your application's Gemfile:
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            ```ruby
         | 
| 13 | 
            +
            gem 'ssml_builder'
         | 
| 14 | 
            +
            ```
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            And then execute:
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                $ bundle
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            Or install it yourself as:
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                $ gem install ssml_builder
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            ## Usage
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            This Gem provides methods to generate ssml strings using the core Builder module as well as providing an extension of the string class if that usage is preferred.
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            ### SsmlBuilder::Builder
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            #### Basic Usage
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            ```ruby
         | 
| 33 | 
            +
            require 'ssml_builder'
         | 
| 34 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 35 | 
            +
            ssml_builder.say("Hello, how are you today?")
         | 
| 36 | 
            +
            ssml_builder.pause("1s")
         | 
| 37 | 
            +
            ssml_builder.p("This is a new paragraph.")
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            ssml_buider.ssml
         | 
| 40 | 
            +
            # Output: "<speak>Hello, how are you today? <break time=\"1s\"/><p>This is a new paragraph.</p></speak>"
         | 
| 41 | 
            +
            ```
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            #### Available Commands
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            * [say](#say)
         | 
| 46 | 
            +
            * [paragraph](#paragraph)
         | 
| 47 | 
            +
            * [p](#p)
         | 
| 48 | 
            +
            * [sentence](#sentence)
         | 
| 49 | 
            +
            * [rate](#rate)
         | 
| 50 | 
            +
            * [pitch](#pitch)
         | 
| 51 | 
            +
            * [volume](#volume)
         | 
| 52 | 
            +
            * [pause](#pause)
         | 
| 53 | 
            +
            * [break](#break)
         | 
| 54 | 
            +
            * [emphasis](#emphasis)
         | 
| 55 | 
            +
            * [audio](#audio)
         | 
| 56 | 
            +
            * [spell_out](#spell_out)
         | 
| 57 | 
            +
            * [characters](#characters)
         | 
| 58 | 
            +
            * [cardinal](#cardinal)
         | 
| 59 | 
            +
            * [number](#number)
         | 
| 60 | 
            +
            * [ordinal](#ordinal)
         | 
| 61 | 
            +
            * [digits](#digits)
         | 
| 62 | 
            +
            * [fraction](#fraction)
         | 
| 63 | 
            +
            * [unit](#unit)
         | 
| 64 | 
            +
            * [date](#date)
         | 
| 65 | 
            +
            * [time](#time)
         | 
| 66 | 
            +
            * [telephone](#telephone)
         | 
| 67 | 
            +
            * [phone](#phone)
         | 
| 68 | 
            +
            * [address](#address)
         | 
| 69 | 
            +
            * [interjection](#interjection)
         | 
| 70 | 
            +
            * [expletive](#expletive)
         | 
| 71 | 
            +
            * [sub](#sub)
         | 
| 72 | 
            +
            * [whisper](#whisper)
         | 
| 73 | 
            +
            * [amazon_verb](#amazon_verb)
         | 
| 74 | 
            +
            * [amazon_participle](#amazon_participle)
         | 
| 75 | 
            +
            * [amazon_noun](#amazon_noun)
         | 
| 76 | 
            +
            * [amazon_sense](#amazon_sense)
         | 
| 77 | 
            +
            * [phoneme](#phoneme)
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            ##### say
         | 
| 80 | 
            +
             | 
| 81 | 
            +
            parameters
         | 
| 82 | 
            +
              - string
         | 
| 83 | 
            +
             | 
| 84 | 
            +
            ```ruby
         | 
| 85 | 
            +
            require 'ssml_builder'
         | 
| 86 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 87 | 
            +
            ssml_builder.say("Hello, how are you today?")
         | 
| 88 | 
            +
             | 
| 89 | 
            +
            ssml_buider.ssml
         | 
| 90 | 
            +
            # Output: "<speak>Hello, how are you today?</speak>"
         | 
| 91 | 
            +
            ```
         | 
| 92 | 
            +
             | 
| 93 | 
            +
            ##### paragraph
         | 
| 94 | 
            +
             | 
| 95 | 
            +
            parameters
         | 
| 96 | 
            +
              - string
         | 
| 97 | 
            +
             | 
| 98 | 
            +
            ```ruby
         | 
| 99 | 
            +
            require 'ssml_builder'
         | 
| 100 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 101 | 
            +
            ssml_builder.paragraph("Hello, how are you today?")
         | 
| 102 | 
            +
             | 
| 103 | 
            +
            ssml_buider.ssml
         | 
| 104 | 
            +
            # Output: "<speak><p>Hello, how are you today?</p></speak>"
         | 
| 105 | 
            +
            ```
         | 
| 106 | 
            +
             | 
| 107 | 
            +
            ##### p
         | 
| 108 | 
            +
             | 
| 109 | 
            +
            Alias for [paragraph](#paragraph)
         | 
| 110 | 
            +
             | 
| 111 | 
            +
            ##### sentence
         | 
| 112 | 
            +
             | 
| 113 | 
            +
            parameters
         | 
| 114 | 
            +
              - string
         | 
| 115 | 
            +
             | 
| 116 | 
            +
            ```ruby
         | 
| 117 | 
            +
            require 'ssml_builder'
         | 
| 118 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 119 | 
            +
            ssml_builder.sentence("Hello, how are you today?")
         | 
| 120 | 
            +
             | 
| 121 | 
            +
            ssml_buider.ssml
         | 
| 122 | 
            +
            # Output: "<speak><s>Hello, how are you today?</s></speak>"
         | 
| 123 | 
            +
            ```
         | 
| 124 | 
            +
             | 
| 125 | 
            +
            ##### rate
         | 
| 126 | 
            +
             | 
| 127 | 
            +
            parameters
         | 
| 128 | 
            +
              - string
         | 
| 129 | 
            +
              - rate
         | 
| 130 | 
            +
                - optional, default: "medium"
         | 
| 131 | 
            +
                - can be integer or string
         | 
| 132 | 
            +
                - valid text inputs: "x-slow", "slow", "medium", "fast", "x-fast"
         | 
| 133 | 
            +
             | 
| 134 | 
            +
            ```ruby
         | 
| 135 | 
            +
            require 'ssml_builder'
         | 
| 136 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 137 | 
            +
            ssml_builder.rate("Text",90)
         | 
| 138 | 
            +
             | 
| 139 | 
            +
            ssml_buider.ssml
         | 
| 140 | 
            +
            # Output: "<speak><prosody rate=\"90%\">Text</prosody></speak>"
         | 
| 141 | 
            +
            ```
         | 
| 142 | 
            +
             | 
| 143 | 
            +
            ##### pitch
         | 
| 144 | 
            +
             | 
| 145 | 
            +
            parameters
         | 
| 146 | 
            +
              - string
         | 
| 147 | 
            +
              - pitch
         | 
| 148 | 
            +
                - optional, default: "medium"
         | 
| 149 | 
            +
                - can be integer, float, or string
         | 
| 150 | 
            +
                - minimum -33.3
         | 
| 151 | 
            +
                - maximum 50
         | 
| 152 | 
            +
                - valid text inputs: "x-low", "low", "medium", "high", "x-high"
         | 
| 153 | 
            +
             | 
| 154 | 
            +
            ```ruby
         | 
| 155 | 
            +
            require 'ssml_builder'
         | 
| 156 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 157 | 
            +
            ssml_builder.pitch("Text",50)
         | 
| 158 | 
            +
             | 
| 159 | 
            +
            ssml_buider.ssml
         | 
| 160 | 
            +
            # Output: "<speak><prosody pitch=\"+50%\">Text</prosody></speak>"
         | 
| 161 | 
            +
            ```
         | 
| 162 | 
            +
             | 
| 163 | 
            +
            ##### volume
         | 
| 164 | 
            +
             | 
| 165 | 
            +
            parameters
         | 
| 166 | 
            +
              - string
         | 
| 167 | 
            +
              - volume
         | 
| 168 | 
            +
                - optional, default: "medium"
         | 
| 169 | 
            +
                - can be integer, float, or string
         | 
| 170 | 
            +
                - maximum 4.08
         | 
| 171 | 
            +
                - valid text inputs: "silent", "x-soft", "soft", "medium", "loud", "x-loud"
         | 
| 172 | 
            +
             | 
| 173 | 
            +
            ```ruby
         | 
| 174 | 
            +
            require 'ssml_builder'
         | 
| 175 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 176 | 
            +
            ssml_builder.volume("Text",2.3)
         | 
| 177 | 
            +
             | 
| 178 | 
            +
            ssml_buider.ssml
         | 
| 179 | 
            +
            # Output: "<speak><prosody volume=\"+2.3dB\">Text</prosody></speak>"
         | 
| 180 | 
            +
            ```
         | 
| 181 | 
            +
             | 
| 182 | 
            +
            ##### pause
         | 
| 183 | 
            +
             | 
| 184 | 
            +
            parameters
         | 
| 185 | 
            +
              - string
         | 
| 186 | 
            +
                - optional, default: "medium"
         | 
| 187 | 
            +
                - can be text time such as: "1s", "100ms", etc.
         | 
| 188 | 
            +
                - valid text inputs: "none", "x-weak", "weak", "medium", "strong", "x-strong"
         | 
| 189 | 
            +
             | 
| 190 | 
            +
            ```ruby
         | 
| 191 | 
            +
            require 'ssml_builder'
         | 
| 192 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 193 | 
            +
            ssml_builder.pause("1s")
         | 
| 194 | 
            +
             | 
| 195 | 
            +
            ssml_buider.ssml
         | 
| 196 | 
            +
            # Output: "<speak><break time=\"1s\"/></speak>"
         | 
| 197 | 
            +
            ```
         | 
| 198 | 
            +
             | 
| 199 | 
            +
            ##### break
         | 
| 200 | 
            +
             | 
| 201 | 
            +
            Alias for [pause](#pause)
         | 
| 202 | 
            +
             | 
| 203 | 
            +
            ##### emphasis
         | 
| 204 | 
            +
             | 
| 205 | 
            +
            parameters
         | 
| 206 | 
            +
              - string
         | 
| 207 | 
            +
              - emphasis
         | 
| 208 | 
            +
                - optional, default: "moderate"
         | 
| 209 | 
            +
                - valid text inputs: "reduced", "moderate", "strong"
         | 
| 210 | 
            +
             | 
| 211 | 
            +
            ```ruby
         | 
| 212 | 
            +
            require 'ssml_builder'
         | 
| 213 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 214 | 
            +
            ssml_builder.emphasis("Text","strong")
         | 
| 215 | 
            +
             | 
| 216 | 
            +
            ssml_buider.ssml
         | 
| 217 | 
            +
            # Output: "<speak><emphasis level=\"strong\">Text</emphasis></speak>"
         | 
| 218 | 
            +
            ```
         | 
| 219 | 
            +
             | 
| 220 | 
            +
            ##### audio
         | 
| 221 | 
            +
             | 
| 222 | 
            +
            parameters
         | 
| 223 | 
            +
              - url
         | 
| 224 | 
            +
                - [SSML Audio Guidelines](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#audio)
         | 
| 225 | 
            +
             | 
| 226 | 
            +
            ```ruby
         | 
| 227 | 
            +
            require 'ssml_builder'
         | 
| 228 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 229 | 
            +
            ssml_builder.audio("http://s3.audio.file.com/audio.mp3")
         | 
| 230 | 
            +
             | 
| 231 | 
            +
            ssml_buider.ssml
         | 
| 232 | 
            +
            # Output: "<speak><audio src=\"http://s3.audio.file.com/audio.mp3\"/></speak>"
         | 
| 233 | 
            +
            ```
         | 
| 234 | 
            +
             | 
| 235 | 
            +
            ##### spell_out
         | 
| 236 | 
            +
             | 
| 237 | 
            +
            parameters
         | 
| 238 | 
            +
              - string
         | 
| 239 | 
            +
             | 
| 240 | 
            +
            ```ruby
         | 
| 241 | 
            +
            require 'ssml_builder'
         | 
| 242 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 243 | 
            +
            ssml_builder.spell_out("Spelling")
         | 
| 244 | 
            +
             | 
| 245 | 
            +
            ssml_buider.ssml
         | 
| 246 | 
            +
            # Output: "<speak><say-as interpret-as=\"spell-out\">Spelling</say-as></speak>"
         | 
| 247 | 
            +
            ```
         | 
| 248 | 
            +
             | 
| 249 | 
            +
            ##### characters
         | 
| 250 | 
            +
             | 
| 251 | 
            +
            parameters
         | 
| 252 | 
            +
              - string
         | 
| 253 | 
            +
             | 
| 254 | 
            +
            ```ruby
         | 
| 255 | 
            +
            require 'ssml_builder'
         | 
| 256 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 257 | 
            +
            ssml_builder.characters("Spelling")
         | 
| 258 | 
            +
             | 
| 259 | 
            +
            ssml_buider.ssml
         | 
| 260 | 
            +
            # Output: "<speak><say-as interpret-as=\"characters\">Spelling</say-as></speak>"
         | 
| 261 | 
            +
            ```
         | 
| 262 | 
            +
             | 
| 263 | 
            +
            ##### cardinal
         | 
| 264 | 
            +
             | 
| 265 | 
            +
            parameters
         | 
| 266 | 
            +
              - string
         | 
| 267 | 
            +
             | 
| 268 | 
            +
            ```ruby
         | 
| 269 | 
            +
            require 'ssml_builder'
         | 
| 270 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 271 | 
            +
            ssml_builder.cardinal("10")
         | 
| 272 | 
            +
             | 
| 273 | 
            +
            ssml_buider.ssml
         | 
| 274 | 
            +
            # Output: "<speak><say-as interpret-as=\"cardinal\">10</say-as></speak>"
         | 
| 275 | 
            +
            ```
         | 
| 276 | 
            +
             | 
| 277 | 
            +
            ##### number
         | 
| 278 | 
            +
             | 
| 279 | 
            +
            parameters
         | 
| 280 | 
            +
              - string
         | 
| 281 | 
            +
             | 
| 282 | 
            +
            ```ruby
         | 
| 283 | 
            +
            require 'ssml_builder'
         | 
| 284 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 285 | 
            +
            ssml_builder.number("10")
         | 
| 286 | 
            +
             | 
| 287 | 
            +
            ssml_buider.ssml
         | 
| 288 | 
            +
            # Output: "<speak><say-as interpret-as=\"number\">10</say-as></speak>"
         | 
| 289 | 
            +
            ```
         | 
| 290 | 
            +
             | 
| 291 | 
            +
            ##### ordinal
         | 
| 292 | 
            +
             | 
| 293 | 
            +
            parameters
         | 
| 294 | 
            +
              - string
         | 
| 295 | 
            +
             | 
| 296 | 
            +
            ```ruby
         | 
| 297 | 
            +
            require 'ssml_builder'
         | 
| 298 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 299 | 
            +
            ssml_builder.ordinal("10")
         | 
| 300 | 
            +
             | 
| 301 | 
            +
            ssml_buider.ssml
         | 
| 302 | 
            +
            # Output: "<speak><say-as interpret-as=\"ordinal\">10</say-as></speak>"
         | 
| 303 | 
            +
            ```
         | 
| 304 | 
            +
             | 
| 305 | 
            +
            ##### digits
         | 
| 306 | 
            +
             | 
| 307 | 
            +
            parameters
         | 
| 308 | 
            +
              - string
         | 
| 309 | 
            +
             | 
| 310 | 
            +
            ```ruby
         | 
| 311 | 
            +
            require 'ssml_builder'
         | 
| 312 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 313 | 
            +
            ssml_builder.digits("10")
         | 
| 314 | 
            +
             | 
| 315 | 
            +
            ssml_buider.ssml
         | 
| 316 | 
            +
            # Output: "<speak><say-as interpret-as=\"digits\">10</say-as></speak>"
         | 
| 317 | 
            +
            ```
         | 
| 318 | 
            +
             | 
| 319 | 
            +
            ##### fraction
         | 
| 320 | 
            +
             | 
| 321 | 
            +
            parameters
         | 
| 322 | 
            +
              - string
         | 
| 323 | 
            +
             | 
| 324 | 
            +
            ```ruby
         | 
| 325 | 
            +
            require 'ssml_builder'
         | 
| 326 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 327 | 
            +
            ssml_builder.fraction("3/20")
         | 
| 328 | 
            +
             | 
| 329 | 
            +
            ssml_buider.ssml
         | 
| 330 | 
            +
            # Output: "<speak><say-as interpret-as=\"fraction\">3/20</say-as></speak>"
         | 
| 331 | 
            +
            ```
         | 
| 332 | 
            +
             | 
| 333 | 
            +
            ##### unit
         | 
| 334 | 
            +
             | 
| 335 | 
            +
            parameters
         | 
| 336 | 
            +
              - string
         | 
| 337 | 
            +
             | 
| 338 | 
            +
            ```ruby
         | 
| 339 | 
            +
            require 'ssml_builder'
         | 
| 340 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 341 | 
            +
            ssml_builder.unit("10 meters")
         | 
| 342 | 
            +
             | 
| 343 | 
            +
            ssml_buider.ssml
         | 
| 344 | 
            +
            # Output: "<speak><say-as interpret-as=\"unit\">10meters</say-as></speak>"
         | 
| 345 | 
            +
            ```
         | 
| 346 | 
            +
             | 
| 347 | 
            +
            ##### date
         | 
| 348 | 
            +
             | 
| 349 | 
            +
            parameters
         | 
| 350 | 
            +
              - year
         | 
| 351 | 
            +
                - string or integer
         | 
| 352 | 
            +
                - nil to leave out
         | 
| 353 | 
            +
              - month
         | 
| 354 | 
            +
                - string or integer
         | 
| 355 | 
            +
                - nil to leave out
         | 
| 356 | 
            +
              - day
         | 
| 357 | 
            +
                - string or integer
         | 
| 358 | 
            +
                - nil to leave out
         | 
| 359 | 
            +
             | 
| 360 | 
            +
            ```ruby
         | 
| 361 | 
            +
            require 'ssml_builder'
         | 
| 362 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 363 | 
            +
            ssml_builder.date("2017",nil,10)
         | 
| 364 | 
            +
             | 
| 365 | 
            +
            ssml_buider.ssml
         | 
| 366 | 
            +
            # Output: "<speak><say-as interpret-as=\"date\">2017??10</say-as></speak>"
         | 
| 367 | 
            +
            ```
         | 
| 368 | 
            +
             | 
| 369 | 
            +
            ##### time
         | 
| 370 | 
            +
             | 
| 371 | 
            +
            parameters
         | 
| 372 | 
            +
              - string
         | 
| 373 | 
            +
             | 
| 374 | 
            +
            ```ruby
         | 
| 375 | 
            +
            require 'ssml_builder'
         | 
| 376 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 377 | 
            +
            ssml_builder.time("2'")
         | 
| 378 | 
            +
             | 
| 379 | 
            +
            ssml_buider.ssml
         | 
| 380 | 
            +
            # Output: "<speak><say-as interpret-as=\"time\">2'</say-as></speak>"
         | 
| 381 | 
            +
            ```
         | 
| 382 | 
            +
             | 
| 383 | 
            +
            ##### telephone
         | 
| 384 | 
            +
             | 
| 385 | 
            +
            parameters
         | 
| 386 | 
            +
              - string
         | 
| 387 | 
            +
             | 
| 388 | 
            +
            ```ruby
         | 
| 389 | 
            +
            require 'ssml_builder'
         | 
| 390 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 391 | 
            +
            ssml_builder.telephone("1234567890")
         | 
| 392 | 
            +
             | 
| 393 | 
            +
            ssml_buider.ssml
         | 
| 394 | 
            +
            # Output: "<speak><say-as interpret-as=\"telephone\">1234567890</say-as></speak>"
         | 
| 395 | 
            +
            ```
         | 
| 396 | 
            +
             | 
| 397 | 
            +
            ##### phone
         | 
| 398 | 
            +
             | 
| 399 | 
            +
            Alias for [telephone](#telephone)
         | 
| 400 | 
            +
             | 
| 401 | 
            +
            ##### address
         | 
| 402 | 
            +
             | 
| 403 | 
            +
            parameters
         | 
| 404 | 
            +
              - string
         | 
| 405 | 
            +
             | 
| 406 | 
            +
            ```ruby
         | 
| 407 | 
            +
            require 'ssml_builder'
         | 
| 408 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 409 | 
            +
            ssml_builder.address("342 W 1st St")
         | 
| 410 | 
            +
             | 
| 411 | 
            +
            ssml_buider.ssml
         | 
| 412 | 
            +
            # Output: "<speak><say-as interpret-as=\"address\">342 W 1st St</say-as></speak>"
         | 
| 413 | 
            +
            ```
         | 
| 414 | 
            +
             | 
| 415 | 
            +
            ##### interjection
         | 
| 416 | 
            +
             | 
| 417 | 
            +
            parameters
         | 
| 418 | 
            +
              - string
         | 
| 419 | 
            +
             | 
| 420 | 
            +
            ```ruby
         | 
| 421 | 
            +
            require 'ssml_builder'
         | 
| 422 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 423 | 
            +
            ssml_builder.interjection("Wow!")
         | 
| 424 | 
            +
             | 
| 425 | 
            +
            ssml_buider.ssml
         | 
| 426 | 
            +
            # Output: "<speak><say-as interpret-as=\"interjection\">Wow!</say-as></speak>"
         | 
| 427 | 
            +
            ```
         | 
| 428 | 
            +
             | 
| 429 | 
            +
            ##### expletive
         | 
| 430 | 
            +
             | 
| 431 | 
            +
            parameters
         | 
| 432 | 
            +
              - string
         | 
| 433 | 
            +
             | 
| 434 | 
            +
            ```ruby
         | 
| 435 | 
            +
            require 'ssml_builder'
         | 
| 436 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 437 | 
            +
            ssml_builder.expletive("Curse Word")
         | 
| 438 | 
            +
             | 
| 439 | 
            +
            ssml_buider.ssml
         | 
| 440 | 
            +
            # Output: "<speak><say-as interpret-as=\"expletive\">Curse Word</say-as></speak>"
         | 
| 441 | 
            +
            ```
         | 
| 442 | 
            +
             | 
| 443 | 
            +
            ##### sub
         | 
| 444 | 
            +
             | 
| 445 | 
            +
            parameters
         | 
| 446 | 
            +
              - string
         | 
| 447 | 
            +
              - alias
         | 
| 448 | 
            +
             | 
| 449 | 
            +
            ```ruby
         | 
| 450 | 
            +
            require 'ssml_builder'
         | 
| 451 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 452 | 
            +
            ssml_builder.sub("Al","aluminum")
         | 
| 453 | 
            +
             | 
| 454 | 
            +
            ssml_buider.ssml
         | 
| 455 | 
            +
            # Output: "<speak><sub alias=\"aluminum\">Al</sub></speak>"
         | 
| 456 | 
            +
            ```
         | 
| 457 | 
            +
             | 
| 458 | 
            +
            ##### whisper
         | 
| 459 | 
            +
             | 
| 460 | 
            +
            parameters
         | 
| 461 | 
            +
              - string
         | 
| 462 | 
            +
             | 
| 463 | 
            +
            ```ruby
         | 
| 464 | 
            +
            require 'ssml_builder'
         | 
| 465 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 466 | 
            +
            ssml_builder.whisper("Be very quiet")
         | 
| 467 | 
            +
             | 
| 468 | 
            +
            ssml_buider.ssml
         | 
| 469 | 
            +
            # Output: "<speak><amazon:effect name=\"whispered\">Be very quiet</amazon:effect></speak>"
         | 
| 470 | 
            +
            ```
         | 
| 471 | 
            +
             | 
| 472 | 
            +
            ##### amazon_verb
         | 
| 473 | 
            +
             | 
| 474 | 
            +
            parameters
         | 
| 475 | 
            +
              - string
         | 
| 476 | 
            +
             | 
| 477 | 
            +
            ```ruby
         | 
| 478 | 
            +
            require 'ssml_builder'
         | 
| 479 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 480 | 
            +
            ssml_builder.amazon_verb("read")
         | 
| 481 | 
            +
             | 
| 482 | 
            +
            ssml_buider.ssml
         | 
| 483 | 
            +
            # Output: "<speak><w role=\"amazon:VB\">read</w></speak>"
         | 
| 484 | 
            +
            ```
         | 
| 485 | 
            +
             | 
| 486 | 
            +
            ##### amazon_participle
         | 
| 487 | 
            +
             | 
| 488 | 
            +
            parameters
         | 
| 489 | 
            +
              - string
         | 
| 490 | 
            +
             | 
| 491 | 
            +
            ```ruby
         | 
| 492 | 
            +
            require 'ssml_builder'
         | 
| 493 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 494 | 
            +
            ssml_builder.amazon_participle("read")
         | 
| 495 | 
            +
             | 
| 496 | 
            +
            ssml_buider.ssml
         | 
| 497 | 
            +
            # Output: "<speak><w role=\"amazon:VBD\">read</w></speak>"
         | 
| 498 | 
            +
            ```
         | 
| 499 | 
            +
             | 
| 500 | 
            +
            ##### amazon_noun
         | 
| 501 | 
            +
             | 
| 502 | 
            +
            parameters
         | 
| 503 | 
            +
              - string
         | 
| 504 | 
            +
             | 
| 505 | 
            +
            ```ruby
         | 
| 506 | 
            +
            require 'ssml_builder'
         | 
| 507 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 508 | 
            +
            ssml_builder.amazon_noun("bath")
         | 
| 509 | 
            +
             | 
| 510 | 
            +
            ssml_buider.ssml
         | 
| 511 | 
            +
            # Output: "<speak><w role=\"amazon:NN\">bath</w></speak>"
         | 
| 512 | 
            +
            ```
         | 
| 513 | 
            +
             | 
| 514 | 
            +
            ##### amazon_sense
         | 
| 515 | 
            +
             | 
| 516 | 
            +
            parameters
         | 
| 517 | 
            +
              - string
         | 
| 518 | 
            +
              - sense
         | 
| 519 | 
            +
                - integer
         | 
| 520 | 
            +
                - [Sense Documentation](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#w)
         | 
| 521 | 
            +
             | 
| 522 | 
            +
            ```ruby
         | 
| 523 | 
            +
            require 'ssml_builder'
         | 
| 524 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 525 | 
            +
            ssml_builder.amazon_sense("bass",1)
         | 
| 526 | 
            +
             | 
| 527 | 
            +
            ssml_buider.ssml
         | 
| 528 | 
            +
            # Output: "<speak><w role=\"SENSE_1\">bass</w></speak>"
         | 
| 529 | 
            +
            ```
         | 
| 530 | 
            +
             | 
| 531 | 
            +
            ##### phoneme
         | 
| 532 | 
            +
             | 
| 533 | 
            +
            [Amazon Phoneme Documentation](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#phoneme)
         | 
| 534 | 
            +
             | 
| 535 | 
            +
            parameters
         | 
| 536 | 
            +
              - string
         | 
| 537 | 
            +
              - alphabet
         | 
| 538 | 
            +
                - string
         | 
| 539 | 
            +
              - ph
         | 
| 540 | 
            +
                - string
         | 
| 541 | 
            +
             | 
| 542 | 
            +
            ```ruby
         | 
| 543 | 
            +
            require 'ssml_builder'
         | 
| 544 | 
            +
            ssml_builder = SsmlBuilder::Builder.new
         | 
| 545 | 
            +
            ssml_builder.phoneme("pecan","ipa","pɪˈkɑːn")
         | 
| 546 | 
            +
             | 
| 547 | 
            +
            ssml_buider.ssml
         | 
| 548 | 
            +
            # Output: "<speak><phoneme alphabet=\"ipa\" ph=\"pɪˈkɑːn\">pecan</phoneme></speak>"
         | 
| 549 | 
            +
            ```
         | 
| 550 | 
            +
             | 
| 551 | 
            +
            ### String
         | 
| 552 | 
            +
             | 
| 553 | 
            +
             | 
| 554 | 
            +
            ## Troubleshooting
         | 
| 555 | 
            +
             | 
| 556 | 
            +
             | 
| 557 | 
            +
            ## Contributing
         | 
| 558 | 
            +
             | 
| 559 | 
            +
            1. Fork it
         | 
| 560 | 
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         | 
| 561 | 
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 562 | 
            +
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 563 | 
            +
            5. Create a new Pull Request
         | 
| 564 | 
            +
             | 
| 565 | 
            +
            Please make sure to write specs for any new features!
         | 
| 566 | 
            +
             | 
| 567 | 
            +
            # Team Members
         | 
| 568 | 
            +
            - "Paul McMahon"
         | 
| 569 | 
            +
              - Email: <colpan@sircolpaniusjackson.com> 
         | 
| 570 | 
            +
              - Twitter: [@colpanius](https://twitter.com/colpanius)
         | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            require "bundler/gem_tasks"
         | 
    
        data/lib/ssml_builder.rb
    ADDED
    
    
| @@ -0,0 +1,216 @@ | |
| 1 | 
            +
            module SsmlBuilder
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class Builder
         | 
| 4 | 
            +
                attr_reader :ssml_content
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                def initialize
         | 
| 7 | 
            +
                  @ssml_content = ""
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                def say(string)
         | 
| 11 | 
            +
                  space_precheck
         | 
| 12 | 
            +
                  @ssml_content += remove_characters(string)
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                def paragraph(string)
         | 
| 16 | 
            +
                  @ssml_content += "<p>" + remove_characters(string) + "</p>"
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def p(string)
         | 
| 20 | 
            +
                  # ALIAS for paragraph
         | 
| 21 | 
            +
                  paragraph(string)
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                def sentence(string)
         | 
| 25 | 
            +
                  @ssml_content += "<s>" + remove_characters(string) + "</s>"
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                def rate(string,rate = "medium")
         | 
| 29 | 
            +
                  space_precheck
         | 
| 30 | 
            +
                  if !["x-slow", "slow", "medium", "fast", "x-fast"].include?(rate)
         | 
| 31 | 
            +
                    rate = (rate.to_i > 20 ? rate.to_i : 20).to_s + "%"
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                  @ssml_content += "<prosody rate=\"" + rate + "\">" + remove_characters(string) + "</prosody>"
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                def pitch(string,pitch = "medium")
         | 
| 37 | 
            +
                  space_precheck
         | 
| 38 | 
            +
                  if !["x-low", "low", "medium", "high", "x-high"].include?(pitch)
         | 
| 39 | 
            +
                    pitch = pitch.to_f > -33.3 ? pitch.to_f : -33.3
         | 
| 40 | 
            +
                    pitch = (pitch.to_f < 50.0 ? pitch : 50.0)
         | 
| 41 | 
            +
                    pitch = pitch > 0 ? "+%g%" % ("%.2f" % pitch) : "%g%" % ("%.2f" % pitch)
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                  @ssml_content += "<prosody pitch=\"" + pitch + "\">" + remove_characters(string) + "</prosody>"
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                def volume(string,volume = "medium")
         | 
| 47 | 
            +
                  space_precheck
         | 
| 48 | 
            +
                  if !["silent", "x-soft", "soft", "medium", "loud", "x-loud"].include?(volume)
         | 
| 49 | 
            +
                    volume = volume.to_f < 4.08 ? volume.to_f : 4.08
         | 
| 50 | 
            +
                    volume = volume > 0 ? "+%gdB" % ("%.2f" % volume) : "%gdB" % ("%.2f" % volume)
         | 
| 51 | 
            +
                  end
         | 
| 52 | 
            +
                  @ssml_content += "<prosody volume=\"" + volume + "\">" + remove_characters(string) + "</prosody>"
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                def prosody
         | 
| 56 | 
            +
                  # UNKOWN HOW I WANT TO USE
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                def pause(length = "medium")
         | 
| 60 | 
            +
                  space_precheck
         | 
| 61 | 
            +
                  if ["none", "x-weak", "weak", "medium", "strong", "x-strong"].include?(length.downcase)
         | 
| 62 | 
            +
                    @ssml_content += "<break strength=\"" + length.downcase + "\"/>"
         | 
| 63 | 
            +
                  else
         | 
| 64 | 
            +
                    @ssml_content += "<break time=\"" + length + "\"/>"
         | 
| 65 | 
            +
                  end
         | 
| 66 | 
            +
                end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                def break(length = "medium")
         | 
| 69 | 
            +
                  # ALIAS for pause
         | 
| 70 | 
            +
                  pause(length)
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                def emphasis(string,level = "moderate")
         | 
| 74 | 
            +
                  space_precheck
         | 
| 75 | 
            +
                  @ssml_content += "<emphasis level=\"" + level + "\">" + string + "</emphasis>"
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                def audio(url)
         | 
| 79 | 
            +
                  space_precheck
         | 
| 80 | 
            +
                  @ssml_content += "<audio src=\"" + url + "\"/>"
         | 
| 81 | 
            +
                end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                def spell_out(string)
         | 
| 84 | 
            +
                  space_precheck
         | 
| 85 | 
            +
                  @ssml_content += "<say-as interpret-as=\"spell-out\">" + string + "</say-as>"
         | 
| 86 | 
            +
                end
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                def characters(string)
         | 
| 89 | 
            +
                  space_precheck
         | 
| 90 | 
            +
                  @ssml_content += "<say-as interpret-as=\"characters\">" + string + "</say-as>"
         | 
| 91 | 
            +
                end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                def cardinal(string)
         | 
| 94 | 
            +
                  space_precheck
         | 
| 95 | 
            +
                  @ssml_content += "<say-as interpret-as=\"cardinal\">" + string + "</say-as>"
         | 
| 96 | 
            +
                end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                def number(string)
         | 
| 99 | 
            +
                  space_precheck
         | 
| 100 | 
            +
                  @ssml_content += "<say-as interpret-as=\"number\">" + string + "</say-as>"
         | 
| 101 | 
            +
                end
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                def ordinal(string)
         | 
| 104 | 
            +
                  space_precheck
         | 
| 105 | 
            +
                  @ssml_content += "<say-as interpret-as=\"ordinal\">" + string + "</say-as>"
         | 
| 106 | 
            +
                end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                def digits(string)
         | 
| 109 | 
            +
                  space_precheck
         | 
| 110 | 
            +
                  @ssml_content += "<say-as interpret-as=\"digits\">" + string + "</say-as>"
         | 
| 111 | 
            +
                end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                def fraction(string)
         | 
| 114 | 
            +
                  space_precheck
         | 
| 115 | 
            +
                  @ssml_content += "<say-as interpret-as=\"fraction\">" + string + "</say-as>"
         | 
| 116 | 
            +
                end
         | 
| 117 | 
            +
             | 
| 118 | 
            +
                def unit(string)
         | 
| 119 | 
            +
                  space_precheck
         | 
| 120 | 
            +
                  @ssml_content += "<say-as interpret-as=\"unit\">" + string.gsub(/ /,'') + "</say-as>"
         | 
| 121 | 
            +
                end
         | 
| 122 | 
            +
             | 
| 123 | 
            +
                def date(year = nil, month = nil, day = nil)
         | 
| 124 | 
            +
                  space_precheck
         | 
| 125 | 
            +
                  year = year.nil? ? "????" : year.to_s
         | 
| 126 | 
            +
                  month = month.nil? ? "??" : month.to_s.rjust(2, '0')
         | 
| 127 | 
            +
                  day = day.nil? ? "??" : day.to_s.rjust(2, '0')
         | 
| 128 | 
            +
                  @ssml_content += "<say-as interpret-as=\"date\">" + year + month + day + "</say-as>"
         | 
| 129 | 
            +
                end
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                def time(string)
         | 
| 132 | 
            +
                  space_precheck
         | 
| 133 | 
            +
                  @ssml_content += "<say-as interpret-as=\"time\">" + string + "</say-as>"
         | 
| 134 | 
            +
                end
         | 
| 135 | 
            +
             | 
| 136 | 
            +
                def telephone(string)
         | 
| 137 | 
            +
                  space_precheck
         | 
| 138 | 
            +
                  @ssml_content += "<say-as interpret-as=\"telephone\">" + string + "</say-as>"
         | 
| 139 | 
            +
                end
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                def phone(string)
         | 
| 142 | 
            +
                  # ALIAS of telephone
         | 
| 143 | 
            +
                  telephone(string)
         | 
| 144 | 
            +
                end
         | 
| 145 | 
            +
             | 
| 146 | 
            +
                def address(string)
         | 
| 147 | 
            +
                  space_precheck
         | 
| 148 | 
            +
                  @ssml_content += "<say-as interpret-as=\"address\">" + string + "</say-as>"
         | 
| 149 | 
            +
                end
         | 
| 150 | 
            +
             | 
| 151 | 
            +
                def interjection(string)
         | 
| 152 | 
            +
                  space_precheck
         | 
| 153 | 
            +
                  @ssml_content += "<say-as interpret-as=\"interjection\">" + string + "</say-as>"
         | 
| 154 | 
            +
                end
         | 
| 155 | 
            +
             | 
| 156 | 
            +
                def expletive(string)
         | 
| 157 | 
            +
                  space_precheck
         | 
| 158 | 
            +
                  @ssml_content += "<say-as interpret-as=\"expletive\">" + string + "</say-as>"
         | 
| 159 | 
            +
                end
         | 
| 160 | 
            +
             | 
| 161 | 
            +
                def sub(string,alias_str)
         | 
| 162 | 
            +
                  space_precheck
         | 
| 163 | 
            +
                  @ssml_content += "<sub alias=\"" + alias_str + "\">" + string + "</sub>"
         | 
| 164 | 
            +
                end
         | 
| 165 | 
            +
             | 
| 166 | 
            +
                def whisper(string)
         | 
| 167 | 
            +
                  if !string.nil? && !string.empty?
         | 
| 168 | 
            +
                    space_precheck
         | 
| 169 | 
            +
                    @ssml_content += "<amazon:effect name=\"whispered\">" + string + "</amazon:effect>"
         | 
| 170 | 
            +
                  end
         | 
| 171 | 
            +
                end
         | 
| 172 | 
            +
             | 
| 173 | 
            +
                def amazon_verb(string)
         | 
| 174 | 
            +
                  space_precheck
         | 
| 175 | 
            +
                  @ssml_content += "<w role=\"amazon:VB\">" + string + "</w>"
         | 
| 176 | 
            +
                end
         | 
| 177 | 
            +
             | 
| 178 | 
            +
                def amazon_participle(string)
         | 
| 179 | 
            +
                  space_precheck
         | 
| 180 | 
            +
                  @ssml_content += "<w role=\"amazon:VBD\">" + string + "</w>"
         | 
| 181 | 
            +
                end
         | 
| 182 | 
            +
             | 
| 183 | 
            +
                def amazon_noun(string)
         | 
| 184 | 
            +
                  space_precheck
         | 
| 185 | 
            +
                  @ssml_content += "<w role=\"amazon:NN\">" + string + "</w>"
         | 
| 186 | 
            +
                end
         | 
| 187 | 
            +
             | 
| 188 | 
            +
                def amazon_sense(string,sense = 1)
         | 
| 189 | 
            +
                  space_precheck
         | 
| 190 | 
            +
                  @ssml_content += "<w role=\"SENSE_" + sense.to_s + "\">" + string + "</w>"
         | 
| 191 | 
            +
                end
         | 
| 192 | 
            +
             | 
| 193 | 
            +
                def phoneme(string,alphabet = "ipa",ph = "")
         | 
| 194 | 
            +
                  space_precheck
         | 
| 195 | 
            +
                  @ssml_content += "<phoneme alphabet=\"" + alphabet + "\" ph=\"" + ph + "\">" + string + "</phoneme>"
         | 
| 196 | 
            +
                end
         | 
| 197 | 
            +
             | 
| 198 | 
            +
                def ssml
         | 
| 199 | 
            +
                  return "<speak>" + @ssml_content + "</speak>"
         | 
| 200 | 
            +
                end
         | 
| 201 | 
            +
             | 
| 202 | 
            +
                private
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                  def remove_characters(string)
         | 
| 205 | 
            +
                    return string.gsub(/['"`]/,'')
         | 
| 206 | 
            +
                  end
         | 
| 207 | 
            +
             | 
| 208 | 
            +
                  def space_precheck
         | 
| 209 | 
            +
                    if !@ssml_content.empty? && @ssml_content[-1] != " "
         | 
| 210 | 
            +
                      @ssml_content += " "
         | 
| 211 | 
            +
                    end
         | 
| 212 | 
            +
                  end
         | 
| 213 | 
            +
             | 
| 214 | 
            +
              end
         | 
| 215 | 
            +
             | 
| 216 | 
            +
            end
         | 
| @@ -0,0 +1,171 @@ | |
| 1 | 
            +
            module SsmlBuilder::String
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              def ssml_say
         | 
| 4 | 
            +
                return ssml_remove_special_characters(self)
         | 
| 5 | 
            +
              end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              def ssml_paragraph
         | 
| 8 | 
            +
                return "<p>" + ssml_remove_special_characters(self) + "</p>"
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              def ssml_p
         | 
| 12 | 
            +
                # ALIAS for paragraph
         | 
| 13 | 
            +
                return self.ssml_paragraph
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              def ssml_sentence
         | 
| 17 | 
            +
                return "<s>" + ssml_remove_special_characters(self) + "</s>"
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              def ssml_rate(rate = "medium")
         | 
| 21 | 
            +
                if !["x-slow", "slow", "medium", "fast", "x-fast"].include?(rate)
         | 
| 22 | 
            +
                  rate = (rate.to_i > 20 ? rate.to_i : 20).to_s + "%"
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
                return "<prosody rate=\"" + rate + "\">" + ssml_remove_special_characters(self) + "</prosody>"
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              def ssml_pitch(pitch = "medium")
         | 
| 28 | 
            +
                if !["x-low", "low", "medium", "high", "x-high"].include?(pitch)
         | 
| 29 | 
            +
                  pitch = pitch.to_f > -33.3 ? pitch.to_f : -33.3
         | 
| 30 | 
            +
                  pitch = (pitch.to_f < 50.0 ? pitch : 50.0)
         | 
| 31 | 
            +
                  pitch = pitch > 0 ? "+%g%" % ("%.2f" % pitch) : "%g%" % ("%.2f" % pitch)
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
                return "<prosody pitch=\"" + pitch + "\">" + ssml_remove_special_characters(self) + "</prosody>"
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              def ssml_volume(volume = "medium")
         | 
| 37 | 
            +
                if !["silent", "x-soft", "soft", "medium", "loud", "x-loud"].include?(volume)
         | 
| 38 | 
            +
                  volume = volume.to_f < 4.08 ? volume.to_f : 4.08
         | 
| 39 | 
            +
                  volume = volume > 0 ? "+%gdB" % ("%.2f" % volume) : "%gdB" % ("%.2f" % volume)
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
                return "<prosody volume=\"" + volume + "\">" + ssml_remove_special_characters(self) + "</prosody>"
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              def ssml_prosody
         | 
| 45 | 
            +
                # UNKOWN HOW I WANT TO USE
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
              def ssml_pause(length = "medium")
         | 
| 49 | 
            +
                if ["none", "x-weak", "weak", "medium", "strong", "x-strong"].include?(length.downcase)
         | 
| 50 | 
            +
                  return "<break strength=\"" + length.downcase + "\"/>"
         | 
| 51 | 
            +
                else
         | 
| 52 | 
            +
                  return "<break time=\"" + length + "\"/>"
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
              def ssml_break(length = "medium")
         | 
| 57 | 
            +
                # ALIAS for ssml_pause
         | 
| 58 | 
            +
                return self.ssml_pause(length)
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              def ssml_emphasis(level = "moderate")
         | 
| 62 | 
            +
                return "<emphasis level=\"" + level + "\">" + self + "</emphasis>"
         | 
| 63 | 
            +
              end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
              def ssml_audio
         | 
| 66 | 
            +
                return "<audio src=\"" + self + "\"/>"
         | 
| 67 | 
            +
              end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
              def ssml_spell_out
         | 
| 70 | 
            +
                return "<say-as interpret-as=\"spell-out\">" + self + "</say-as>"
         | 
| 71 | 
            +
              end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
              def ssml_characters
         | 
| 74 | 
            +
                return "<say-as interpret-as=\"characters\">" + self + "</say-as>"
         | 
| 75 | 
            +
              end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
              def ssml_cardinal
         | 
| 78 | 
            +
                return "<say-as interpret-as=\"cardinal\">" + self + "</say-as>"
         | 
| 79 | 
            +
              end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
              def ssml_number
         | 
| 82 | 
            +
                return "<say-as interpret-as=\"number\">" + self + "</say-as>"
         | 
| 83 | 
            +
              end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
              def ssml_ordinal
         | 
| 86 | 
            +
                return "<say-as interpret-as=\"ordinal\">" + self + "</say-as>"
         | 
| 87 | 
            +
              end
         | 
| 88 | 
            +
             | 
| 89 | 
            +
              def ssml_digits
         | 
| 90 | 
            +
                return "<say-as interpret-as=\"digits\">" + self + "</say-as>"
         | 
| 91 | 
            +
              end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
              def ssml_fraction
         | 
| 94 | 
            +
                return "<say-as interpret-as=\"fraction\">" + self + "</say-as>"
         | 
| 95 | 
            +
              end
         | 
| 96 | 
            +
             | 
| 97 | 
            +
              def ssml_unit
         | 
| 98 | 
            +
                return "<say-as interpret-as=\"unit\">" + self.gsub(/ /,'') + "</say-as>"
         | 
| 99 | 
            +
              end
         | 
| 100 | 
            +
             | 
| 101 | 
            +
              def ssml_date
         | 
| 102 | 
            +
                return "<say-as interpret-as=\"date\">" + self + "</say-as>"
         | 
| 103 | 
            +
              end
         | 
| 104 | 
            +
             | 
| 105 | 
            +
              def ssml_time
         | 
| 106 | 
            +
                return "<say-as interpret-as=\"time\">" + self + "</say-as>"
         | 
| 107 | 
            +
              end
         | 
| 108 | 
            +
             | 
| 109 | 
            +
              def ssml_telephone
         | 
| 110 | 
            +
                return "<say-as interpret-as=\"telephone\">" + self + "</say-as>"
         | 
| 111 | 
            +
              end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
              def ssml_phone
         | 
| 114 | 
            +
                # ALIAS of telephone
         | 
| 115 | 
            +
                return self.ssml_telephone
         | 
| 116 | 
            +
              end
         | 
| 117 | 
            +
             | 
| 118 | 
            +
              def ssml_address
         | 
| 119 | 
            +
                return "<say-as interpret-as=\"address\">" + self + "</say-as>"
         | 
| 120 | 
            +
              end
         | 
| 121 | 
            +
             | 
| 122 | 
            +
              def ssml_interjection
         | 
| 123 | 
            +
                return "<say-as interpret-as=\"interjection\">" + self + "</say-as>"
         | 
| 124 | 
            +
              end
         | 
| 125 | 
            +
             | 
| 126 | 
            +
              def ssml_expletive
         | 
| 127 | 
            +
                return "<say-as interpret-as=\"expletive\">" + self + "</say-as>"
         | 
| 128 | 
            +
              end
         | 
| 129 | 
            +
             | 
| 130 | 
            +
              def ssml_sub(alias_str)
         | 
| 131 | 
            +
                return "<sub alias=\"" + alias_str + "\">" + self + "</sub>"
         | 
| 132 | 
            +
              end
         | 
| 133 | 
            +
             | 
| 134 | 
            +
              def ssml_whisper
         | 
| 135 | 
            +
                return "<amazon:effect name=\"whispered\">" + self + "</amazon:effect>"
         | 
| 136 | 
            +
              end
         | 
| 137 | 
            +
             | 
| 138 | 
            +
              def ssml_amazon_verb
         | 
| 139 | 
            +
                return "<w role=\"amazon:VB\">" + self + "</w>"
         | 
| 140 | 
            +
              end
         | 
| 141 | 
            +
             | 
| 142 | 
            +
              def ssml_amazon_participle
         | 
| 143 | 
            +
                return "<w role=\"amazon:VBD\">" + self + "</w>"
         | 
| 144 | 
            +
              end
         | 
| 145 | 
            +
             | 
| 146 | 
            +
              def ssml_amazon_noun
         | 
| 147 | 
            +
                return "<w role=\"amazon:NN\">" + self + "</w>"
         | 
| 148 | 
            +
              end
         | 
| 149 | 
            +
             | 
| 150 | 
            +
              def ssml_amazon_sense(sense = 1)
         | 
| 151 | 
            +
                return "<w role=\"SENSE_" + sense.to_s + "\">" + self + "</w>"
         | 
| 152 | 
            +
              end
         | 
| 153 | 
            +
             | 
| 154 | 
            +
              def ssml_phoneme(alphabet = "ipa",ph = "")
         | 
| 155 | 
            +
                return "<phoneme alphabet=\"" + alphabet + "\" ph=\"" + ph + "\">" + self + "</phoneme>"
         | 
| 156 | 
            +
              end
         | 
| 157 | 
            +
             | 
| 158 | 
            +
              def to_ssml
         | 
| 159 | 
            +
                return "<speak>" + self + "</speak>"
         | 
| 160 | 
            +
              end
         | 
| 161 | 
            +
             | 
| 162 | 
            +
              private
         | 
| 163 | 
            +
             | 
| 164 | 
            +
                def ssml_remove_special_characters(string)
         | 
| 165 | 
            +
                  return string.gsub(/['"`]/,'')
         | 
| 166 | 
            +
                end
         | 
| 167 | 
            +
            end
         | 
| 168 | 
            +
             | 
| 169 | 
            +
            class String
         | 
| 170 | 
            +
              include SsmlBuilder::String
         | 
| 171 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,120 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: ssml_builder
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Paul McMahon
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2017-06-22 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: bundler
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '1.7'
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '1.7'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rake
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ">="
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rspec
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - "~>"
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '3.2'
         | 
| 48 | 
            +
                - - ">="
         | 
| 49 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 50 | 
            +
                    version: 3.2.0
         | 
| 51 | 
            +
              type: :development
         | 
| 52 | 
            +
              prerelease: false
         | 
| 53 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 54 | 
            +
                requirements:
         | 
| 55 | 
            +
                - - "~>"
         | 
| 56 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 57 | 
            +
                    version: '3.2'
         | 
| 58 | 
            +
                - - ">="
         | 
| 59 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 60 | 
            +
                    version: 3.2.0
         | 
| 61 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 62 | 
            +
              name: rspec-mocks
         | 
| 63 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 64 | 
            +
                requirements:
         | 
| 65 | 
            +
                - - "~>"
         | 
| 66 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 67 | 
            +
                    version: '3.2'
         | 
| 68 | 
            +
                - - ">="
         | 
| 69 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 70 | 
            +
                    version: 3.2.0
         | 
| 71 | 
            +
              type: :development
         | 
| 72 | 
            +
              prerelease: false
         | 
| 73 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 74 | 
            +
                requirements:
         | 
| 75 | 
            +
                - - "~>"
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            +
                    version: '3.2'
         | 
| 78 | 
            +
                - - ">="
         | 
| 79 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 80 | 
            +
                    version: 3.2.0
         | 
| 81 | 
            +
            description: Gem for building SSML messages for Amazon Alexa
         | 
| 82 | 
            +
            email:
         | 
| 83 | 
            +
            - colpan@sircolpaniusjackson.com
         | 
| 84 | 
            +
            executables: []
         | 
| 85 | 
            +
            extensions: []
         | 
| 86 | 
            +
            extra_rdoc_files: []
         | 
| 87 | 
            +
            files:
         | 
| 88 | 
            +
            - Gemfile
         | 
| 89 | 
            +
            - LICENSE.txt
         | 
| 90 | 
            +
            - README.md
         | 
| 91 | 
            +
            - Rakefile
         | 
| 92 | 
            +
            - lib/ssml_builder.rb
         | 
| 93 | 
            +
            - lib/ssml_builder/builder.rb
         | 
| 94 | 
            +
            - lib/ssml_builder/core_extensions/string.rb
         | 
| 95 | 
            +
            - lib/ssml_builder/version.rb
         | 
| 96 | 
            +
            homepage: https://github.com/colpan/ssml_builder
         | 
| 97 | 
            +
            licenses:
         | 
| 98 | 
            +
            - MIT
         | 
| 99 | 
            +
            metadata: {}
         | 
| 100 | 
            +
            post_install_message: 
         | 
| 101 | 
            +
            rdoc_options: []
         | 
| 102 | 
            +
            require_paths:
         | 
| 103 | 
            +
            - lib
         | 
| 104 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 105 | 
            +
              requirements:
         | 
| 106 | 
            +
              - - ">="
         | 
| 107 | 
            +
                - !ruby/object:Gem::Version
         | 
| 108 | 
            +
                  version: '0'
         | 
| 109 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 110 | 
            +
              requirements:
         | 
| 111 | 
            +
              - - ">="
         | 
| 112 | 
            +
                - !ruby/object:Gem::Version
         | 
| 113 | 
            +
                  version: '0'
         | 
| 114 | 
            +
            requirements: []
         | 
| 115 | 
            +
            rubyforge_project: 
         | 
| 116 | 
            +
            rubygems_version: 2.4.5.1
         | 
| 117 | 
            +
            signing_key: 
         | 
| 118 | 
            +
            specification_version: 4
         | 
| 119 | 
            +
            summary: Gem for building SSML messages for Amazon Alexa
         | 
| 120 | 
            +
            test_files: []
         |