Skip to content
Text to IPA converter in JavaScript
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
lib
.gitignore
LICENSE
README.md

README.md

text-to-ipa JS Version License: GPL v3

Text to IPA converter in JavaScript

This comes with the core dictionary lookup and example frontend. This project assumes you will be running this translator in a browser of some sort. text-to-ipa.js contains the main logic for loading the ipadict.txt and looking up words, while converter-form.js and example-translator.html provide an interface.

Further reading on how this all takes place can be found inside the respective .js files where extensive documentation can be found.

An example you can use is in the example-translator.html file. Just download the repository and open up that file in a web browser.

Getting Started

This tool implies that the CMU-IPA Dictionary will be used. You can load any dictionary you want into this program, but the method to lookup words assumes it will be in the CMU format.

This was kind of a pain to get working, as most of the time was found looking for a good IPA dictionary which was ultimately found here. This dictionary is included with this repository by default.

Deploying

  1. Include the following in the web page you want to deploy a converter to:
<script src="./text-to-ipa.js"></script>
<script src="./converter-form.js"></script>
  1. Point the TextToIPA Object to the CMU IPA Dictionary like such:
window.onload = TextToIPA.loadDict('./ipadict.txt');
  1. Set up a UI for the converter in the webpage. Here's an example:
<div id="js-text-to-ipa-form">

  <ul style="list-style-type: none;">
    <li><textarea id="ipa-in" placeholder="Write text here!" rows="4" cols="50"></textarea></li>
    <li class="button"><button type="button" id="js-ipa-submit" onClick="ConverterForm.convert('ipa-in', 'ipa-out', 'ipa-err')">Convert!</button></li>
    <li><textarea readonly id="ipa-out" placeholder="aʊtpʊt gəʊz hɪə!" rows="4" cols="50"></textarea></li>
  </ul>

  <ul style="list-style-type: none;">
    <li><noscript><p>This converter will not work unless Javascript is enabled.</p></noscript></li>
    <li>
      <div id="ipa-err">
        <p>Errors will go here if you make any. (This will be overwritten!)</p>
      </div>
    </li>
  </ul>
</div>

See examples for more.

Example

For a styled and better looking version instead of one that has no CSS you can test it on my website here

Basic Usage

This converter will simply look up each word in the CMU to IPA dictionary, and pop out the resulting phonetic text.

License

GPL

This code is released under the GNU GENERAL PUBLIC LICENSE. All works in this repository are meant to be utilized under this license. You are entitled to remix, remodify, and redistribute this program as you see fit, under the condition that all derivative works must use the GPL Version 3.

Acknowledgements

CMU IPA Dictionary

You can’t perform that action at this time.