Skip to content

Instantly share code, notes, and snippets.

@AutoSponge
Last active September 12, 2022 15:58
Show Gist options
  • Save AutoSponge/f68870d00b73eaccecb451eef4c3da1d to your computer and use it in GitHub Desktop.
Save AutoSponge/f68870d00b73eaccecb451eef4c3da1d to your computer and use it in GitHub Desktop.

Expansion of ARIA Pronunciation Proposal

ref: https://docs.google.com/document/d/1GzVgbwcldWAP3l6yc3KLSRy4rr_qRusEE566viui0_o/edit#

The Pronunciation Task Force (TF) has evaluated multiple approaches to pronunciation and summarized their analysis in the Gap Analysis. The ARIA proposal, through an aria-pronouce attribute, provides an improved technique for authors to correct pronunciation and substitution.

However, we believe with slight modifications, the ARIA proposal could also achieve similar results for additional, priorty features. The priority features identified by the Pronunciation TF are:

  • Language (covered by HTML and RFC 5646 with possible modifications for historical variants, dialects, etc.)
  • Phonetic Pronunciation (covered by the core of the ARIA proposal)
  • Substitution
  • Say As
  • Pausing (Break)

Substitution

For substitution, the alias key could indicate an expansion.

<script>
document.pronunciationDict = {
  "en-US": {
    "W3C": {
      "alias": "World Wide Web Consortium"
    }
  }
};
</script>
<span aria-pronounce="alias">W3C</span>

Say-as

For say-as, the interpret-as value can be used to key different pronunciations. This does not address parsing of various formats, such as date or currency.

<script>
document.pronunciationDict = {
  "en-US": {
    "10": {
      "characters": "1 0",
      "ordinal": "tenth",
      "cardinal": "ten"
    },
    "λ": {
      "symbol": "lambda"
    },
    "Ω": {
      "symbol": /oʊˈmeɪɡə/
    }
  }
};
</script>
<span aria-pronounce="characters">10</span>
<span aria-pronounce="ordinal">10</span>
<span aria-pronounce="cardinal">10</span>
<span aria-pronounce="symbol">λ</span>
<span aria-pronounce="symbol">Ω</span>

Pausing

For pausing, common punctuation or other characters could map to pauses but this would require a different notation from the phonetic and ipa notations used in the other examples.

<script>
document.pronunciationDict = {
  "en-US": {
    "...": {
      "break": "[250ms]"
    }
  }
};
</script>
We will put it by, that when he comes again<span aria-pronounce="break">...</span> But it may be months, perhaps, before THAT happens.

It's unclear, from the ARIA proposal, if , was keyed into the dictionary and the entire example was wrapped with <div aria-pronounce="break"> whether or not the individual commas would get parsed. For now, it's assumed that each comma would need to be separately wrapped to ensure the proper timing.

Emphasis/Whisper

In the previous example (Jane Austen’s Sense and Sensibility), "THAT" should be read with emphasis. However, not only would creating such a key/value pair require a new notation for emphasis (e.g., {{THAT}}), any emphasized text would need to be added to the dictionary even if no pronunciation hint is needed. A SENTENCE WITH EVERY WORD HIGHLIGHTED (to quote a recent commercial), would require significant markup and thus, this probably isn't the proper technique.

If there were a substitution notation, like for RegExp, perhaps there could still be a solution using this proposal. It might look like this: $emphasize': '{{$}}' where any text wrapped with <span aria-pronounce="$emphasize"> leaves the content unaltered. Like other voice changes (gender, age, emotion), this notation could be independant from locale and/or apply to multiple locales.

<script>
document.pronunciationDict = {
  "$": {
    "$emphasize": "{{$}}",
    "$whisper": "}}${{"
  }
  "en-US": {
    "...": {
      "break": "[250ms]"
    }
  }
};
</script>
We will put it by, that when he comes again<span aria-pronounce="break">...</span> But it may be months, perhaps, before <span aria-pronounce="$emphasize">THAT</span> happens.
@AutoSponge
Copy link
Author

Should we include the example for inches and minutes?

@AutoSponge
Copy link
Author

Still needed:

  • clarification of how HTML lang, author locale, and user locale can/should interact
  • a mechanism for offering choice to a user (locale?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment