TTS Custom Lexicon is not applied

Karin Hedberg 30 Reputation points
2023-03-30T10:16:43.3066667+00:00

I am trying to apply a custom lexicon to the Text-to-Speech service. Here is my lexicon file:

<?xml version="1.0" encoding="UTF-8"?>

<lexicon version="1.0"
      xmlns="http://www.w3.org/2005/01/pronunciation-lexicon"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.w3.org/2005/01/pronunciation-lexicon
      http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd"
      alphabet="x-sampa" xml:lang="sv-SE">
    <lexeme>
        <grapheme>BTW</grapheme>
        <alias>By the way</alias>
    </lexeme>
    <lexeme>
        <grapheme>😀</grapheme>
        <alias>test emoji</alias>
    </lexeme>
</lexicon>

It is uploaded to blob storage and I can access the URI (link). I also tried with a SAS link that i created, and that is also accessible to me via the browser: (link)

Now I am trying to apply my lexicon to a TTS service call using Python and the speech SDK.


import os
import azure.cognitiveservices.speech as speechsdk

region = os.environ.get("SPEECH_REGION")
subscription_key = os.environ.get("SPEECH_KEY")
speech_config = speechsdk.SpeechConfig(subscription=subscription_key, region=region)
speech_synthesiser = speechsdk.SpeechSynthesizer(speech_config=speech_config)
uri = "https://ttslexica.blob.core.windows.net/tts-lexica/sv-SE_lexicon.xml"
ssml = f"""<speak xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="http://www.w3.org/2001/mstts" xmlns:emo="http://www.w3.org/2009/10/emotionml" version="1.0" xml:lang="sv-SE"><voice name="sv-SE-SofieNeural"><lexicon uri="{uri}" />😀</voice></speak>"""

result = speech_synthesiser.speak_ssml(ssml)

This I expect the output to read "test emoji", but what I hear is "flinande ansikte" ("grinning face" in Swedish), the default name of the 😀 emoji.

Since I don't hear the expected result, it would be nice if I could find some information about any lexicon applied or not in the SpeechSynthesisResult object saved as the variable result.

  1. How do I succeed in making my lexicon apply to the request I am making?
  2. Is there any way of checking whether a blob file was accessed, e.g. from the Storage account view on Azure portal?
Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
2,069 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,619 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jiajun Zhang (SPEECH) 0 Reputation points Microsoft Employee
    2024-12-11T05:24:47.3633333+00:00

    We are fixing it, will notify when the fix is deployed.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.