07 April 2021

IPA spelling and the correct ' for Amazon Polly


Problem:
When sending IPA codes to AWS Polly it fails with

# aws polly synthesize-speech --text-type ssml --text '<phoneme alphabet="ipa" ph="{ipa}"></phoneme>'   --output-format mp3 --voice-id {voice}   blah.mp3

# ipa="ko̞.'lo̞ɾ"

/bin/bash: -c: line 0: unexpected EOF while looking for matching `"'
/bin/bash: -c: line 1: syntax error: unexpected end of file

If you tweak it long enough to get it out of bash into AWS you will get

An error occurred (InvalidSsmlException) when calling the SynthesizeSpeech operation: Invalid SSML request


Issue:
Initially you may think that the problem lies on the central " ' " character.

And you are right.

You may try to wrap it in different ways, but no joy.

The problem is not the wrapping, is the character itself.

If you try to put it on http://ipa-reader.xyz/ you will notice it fails there too.

But there are other words like iːsˈθɛtɪk that don't fail.

What is the problem?

The character "'" and "ˈ" are different


Solution:

Replace it with

# ipa=ipa.replace("'","ˈ")

Too Cool for Internet Explorer