adhearsion / ruby_speech

A ruby library for TTS & ASR document preparation
MIT License
101 stars 41 forks source link

Unexpected namespace prefix 'default' on SSML documents #24

Open Jared-Prime opened 10 years ago

Jared-Prime commented 10 years ago

I noticed running unit tests in our application that ssml nodes were getting a 'default' prefix after being embedded in a parent element. This occurred under Ruby 1.9.3-p484 but not under JRuby 1.7.4.

Sample test:

      context 'embedding nodes' do
        let(:fallback_doc){fallback_ssml(prompt, 'howdy.wav')}
        specify 'embeds fallback correctly' do
          subject.set_main_prompt(prompt, 'howdy.wav')
          subject.announcer_prompt.first.to_s.should eq fallback_doc.to_s
        end
      end

Sample test output running 1.9.3-p484:

Failures:

  1) Ifbyphone::Announcer protected methods #set_main_prompt embedding nodes embeds fallback correctly
     Failure/Error: subject.announcer_prompt.first.to_s.should eq fallback_doc.to_s

       expected: "<speak xmlns=\"http://www.w3.org/2001/10/synthesis\" version=\"1.0\" xml:lang=\"en-US\">\n  <audio src=\"howdy.wav\">\n    <voice name=\"Paul\">\n      <prosody rate=\"1.0\">Riddle me this!</prosody>\n    </voice>\n  </audio>\n</speak>"
            got: "<speak xmlns=\"http://www.w3.org/2001/10/synthesis\" version=\"1.0\" xml:lang=\"en-US\">\n  <audio src=\"howdy.wav\">\n    <default:voice name=\"Paul\">\n      <prosody rate=\"1.0\">Riddle me this!</prosody>\n    </default:voice>\n  </audio>\n</speak>"

       (compared using ==)

       Diff:

       @@ -1,8 +1,8 @@
        <speak xmlns="http://www.w3.org/2001/10/synthesis" version="1.0" xml:lang="en-US">
          <audio src="howdy.wav">
       -    <voice name="Paul">
       +    <default:voice name="Paul">
              <prosody rate="1.0">Riddle me this!</prosody>
       -    </voice>
       +    </default:voice>
          </audio>
        </speak>
     # ./spec/ifbyphone/announcer_spec.rb:346:in `block (5 levels) in <top (required)>'

You've Nyaned for 1.91 seconds

1 example, 1 failure

JRuby passes happily.

I wonder, but do not know, if this conditional treatment of Nokogiri implementation of JRuby contributes to this phenomenon. While this is not a huge issue for us since we're running JRuby in production, it caused some concern that the tests behave differently under different rubies. I am also concerned for anybody out there using MRI.

Thanks!

Jared-Prime commented 10 years ago

cc @runningferret and @sfgeorge

benlangfeld commented 10 years ago

So, this example has dependencies on your application and test suite and so cannot be reproduced easily. Please provide an example (or even a PR for a test on this project) demonstrating the issue.

At the same time, the prefix is compliant with the XML specification, and any XML compliant parser / TTS engine will have no trouble with such a document. As such, I'm going to mark this awaiting-contribution.

Jared-Prime commented 10 years ago

I'm going to mark this awaiting-contribution.

No problem; this is low priority. Just wanted to log the issue to put it on the record.