~alcinnz/rhapsode

f112607ac3044467407099a78b7e73312dbf5e73 — Adrian Cochrane 4 years ago 075aa68
Read <progress> as a percentage, that's more international.

eSpeak can trivially localize this to it's various locales.
2 files changed, 12 insertions(+), 4 deletions(-)

M src/SpeechStyle.hs
M useragent.css
M src/SpeechStyle.hs => src/SpeechStyle.hs +11 -2
@@ 6,7 6,9 @@ import Data.CSS.Syntax.Tokens
import Data.CSS.Style
import Data.Text as Txt
import Data.Scientific (toRealFloat)
import Data.Maybe (isJust, catMaybes)
import Data.Maybe (isJust, catMaybes, fromMaybe)

import Text.Read (readMaybe) -- to parse <progress> into a more international textual representation.

data Unit' = Unit' Text Float
data SpeechStyle = SpeechStyle {


@@ 180,11 182,18 @@ parseCue [Ident "none"] = Just NoCue
parseCue _ = Nothing
isCue = isJust . parseCue

-- ParsingUtils
parseStrings (String txt:toks) = append txt <$> parseStrings toks
parseStrings (Function "-rhaps-percentage":String num:String denom:RightParen:toks) =
    append (pack $ show frac) <$> parseStrings toks
  where
    frac :: Int
    frac = round (readNum num / readNum denom * 100)
    readNum :: Text -> Float
    readNum = fromMaybe (0.0) . readMaybe . unpack
parseStrings [] = Just ""
parseStrings _ = Nothing

-- ParsingUtils
cssUnit n "khz" = Unit' "hz" (cssFloat n*1000)
cssUnit n unit = Unit' unit $ cssFloat n
cssFloat :: NumericValue -> Float

M useragent.css => useragent.css +1 -2
@@ 86,8 86,7 @@ q, blockquote {voice-family: female 2}
cite {voice-stress: reduce}
dialog {speak: never} dialog[open] {speak: always}
kbd {speak-as: spell-out}
progress {content: attr(value) " of " attr(max)}
progress:lang(hu) {content: attr(value) " a " attr(max) "-ból"} /* FIXME depending on number of vowels, should be -ből */
progress {content: -rhaps-percentage(attr(value) attr(max)) "%"}
sub {voice-rate: x-fast}
sup {voice-rate: fast}
var {voice-rate: slow}