Vocabulary management

Updated at:

A vocabulary corrects mispronounced words in speech synthesis, such as proper nouns, brand names, acronyms, and other terms with specific pronunciations. You define "source word → replacement text" rules in a vocabulary. During synthesis, the platform replaces the source words in your text with the corresponding replacement text before generating the audio. For example, you can customize the pronunciation of GitHub or ensure that API is spelled out letter by letter. In the left navigation pane, click Voice Library > Vocabulary Management.

Page layout

  • Main Area: The content area for Voice Library > Vocabulary Management.

  • Cards Panel: Lists all vocabularies in the current workspace as cards. Each card displays the vocabulary's name, description, rule count, and last update time. When you hover over a card, Edit and Delete buttons appear in the top-right corner, and a Copy Vocabulary ID button appears in the bottom-right corner. The search bar at the top allows you to filter by name, description, or ID.

  • image

Core operations

1. Create a vocabulary

  1. Click the Create Vocabulary button in the top-right corner.

  2. In the dialog box, enter the following:

    • Name (Required): Up to 25 characters (e.g., "Product Names").

    • Description (Optional): Explain the purpose of the vocabulary to help your team members identify it.

  3. In the Replacement Rules section, define your rules, one per line. Enter the source word on the left and the replacement text on the right. Click Add Rule to add a new row, or click the trash icon at the end of a row to delete it.

  4. Click Create.

If you have many rules, you can use bulk import to paste them all at once. For details, see the "Bulk import and backup" section below.

Source words are case-sensitive and must match exactly. GitHub and github are treated as two different rules. If you need to cover both, you must add them as separate rules.

image

2. Use a vocabulary in code

After you create a vocabulary, hover over its card and click Copy Vocabulary ID in the bottom-right corner. The ID will look like 3f9a2c1e-7b4d-4e8a-9c0f-1d2e3f4a5b6c. Reference this ID in the run-task action for a real-time speech synthesis WebSocket connection by setting the parameters.vocabulary_id parameter:

{
  "header": {
    "action": "run-task",
    "task_id": "<your task ID>",
    "streaming": "duplex"
  },
  "payload": {
    "task_group": "audio",
    "task": "tts",
    "function": "SpeechSynthesizer",
    "model": "<model name>",
    "parameters": {
      "voice": "<voice ID>",
      "format": "mp3",
      "vocabulary_id": "3f9a2c1e-7b4d-4e8a-9c0f-1d2e3f4a5b6c"
    },
    "input": {}
  }
}

For the complete protocol specification, see the real-time speech synthesis WebSocket API documentation.

If you need to temporarily add or override rules for a specific task, you can also pass a task-level parameters.hot_fix.replace:

"parameters": {
  "vocabulary_id": "3f9a2c1e-7b4d-4e8a-9c0f-1d2e3f4a5b6c",
  "hot_fix": {
    "replace": [
      { "Qwen": "Tongyi Qwen" }
    ]
  }
}

Rules are merged based on the source word. If a source word exists in both the vocabulary and the hot_fix.replace list, the hot_fix.replace rule takes precedence. All other rules from the vocabulary are still applied.

The vocabulary_id can only be specified in a run-task action. It cannot be changed with a continue-task action after the task has started. You can only update temporary hot_fix.replace rules with a continue-task action.

3. View details

Click a vocabulary card to open its details panel. The panel displays the vocabulary ID, rule count, creation and update timestamps, description, and the complete list of rules (20 per page). The search bar at the top of the panel allows you to search by source word or replacement text. Click Edit in the top-right corner to start editing the vocabulary.

4. Edit a vocabulary

Hover over a vocabulary card and click Edit, or click Edit in the details panel. You can modify the name, description, and rules. Click Save to apply your changes.

Saving overwrites all existing rules. The platform does not version rules, making changes irreversible. For vocabularies with many rules or for major changes, back up your rules first by clicking Copy All Rules in the details panel.

After you save, new synthesis tasks will use the updated rules. The changes typically take effect within 30 seconds. Tasks that are already in progress will continue to use the rules they started with and are not affected.

5. Bulk import and backup

In the Create/Edit dialog box, click Bulk Import. Paste your rules into the text box, one per line, in the following format:

GitHub=Git Hub
API=A P I

You can also copy two columns (source word, replacement text) directly from an Excel sheet and paste them. The system automatically recognizes the Tab character as a separator. The import logic is as follows:

  • Whitespace around the delimiter is removed, and empty lines are ignored.

  • If the same source word appears multiple times in the pasted content, the last one takes precedence.

  • The imported content merges with existing rules in the dialog box: if a source word matches an existing rule, its replacement text is updated; new rules are appended.

  • Lines in an invalid format are skipped, and the system reports the corresponding line numbers.

Importing only populates the dialog box. The rules are not written to the system until you click Create or Save.

To back up or migrate a vocabulary, click Copy All Rules in its details panel. The copied content is in the source word=replacement text format and can be pasted directly back into the bulk import tool.

6. Delete a vocabulary

Hover over a vocabulary card and click Delete. After a second confirmation, the vocabulary is permanently deleted.

After deletion, any synthesis task that still references the ID will not fail. Instead, the task proceeds without applying the vocabulary's rules, and the pronunciation reverts to the default.

Key limitations

  • Vocabulary Limit: Each workspace supports up to 10 vocabularies. When you reach the limit, you must delete an unused vocabulary before creating a new one.

  • Rule and Character Limits:

    Item

    Limit

    Name

    Required, up to 25 characters.

    Description

    Optional, up to 2,048 characters.

    Rules per vocabulary

    Up to 500.

    Source word / replacement text

    Cannot be empty. Up to 20 characters each.

    Total vocabulary size

    Up to 64 KB.

    Character counts are based on Unicode characters. A Chinese character, a letter, or an emoji each counts as one character.

  • Exact Match with No Normalization: Source words are case-sensitive and differentiate between full-width and half-width characters. Leading and trailing spaces also count and are not removed automatically. The same source word cannot be duplicated within a vocabulary.

  • Control Characters Not Allowed: The source word and replacement text cannot contain control characters such as newlines or tabs.

  • Matching Logic: The service scans the input text from left to right. At any given position, it matches the longest possible source word. The service does not scan the replacement result for further matches. For example, if you have rules for both Ali → A and Alibaba Cloud → B, the text "Alibaba Cloud" will only be replaced with B. The order of rules in the list does not affect the outcome.

  • Mutually Exclusive with SSML: You cannot set enable_ssml=true and pass a vocabulary_id in the same request. This causes a parameter error. For SSML scenarios, use SSML tags to control pronunciation directly.

  • One Vocabulary per Task: A task can only reference one vocabulary. If you need to combine rules from multiple sets, merge them into a single vocabulary or use hot_fix.replace to add temporary rules.

  • Limits for Hot Fixes: The hot_fix.replace parameter accepts a maximum of 128 rules or 16 KB per request.

FAQ

  • Why don't my changes take effect immediately after saving? Rules only apply to new tasks. Tasks already in progress continue to use the rules that were active when they started.

  • Can I roll back to a previously saved version of my rules? No, the platform does not store historical versions. Back up your rules by using the Copy All Rules feature before making changes.

  • Source words require an exact, case-sensitive match. The service does not automatically normalize case. For example, a rule for hello → hullo will match the text hello but not Hello.

  • Does the order of the rules matter? No. The service always matches the longest possible source word at any position, regardless of the rule's order in the list.

  • Can the replacement text be matched by another rule? No. The output of a replacement is not scanned again. This prevents chain reactions and infinite loops between rules.

  • If I delete a vocabulary or use an invalid ID, will my requests fail?No, the task will not fail. It will ignore the vocabulary and continue with synthesis. The success response will include a warnings field to notify you of the issue. Any temporary hot_fix rules will still be applied.

  • Can I use SSML and a vocabulary at the same time? No. Passing a vocabulary_id when enable_ssml=true will cause a parameter error.

  • What should I do if I see the message "Vocabulary limit reached (10)"? Delete vocabularies that are no longer in use, or merge rules with similar purposes into a single vocabulary.

  • Can a source word contain an equal sign (=) during bulk import? When using the source word=replacement text format, the system uses the first = as the separator. Therefore, the source word cannot contain an =. If you need to include an equal sign in a source word, either paste the rules from a two-column Excel sheet (which uses a Tab separator) or add the rule manually in the dialog box.