3

We want to automatically generate the IPA Transcription for a person's name when we create a record for them in our application. Does anyone know of an API service that can do this?

6
  • 4
    How will you do that? Some names don't have a unique pronunciation, you'll have to ask the bearers (famous example: Reagan, it can be Reggan or Reegan) Nov 8, 2019 at 13:00
  • 1
    Taking Reagan as an example, if that is a name we want to store the IPA Transcription for, is there an API we could use to look it up? Nov 8, 2019 at 14:18
  • 1
    It's not an API, but in a previous answer of mine I indicated how eSpeak can be used to generate IPA transcriptions of arbitrary text in English and several other languages. Unfortunately, it's not optimized for personal names, and as others have indicated, those can be particularly tricky.
    – LjL
    Nov 8, 2019 at 16:20
  • You can match up the spelling with the phonemic (based on IPA but phonemic, not phonetic) spelling in Kenyon and Knott, which is online.
    – jlawler
    Nov 9, 2019 at 17:05
  • 1
    We had two Marias on my team who were easier to distinguish when speaking than when writing: /mərˈijə/ and /ˈmarjə/. Nov 11, 2019 at 11:45

2 Answers 2

4

IBM Watson Text-to-Speech will return IPA transcripts of any submitted word in Dutch, English, French, German, Italian, Japanese, Korean, Portuguese, and Spanish. I've used this API extensively and I have been happy with the service.

The Oxford English Dictionary does better IPA transcripts as they include every pronunciation for words with multiple pronunciations. But they do only English and only lemmas, no names.

Google Cloud Text-to-Speech doesn't provide IPA transcripts.

You could try EasyPronunciation.com. I've only used them a little.

1

Asking for an API limits your options because you’re basically asking for:

  1. Software that has that capability.
  2. Someone who has decided to host that software on a server and serve requests (free or for money).

It will be easier in the long run, if requiring more up-front learning, to just learn how to use a package that has that capability, on your machine. If you actually need it as an API serving requests over the web (like a micro service), you can set that up yourself as well, but that’s sort of a second topic.

The easiest way to see what packages are already ready to go is to search GitHub. It is much more convenient to have one expansive place where you can find lots of things in a similar form, instead of odds and ends on different websites.

I just found this:

https://github.com/dmort27/epitran

Epitran: A tool for transcribing orthographic text as IPA (International Phonetic Alphabet). 511 Stars.

So, to find a library, search GitHub. As to the underlying question of what a good NLP technique to achieve IPA transcription is (as in, if you wanted to try to write the program yourself), I leave to a different post (if you were to ask it).


And, it behooves me to say, GPT-4 has excellent NLP capability (with adequate prompting).

Watch this:

Prompt:

Hey GPT-4,

Show me a simple demo (for a beginner) of making an API call to the OpenAI API.

You can use any arbitrary completion model, like GPT3, it doesn’t matter.

In the example, show someone how you would ask the model to transcribe any given input text - particularly people’s names - into IPA (international phonetic alphabet).

Let the example serve as a good pedagogical demonstration of what an excellent prompt should look like - particularly, making use of few-shot learning (examples), to guide the model’s output to be accurate.

Show how the API call can contain a string prefix which is passed on every call - so the user just passes the words to be transcribed - but the model receives the same “instruction prompt” string, passed in the call, every time.

The model will be used as an “IPA generating engine”, so it is important it only outputs the IPA of the input, and does not output conversational text of any kind, that would pollute the data fields it will be filling.

Thanks!

ChatGPT (GPT-4):

Sure, let's take an example using Python and OpenAI's `openai.ChatCompletion` API which creates an interactive model.

We will be using the `gpt-3.5-turbo` model as an example here. In the prompt, we'll provide a few examples of text transcribed into IPA to guide the model's response.

Here's a simplified demonstration:

```python
import openai

openai.api_key = 'your-api-key'

# Instruction to the model
instruction = (
    "You are a highly skilled expert in phonetics and your task is to transcribe English text into the International Phonetic Alphabet (IPA). "
    "Here are a few examples:\n\n"
    "1. 'John' becomes /dʒɒn/\n"
    "2. 'Amy' becomes /ˈeɪmi/\n"
    "3. 'Christopher' becomes /ˈkrɪstəfər/\n"
    "Now, transcribe the following:\n"
)

# The name you want to transcribe
name = "Michael"

response = openai.ChatCompletion.create(
  model="gpt-3.5-turbo",
  messages=[
        {"role": "system", "content": instruction},
        {"role": "user", "content": name},
    ]
)

# Extracting the model's response
output = response['choices'][0]['message']['content']

print(output)
```

In this example, replace `'your-api-key'` with your actual OpenAI API key.

Note that the example IPA transcriptions are just illustrative and may not be 100% accurate. You would want to use accurate transcriptions in your actual use case to guide the model effectively. This is an essential aspect of the "few-shot learning" approach.

The model will receive the same instruction prompt on each API call, while the user will only need to pass the text to be transcribed. To maintain the integrity of the data fields, it's vital to correctly parse the response from the API call, specifically `response['choices'][0]['message']['content']`, which extracts the model's response.

Keep in mind that the OpenAI API rate limits apply, and usage costs vary depending on the model and the number of tokens processed. Make sure to review OpenAI's API documentation and Pricing page for more details.

One downside of using an LLM is the results are not guaranteed. You (or another human) did not write the rules by which it transcribes. It may be the case, if you were to test it, that it is extremely good. Or maybe it isn’t. It’s not formally proven.

But I would use it in this scenario.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.