adhearsion / ruby_speech

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

Improper rendering of SSML fractional durations (0.5s vs 500ms) #48

Closed chewi closed 6 years ago

chewi commented 7 years ago

When trying an SSML Break time of 0.5 under Adhearsion, FreeSWITCH treats this as 0 seconds. This makes some sense as the spec does not say that you can pass fractional seconds, only whole seconds or milliseconds. If I modify set_time_attribute to do the following then it works correctly.

self[key] = value == value.round ? "#{value.to_i}s" : "#{(value * 1000).to_i}ms"

However, this has other implications. If you read the time value from the Break element, it simply casts the string with to_f, returning 3.0 when 3 was given or 3500.0 when 3.5 was given. I guess we need get_time_attribute to convert back the other way? I also can't work out how to fix importing of millisecond values from XML.

It would have been easier to just use milliseconds all the time but I guess it's too late for that now.

benlangfeld commented 7 years ago

It would have been easier to just use milliseconds all the time but I guess it's too late for that now.

I don't think so. It makes sense to me to avoid this complexity by doing that.

chewi commented 6 years ago

Dealing with this in #49. Don't recall exactly why I found it so hard the first time.