> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# Använda uttalslexikon

> **Note**
>
> **Instruktionsguide** · Förutsätter att du har slutfört [ElevenAPI- snabbstarten](/docs/sv/eleven-api/quickstart).

## Översikt

Med uttalslexikon kan du anpassa hur din AI-agent uttalar specifika ord eller fraser. Detta är särskilt användbart för att:

* Korrigera uttalet av namn, platser eller tekniska termer
* Säkerställa konsekvent uttal i alla samtal
* Anpassa regionala uttalsvariationer

ElevenLabs stöder både [IPA](https://en.wikipedia.org/wiki/International_Phonetic_Alphabet)- och [CMU](https://en.wikipedia.org/wiki/CMU_Pronouncing_Dictionary)-alfabet.

> **Info**
>
> Fonemtaggar i uttalslexikon fungerar endast med modellerna eleven\_v4, eleven\_flash\_v2 och eleven\_v3.
>
> Andra modeller hoppar över fonemtaggar i lexikonet och använder standarduttalet. För andra modeller kan du
> använda alias-taggar i stället för att ersätta stavningar eller fraser som ger det uttal du behöver.
>
> Om du vill använda IPA- och CMU-uttal på andra språk än engelska måste du
> byta till modellen eleven\_v4.

## Snabbstart

> **Note**
>
> Den här guiden förutsätter att du har [konfigurerat din API-nyckel och SDK](/docs/sv/eleven-api/quickstart). Slutför
> snabbstarten först om du inte redan har gjort det.

#### Skapa en uttalslexikonfil

I det här exemplet skapar vi en uttalslexikonfil för ordet `tomato`.

Den här regeln använder alfabetet "IPA" och uppdaterar uttalet för `tomato` och `Tomato` med ett annat uttal. PLS-filer är skiftlägeskänsliga, så vi inkluderar ordet både med och utan versalt "T".

> **Tip**
>
> Du kan använda AI-verktyg som Claude eller ChatGPT för att få hjälp med att skapa IPA- eller CMU-notationer för specifika ord.

**`dictionary.pls`**

```xml title="dictionary.pls"
<?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="ipa" xml:lang="en-US">
<lexeme>
    <grapheme>tomato</grapheme>
    <phoneme>/tə'meɪtoʊ/</phoneme>
</lexeme>
<lexeme>
    <grapheme>Tomato</grapheme>
    <phoneme>/tə'meɪtoʊ/</phoneme>
</lexeme>
</lexicon>
```

#### Skapa ett uttalslexikon från en fil via SDK:t

Skapa en ny fil med namnet `example.py` eller `example.mts`, beroende på vilket språk du väljer, och lägg till följande kod:

```python maxLines=0
from elevenlabs import ElevenLabs, PronunciationDictionaryVersionLocator
from elevenlabs.play import play

elevenlabs = ElevenLabs()

with open("dictionary.pls", "rb") as f:
    # this dictionary changes how tomato is pronounced
    pronunciation_dictionary = elevenlabs.pronunciation_dictionaries.create_from_file(
        file=f.read(), name="example"
    )

audio_1 = elevenlabs.text_to_speech.convert(
    text="Without the dictionary: tomato",
    voice_id="aMSt68OGf4xUZAnLpTU8",
    model_id="eleven_flash_v2",
)

audio_2 = elevenlabs.text_to_speech.convert(
    text="With the dictionary: tomato",
    voice_id="aMSt68OGf4xUZAnLpTU8",
    model_id="eleven_flash_v2",
    pronunciation_dictionary_locators=[
        PronunciationDictionaryVersionLocator(
            pronunciation_dictionary_id=pronunciation_dictionary.id,
            version_id=pronunciation_dictionary.version_id,
        )
    ],
)

# play the audio
play(audio_1)
play(audio_2)
```

```typescript maxLines=0
import { ElevenLabsClient, play } from "@elevenlabs/elevenlabs-js";
import "dotenv/config";
import fs from "node:fs";

const elevenlabs = new ElevenLabsClient();

const pronunciationDictionary = await elevenlabs.pronunciationDictionaries.createFromFile({
    file: fs.createReadStream("dictionary.pls"),
});

const audio1 = await elevenlabs.textToSpeech.convert("Without the dictionary: tomato", {
    voiceId: "aMSt68OGf4xUZAnLpTU8",
    modelId: "eleven_flash_v2",
});

const audio2 = await elevenlabs.textToSpeech.convert("With the dictionary: tomato", {
    voiceId: "aMSt68OGf4xUZAnLpTU8",
    modelId: "eleven_flash_v2",
    pronunciationDictionaryLocators: [
        {
            pronunciationDictionaryId: pronunciationDictionary.id,
            versionId: pronunciationDictionary.versionId,
        },
    ],
});

play(audio1);
play(audio2);
```

#### Kör koden

```python
python example.py
```

```typescript
npx tsx example.mts
```

Du bör höra två versioner av ljudet spelas upp genom dina högtalare, en med och en utan uttalslexikonet.

## Nästa steg

#### [API-referens](/docs/sv/api-reference/pronunciation-dictionaries/create-from-file)

Fullständig API-referens för uttalslexikon.

#### [TTS-streaming](/docs/sv/eleven-api/guides/how-to/text-to-speech/streaming)

Streama text till tal stegvis för uppspelning med lägre fördröjning.