Skip to content

[TTS] Magpie multilingual: English words inside Arabic sentences are hallucinated or mispronounced #16592

Open

Description

@hadeelbkh

Is your feature request related to a problem? Please describe.

I'm using magpie_tts_multilingual_357m (v2607) for Arabic. And when there is code-switching speech (English words in an Arabic sentence), the model mispronounces that word or hallucinates it.

This is a big deal in Arabic, because we mix English terms all the time in our conversations. For example, terms in banking, tech or customer service ("transfer", "OTP", "Apple Pay", "credit card"...).

The reason is that the language param picks one tokenizer for the whole sentence. So, for Arabic text, everything goes to arabic_MSA_chartokenizer (or the SA/AE one), including any English words. The Arabic char tokenizer accepts Latin letters, but the model was never trained on them in Arabic context, so it has no idea how to say them.

How I tested it:

  • 30 banking sentences: 24 in white Arabic and 6 in Saudi dialect. They cover single English words, phrases, acronyms, brand names, and English at the start, middle and end of the sentence.
  • Numbers are written as Arabic words, because the Arabic char tokenizer has no digits.
  • I used examples/tts/magpietts_inference.py with the same flags as L2_TTS_InferEvaluate_Magpietts_SeenSpeakers.sh, with all 5 speakers. The tokenizer was set with tokenizer_names (arabic_MSA_chartokenizer for white, arabic_SA_chartokenizer for Saudi).
  • I transcribed the output with whisper-large-v3-turbo and checked whether each English term shows up.

Results (150 clips):

English terms Whisper could find 0 / 185
Arabic words around them that came out fine ~88%

So the Arabic part works, and the English part fails every time.

Some examples (speaker Aria):

1. Two English phrases (Saudi)

  • Text: وش الفرق بين ال credit card وال debit card؟
  • Whisper heard: واش الفرق بين ال... (then repeats و for 3 seconds)
S03_Aria.mp4

2. Brand name at the start (Saudi)

  • Text: Apple Pay ما يشتغل عندي من أمس، وش المشكلة؟
  • Whisper heard: ما يشتغل عندي من أمس وش المشكلة؟ (Apple Pay is gone)
S05_Aria.mp4

3. Acronym in the middle (white Arabic)

  • Text: إذا نسيت ال PIN، يمكنك إعادة تعيينه من التطبيق.
  • Whisper heard: إذا نسيت آل رأ يمكنك إعادة تعيينه من التطبيق
W14_Aria.mp4

4. Three English terms: start, middle and end (white Arabic)

  • Text: Premium account يمنحك cashback أعلى ودخولًا مجانيًا إلى airport lounges.
  • Whisper heard: تلس كي يمنحك لس أعلى ودخولاً مجانياً إلى تي اتي
W24_Aria.mp4

Describe the solution you'd like

I tried a fix on my side and it works. Instead of one tokenizer for the whole sentence, split the text by script:

  • Arabic words go to the Arabic char tokenizer (MSA, SA or AE, based on the language code)
  • Latin words go to english_phoneme
  • then join the token ids and generate as usual

Both tokenizers are already in the checkpoint and share the same embedding table, so this needs no new weights, no fine-tuning and no change to the model. In my tests the English words come out right, and latency is the same as plain Arabic or plain English.

What I'd like to add in a PR:

  • An opt-in way to turn this on, so current behavior doesn't change. For example a language code like ar-en / ar-SA-en, or a config flag. I'm happy to follow whatever you prefer.
  • Only words with Latin letters go to English. Digits and punctuation stay with the Arabic part.
  • Deterministic English G2P for the routed words, because the random grapheme fallback (phoneme_probability) brings back the same problem.
  • Unit tests, plus before/after numbers with the same 30 sentences and setup as above.

Something like:

audio, audio_len = model.do_tts(
    "أبغى أسوي transfer لحساب أخوي، كيف أسويه؟",
    language="ar-SA-en", 
    speaker_index=0,
)

Describe alternatives you've considered

  • Fine-tuning on Arabic-English code-switched data: I tried it and it didn't fix the English words.
  • Writing English words in Arabic letters (for example "ترانسفير"): it works sometimes, but it's not real English pronunciation. It also needs a dictionary or rules for every word, and users don't type like that.
  • Using IPA (|...|) for the English words: this doesn't work for Arabic. The |...| syntax is only handled by the phoneme (G2P) tokenizers, and the Arabic char tokenizer just skips IPA symbols as unknown chars. Even for languages where it works, users would have to write phonemes by hand.

Additional context

  • This builds on [TTS] Fix LANGUAGE_TOKENIZER_MAP fallback to english_phoneme for v2607 languages #16591. That PR fixes ar, ar-SA and ar-AE falling back to english_phoneme in LANGUAGE_TOKENIZER_MAP. Without it, Arabic doesn't even reach the Arabic tokenizer with the v2607 checkpoint.
  • Hindi and Japanese already handle English words in their own way (Hindi G2P uses both Hindi and English pronunciation dicts, and Japanese reads English loanwords through katakana). Arabic uses a char tokenizer with no G2P, so it has nothing like that yet.

Would you accept a PR for this? And which design do you prefer, a new language code or a config flag?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    community-requestwaiting-on-maintainers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions