All Products
Search
Document Center

Alibaba Cloud Model Studio:Hotword kustom

Last Updated:Mar 26, 2026

Gunakan fitur hotword dalam tugas pengenalan ucapan ketika istilah khusus domain—seperti nama produk atau kata benda khusus—tidak dikenali secara akurat. Tambahkan istilah tersebut sebagai hotword untuk meningkatkan akurasi pengenalan.

Kata Pemicu

Fitur hotword memungkinkan Anda meningkatkan akurasi pengenalan kata-kata tertentu dengan menyediakan array JSON berisi istilah-istilah tersebut. Setiap objek dalam array mendefinisikan satu hotword beserta propertinya.

Contoh: Meningkatkan akurasi pengenalan judul film (untuk model seri Fun-ASR dan Paraformer)

[
    {"text": "赛德克巴莱", "weight": 4, "lang": "zh"},
    {"text": "Seediq Bale", "weight": 4, "lang": "en"},
    {"text": "夏洛特烦恼", "weight": 4, "lang": "zh"},
    {"text": "Goodbye Mr. Loser", "weight": 4, "lang": "en"},
    {"text": "阙里人家", "weight": 4, "lang": "zh"},
    {"text": "Confucius' Family", "weight": 4, "lang": "en"}
]

Deskripsi bidang:

Parameter

Tipe

Wajib

Deskripsi

text

string

Ya

Teks hotword.

Bahasa teks hotword harus didukung oleh model yang dipilih. Bahasa yang didukung bervariasi tergantung modelnya.

Hotword meningkatkan akurasi pengenalan atau terjemahan. Gunakan kata aktual, bukan kombinasi acak karakter. Aturan berikut membatasi panjang teks hotword:

  • Berisi karakter non-ASCII: Jumlah total karakter dalam string tidak boleh melebihi 15. Ini mencakup karakter non-ASCII (seperti karakter Tionghoa, kana Jepang, Hangul Korea, dan huruf Cyrillic Rusia) serta karakter ASCII.

    Contoh:

    • ✅ "厄洛替尼盐酸盐" (7 karakter)

    • ✅ "EGFR抑制剂" (7 karakter, di mana "EGFR" terdiri dari 4 karakter ASCII)

    • ✅ "こんにちは" (5 karakter)

    • ✅ "Фенибут Белфарм" (15 karakter, termasuk spasi)

    • ❌ "Клофелин Белмедпрепараты" (24 karakter)

  • Hanya berisi karakter ASCII: Jumlah segmen dalam string tidak boleh melebihi tujuh. Segmen adalah rangkaian berurutan karakter ASCII yang dipisahkan oleh spasi.

    Contoh:

    • ✅ "Exothermic reaction" → 2 segmen

    • ✅ "Human immunodeficiency virus type 1" → 5 segmen

    • ❌ "The effect of temperature variations on enzyme activity in biochemical reactions" → 11 segmen

weight

int

Tidak

Bobot hotword. Nilai umum adalah 4.

Rentang nilai: [1, 5].

Jika hasilnya tidak meningkat secara signifikan, Anda dapat menaikkan bobotnya. Namun, bobot yang terlalu tinggi mungkin mengurangi akurasi pengenalan kata lain.

lang

string

Tidak

Kode bahasa. Ini memungkinkan Anda meningkatkan hotword untuk bahasa tertentu yang didukung oleh model ASR. Jika Anda tidak dapat menentukan bahasa sebelumnya, Anda dapat mengosongkan bidang ini, dan model akan mendeteksi bahasa secara otomatis.

Lihat referensi API model untuk daftar bahasa yang didukung beserta kode-kodenya. Saat memanggil layanan pengenalan ucapan, pastikan Anda menentukan bahasa yang sama. Jika Anda menentukan bahasa dalam language_hints, hotword untuk bahasa lain tidak akan berlaku.

Model yang didukung

Fitur ini saat ini belum didukung.

Penagihan

Fitur hotword gratis.

Batas hotword

  1. Setiap akun dapat membuat hingga 10 daftar hotword. Kuota ini dibagi di seluruh model. Untuk meminta peningkatan, kirimkan tiket.

  2. Setiap daftar hotword dapat berisi hingga 500 hotword.

Panduan cepat: Buat dan gunakan daftar hotword

Alur kerja

Membuat daftar hotword dan menggunakannya untuk pengenalan ucapan melibatkan dua langkah berurutan:

  1. Buat daftar hotword

    Panggil API Create. Pada langkah ini, Anda harus menentukan parameter target_model (targetModel dalam Java) untuk mengaitkan daftar hotword dengan model pengenalan ucapan tertentu.

    Jika Anda sudah memiliki daftar hotword, Anda dapat melewati langkah ini. Untuk melihat daftar yang sudah ada, panggil API Query all.

  2. Gunakan daftar hotword untuk pengenalan ucapan.

    Panggil API pengenalan ucapan dan sertakan ID daftar hotword dalam permintaan. Model pengenalan ucapan yang digunakan pada langkah ini harus sesuai dengan target_model (targetModel dalam Java) yang digunakan saat membuat daftar hotword.

Prasyarat

  1. Dapatkan Kunci API: Dapatkan Kunci API. Untuk keamanan yang lebih baik, simpan Kunci API Anda dalam variabel lingkungan.

  2. Instal SDK: Instal versi terbaru SDK DashScope.

Contoh kode

Contoh menggunakan file audio asr_example.wav.

Python

import dashscope
from dashscope.audio.asr import *
import os


# Kunci API untuk wilayah Singapura dan Tiongkok (Beijing) berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
# Jika Anda belum mengatur variabel lingkungan DASHSCOPE_API_KEY, ganti baris berikut dengan Kunci API Anda: dashscope.api_key = "sk-xxx"
dashscope.api_key = os.environ.get('DASHSCOPE_API_KEY')

# Berikut adalah URL untuk wilayah Singapura. Untuk menggunakan model dari wilayah Tiongkok (Beijing), gunakan https://dashscope.aliyuncs.com/api/v1.
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'

# Berikut adalah URL untuk wilayah Singapura. Untuk menggunakan model dari wilayah Tiongkok (Beijing), gunakan wss://dashscope-intl.aliyuncs.com/api-ws/v1/inference.
dashscope.base_websocket_api_url='wss://dashscope-intl.aliyuncs.com/api-ws/v1/inference'
prefix = 'testpfx'
target_model = "fun-asr-realtime"

my_vocabulary = [
    {"text": "Speech Lab", "weight": 4}
]

service = VocabularyService()
vocabulary_id = service.create_vocabulary(
      prefix=prefix,
      target_model=target_model,
      vocabulary=my_vocabulary)

if service.query_vocabulary(vocabulary_id)['status'] == 'OK':
    recognition = Recognition(model=target_model,
                          format='wav',
                          sample_rate=16000,
                          callback=None,
                          vocabulary_id=vocabulary_id)
    result = recognition.call('asr_example.wav')
    print(result.output)

service.delete_vocabulary(vocabulary_id)

Java

import com.alibaba.dashscope.audio.asr.recognition.Recognition;
import com.alibaba.dashscope.audio.asr.recognition.RecognitionParam;
import com.alibaba.dashscope.audio.asr.vocabulary.Vocabulary;
import com.alibaba.dashscope.audio.asr.vocabulary.VocabularyService;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.Constants;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class Main {
    // Kunci API untuk wilayah Singapura dan Tiongkok (Beijing) berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
    // Jika Anda belum mengatur variabel lingkungan DASHSCOPE_API_KEY, ganti baris berikut dengan Kunci API Anda: public static String apiKey = "sk-xxx"
    public static String apiKey = System.getenv("DASHSCOPE_API_KEY");

    public static void main(String[] args) throws NoApiKeyException, InputRequiredException {
        // Berikut adalah URL untuk wilayah Singapura. Untuk menggunakan model dari wilayah Tiongkok (Beijing), gunakan https://dashscope.aliyuncs.com/api/v1.
        Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
        // Berikut adalah URL untuk wilayah Singapura. Untuk menggunakan model dari wilayah Tiongkok (Beijing), gunakan wss://dashscope-intl.aliyuncs.com/api-ws/v1/inference.
        Constants.baseWebsocketApiUrl = "wss://dashscope-intl.aliyuncs.com/api-ws/v1/inference";

        String targetModel = "fun-asr-realtime";

        JsonArray vocabularyJson = new JsonArray();
        List<Hotword> wordList = new ArrayList<>();
        wordList.add(new Hotword("Speech Lab", 4));

        for (Hotword word : wordList) {
            JsonObject jsonObject = new JsonObject();
            jsonObject.addProperty("text", word.text);
            jsonObject.addProperty("weight", word.weight);
            vocabularyJson.add(jsonObject);
        }

        VocabularyService service = new VocabularyService(apiKey);
        Vocabulary vocabulary = service.createVocabulary(targetModel, "testpfx", vocabularyJson);

        if ("OK".equals(service.queryVocabulary(vocabulary.getVocabularyId()).getStatus())) {
            Recognition recognizer = new Recognition();
            // Buat RecognitionParam
            RecognitionParam param =
                    RecognitionParam.builder()
                            .model(targetModel)
                            .apiKey(apiKey)
                            .format("wav")
                            .sampleRate(16000)
                            .vocabularyId(vocabulary.getVocabularyId())
                            .build();

            try {
                System.out.println("Hasil pengenalan: " + recognizer.call(param, new File("asr_example.wav")));
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                // Tutup koneksi WebSocket setelah tugas selesai.
                recognizer.getDuplexApi().close(1000, "bye");
            }
        }

        service.deleteVocabulary(vocabulary.getVocabularyId());
        System.exit(0);
    }
}

class Hotword {
    String text;
    int weight;

    public Hotword(String text, int weight) {
        this.text = text;
        this.weight = weight;
    }
}

API

Gunakan akun yang sama untuk semua operasi API.

Buat daftar hotword

Untuk informasi lebih lanjut tentang format JSON daftar hotword, lihat Ikhtisar hotword.

SDK Python

  • API

    Penting

    target_model: Model pengenalan ucapan untuk daftar hotword. Model ini harus sesuai dengan yang ditentukan dalam panggilan API pengenalan ucapan berikutnya.

    def create_vocabulary(self, target_model: str, prefix: str, vocabulary: List[dict]) -> str:
        '''
        Buat daftar hotword.
        param: target_model Model pengenalan ucapan untuk daftar hotword. Model ini harus sesuai dengan yang ditentukan dalam panggilan API berikutnya.
        param: prefix Awalan kustom untuk daftar hotword. Hanya boleh berisi angka dan huruf kecil serta harus kurang dari 10 karakter.
        param: vocabulary Daftar hotword dalam format JSON.
        return: ID daftar hotword.
        '''
  • Contoh kode

    import dashscope
    from dashscope.audio.asr import *
    import os
    
    # Kunci API untuk wilayah Singapura (Internasional) dan Tiongkok (Beijing) berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
    # Jika Anda belum mengonfigurasi variabel lingkungan, ganti baris berikut dengan Kunci API Model Studio Anda: dashscope.api_key = "sk-xxx"
    dashscope.api_key = os.environ.get('DASHSCOPE_API_KEY')
    
    # Berikut adalah URL untuk wilayah Singapura (Internasional). Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope.aliyuncs.com/api/v1
    dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
    
    prefix = 'testpfx'
    target_model = "fun-asr"
    
    my_vocabulary = [
        {"text": "Seediq Bale", "weight": 4}
    ]
    
    # Buat daftar hotword
    service = VocabularyService()
    vocabulary_id = service.create_vocabulary(
        prefix=prefix,
        target_model=target_model,
        vocabulary=my_vocabulary)
    
    print(f"ID daftar hotword: {vocabulary_id}")

SDK Java

  • API

    Penting

    targetModel: Model pengenalan ucapan untuk daftar hotword. Model ini harus sesuai dengan yang ditentukan dalam panggilan API pengenalan ucapan berikutnya.

    /**
     * Membuat daftar hotword baru.
     *
     * @param targetModel Model pengenalan ucapan untuk daftar hotword. Model ini harus sesuai dengan yang ditentukan dalam panggilan API berikutnya.
     * @param prefix Awalan kustom untuk daftar hotword. Hanya boleh berisi angka dan huruf kecil serta harus kurang dari 10 karakter.
     * @param vocabulary Daftar hotword dalam format JSON.
     * @return Objek daftar hotword.
     * @throws NoApiKeyException jika Kunci API kosong.
     * @throws InputRequiredException jika parameter wajib kosong.
     */
    public Vocabulary createVocabulary(String targetModel, String prefix, JsonArray vocabulary)
        throws NoApiKeyException, InputRequiredException 
  • Contoh kode

    import com.alibaba.dashscope.audio.asr.vocabulary.Vocabulary;
    import com.alibaba.dashscope.audio.asr.vocabulary.VocabularyService;
    import com.alibaba.dashscope.exception.InputRequiredException;
    import com.alibaba.dashscope.exception.NoApiKeyException;
    import com.alibaba.dashscope.utils.Constants;
    import com.google.gson.JsonArray;
    import com.google.gson.JsonObject;
    
    import java.util.ArrayList;
    import java.util.List;
    
    public class Main {
        // Kunci API untuk wilayah Singapura (Internasional) dan Tiongkok (Beijing) berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
        // Jika Anda belum mengonfigurasi variabel lingkungan, ganti baris berikut dengan Kunci API Model Studio Anda: public static String apiKey = "sk-xxx"
        public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
    
        public static void main(String[] args) throws NoApiKeyException, InputRequiredException {
            // Berikut adalah URL untuk wilayah Singapura (Internasional). Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope.aliyuncs.com/api/v1
            Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
            String targetModel = "fun-asr";
    
            JsonArray vocabularyJson = new JsonArray();
            List<Hotword> wordList = new ArrayList<>();
            wordList.add(new Hotword("Wu Yigong", 4));
            wordList.add(new Hotword("Confucius' Family", 4));
    
            for (Hotword word : wordList) {
                JsonObject jsonObject = new JsonObject();
                jsonObject.addProperty("text", word.text);
                jsonObject.addProperty("weight", word.weight);
                vocabularyJson.add(jsonObject);
            }
    
            VocabularyService service = new VocabularyService(apiKey);
            Vocabulary vocabulary = service.createVocabulary(targetModel, "testpfx", vocabularyJson);
            System.out.println("ID daftar hotword: " + vocabulary.getVocabularyId());
        }
    }
    
    class Hotword {
        String text;
        int weight;
        String lang;
    
        public Hotword(String text, int weight) {
            this.text = text;
            this.weight = weight;
        }
    }

API RESTful

  • URL

    Tiongkok (Beijing):

    POST https://dashscope.aliyuncs.com/api/v1/services/audio/asr/customization

    Singapura (Internasional):

    POST https://dashscope-intl.aliyuncs.com/api/v1/services/audio/asr/customization
  • Header permintaan

    Parameter

    Tipe

    Wajib

    Deskripsi

    Authorization

    string

    Ya

    Token otentikasi. Formatnya adalah Bearer <your_api_key>. Ganti <your_api_key> dengan Kunci API Anda.

    Content-Type

    string

    Ya

    Tipe media data dalam badan permintaan. Nilainya harus application/json.

  • Body permintaan

    Badan permintaan berikut mencakup semua parameter permintaan. Anda dapat menghilangkan bidang opsional sesuai kebutuhan.

    Penting

    Perhatikan perbedaan antara parameter berikut:

    • model: Model hotword kustom. Tetapkan nilainya ke speech-biasing.

    • target_model: Model pengenalan ucapan untuk daftar hotword. Model ini harus sesuai dengan yang ditentukan dalam panggilan API pengenalan ucapan berikutnya.

    {
        "model": "speech-biasing",
        "input": {
            "action": "create_vocabulary",
            "target_model": "fun-asr",
            "prefix": "testpfx",
            "vocabulary": [
              {"text": "Seediq Bale", "weight": 4, "lang": "zh"}
            ]
        }
    }
  • Parameter permintaan

    Parameter

    Tipe

    Default

    Wajib

    Deskripsi

    model

    string

    -

    Ya

    Model hotword kustom. Nilainya harus speech-biasing.

    action

    string

    -

    Ya

    Tipe operasi. Nilainya harus create_vocabulary.

    target_model

    string

    -

    Ya

    Model pengenalan ucapan untuk daftar hotword. Untuk informasi lebih lanjut, lihat Model yang didukung.

    Model ini harus sesuai dengan yang ditentukan dalam panggilan API berikutnya.

    prefix

    string

    -

    Ya

    Nama yang mudah dikenali untuk daftar hotword. Hanya boleh berisi angka dan huruf kecil serta harus kurang dari 10 karakter.

    Awal ini disertakan dalam ID daftar hotword. Misalnya, jika awalannya adalah "testpfx", ID daftar hotword yang dihasilkan adalah "vocab-testpfx-51773d05xxxxxx".

    vocabulary

    array[object]

    -

    Ya

    Daftar hotword dalam format JSON. Untuk informasi lebih lanjut, lihat Ikhtisar hotword.

  • Parameter respons

    Contoh respons

    {
        "output": {
            "vocabulary_id": "vocab-testpfx-5112c3de3705486baxxxxxxx"
        },
        "usage": {
            "count": 1
        },
        "request_id": "aee47022-2352-40fe-acfa-xxxx"
    }

    Tabel berikut menjelaskan parameter respons utama.

    Parameter

    Tipe

    Deskripsi

    vocabulary_id

    string

    ID daftar hotword.

  • Contoh kode

    Berikut adalah contoh cURL. Untuk contoh Java dan Python, lihat SDK yang sesuai.

    Jika Anda belum mengonfigurasi Kunci API sebagai variabel lingkungan, ganti $DASHSCOPE_API_KEY dengan Kunci API Anda.

    https://dashscope-intl.aliyuncs.com/api/v1/services/audio/asr/customization# ======= Penting =======
    # Berikut adalah URL untuk wilayah Singapura (Internasional). Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope.aliyuncs.com/api/v1/services/audio/asr/customization
    # Kunci API untuk wilayah Singapura (Internasional) dan Tiongkok (Beijing) berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
    # === Hapus komentar ini sebelum eksekusi ===
    
    curl -X POST <a data-init-id="9f104f338c7kz" href="https://poc-dashscope.aliyuncs.com/api/v1/services/audio/tts/customization" id="35ebbc67890ds">https://dashscope-intl.aliyuncs.com/api/v1/services/audio/asr/customization</a> \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
        "model": "speech-biasing",
        "input": {
            "action": "create_vocabulary",
            "target_model": "fun-asr",
            "prefix": "testpfx",
            "vocabulary": [
              {"text": "Seediq Bale", "weight": 4}
            ]
        }
    }'

Dapatkan semua daftar hotword

SDK Python

  • API

    def list_vocabularies(self, prefix=None, page_index: int = 0, page_size: int = 10) -> List[dict]:
        '''
        Menampilkan semua daftar hotword yang telah dibuat.
        param: prefix Awalan untuk filter. Jika ditentukan, operasi ini hanya mengembalikan daftar hotword yang sesuai dengan awalan ini.
        param: page_index Indeks halaman.
        param: page_size Jumlah entri per halaman.
        return: Daftar dictionary, masing-masing merepresentasikan satu daftar hotword.
        '''
  • Contoh kode

    import dashscope
    from dashscope.audio.asr import *
    import json
    import os
    
    # Kunci API untuk wilayah Singapura dan Tiongkok (Beijing) berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
    # Jika Anda belum mengatur variabel lingkungan, ganti baris berikut dengan Kunci API Model Studio Anda: dashscope.api_key = "sk-xxx"
    dashscope.api_key = os.environ.get('DASHSCOPE_API_KEY')
    
    # Berikut adalah URL untuk wilayah Singapura. Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope-intl.aliyuncs.com/api/v1
    dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
    
    service = VocabularyService()
    vocabularies = service.list_vocabularies()
    print(f"Daftar hotword: {json.dumps(vocabularies)}")
  • Parameter respons

    Klik untuk melihat contoh respons

    [
      {
        "gmt_create": "2025-04-22 14:23:35",
        "vocabulary_id": "vocab-testpfx-5112c3de3705486baxxxxxxx",
        "gmt_modified": "2025-04-22 14:23:35",
        "status": "OK"
      }
    ]

    Tabel berikut menjelaskan parameter respons utama.

    Parameter

    Tipe

    Deskripsi

    vocabulary_id

    string

    ID daftar hotword.

    gmt_create

    string

    Waktu pembuatan daftar hotword.

    gmt_modified

    string

    Waktu modifikasi terakhir daftar hotword.

    status

    string

    Status daftar hotword. Nilai yang valid:

    • OK: Daftar hotword siap digunakan.

    • UNDEPLOYED: Daftar hotword belum dideploy dan tidak dapat digunakan.

SDK Java

  • API

    /**
     * Menampilkan semua daftar hotword yang telah dibuat. Indeks halaman default adalah 0 dan ukuran halaman default adalah 10.
     *
     * @param prefix Awalan untuk memfilter daftar hotword.
     * @return Array objek <code>Vocabulary
    Vocabulary
  • Contoh kode

    import com.alibaba.dashscope.audio.asr.vocabulary.Vocabulary;
    import com.alibaba.dashscope.audio.asr.vocabulary.VocabularyService;
    import com.alibaba.dashscope.exception.InputRequiredException;
    import com.alibaba.dashscope.exception.NoApiKeyException;
    import com.alibaba.dashscope.utils.Constants;
    import com.google.gson.Gson;
    import com.google.gson.GsonBuilder;
    
    public class Main {
        // Kunci API untuk wilayah Singapura dan Tiongkok (Beijing) berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
        // Jika Anda belum mengatur variabel lingkungan, ganti baris berikut dengan Kunci API Model Studio Anda: public static String apiKey = "sk-xxx"
        public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
    
        public static void main(String[] args) throws NoApiKeyException, InputRequiredException {
            // Berikut adalah URL untuk wilayah Singapura. Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope-intl.aliyuncs.com/api/v1
            Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
    
            VocabularyService service = new VocabularyService(apiKey);
            Vocabulary[] vocabularies = service.listVocabulary("testpfx");
            Gson gson = new GsonBuilder()
                    .setPrettyPrinting()
                    .create();
            System.out.println("Daftar hotword: " + gson.toJson(vocabularies));
        }
    }
  • Klik untuk melihat contoh respons

    [
      {
        "gmt_create": "2025-04-22 14:23:35",
        "vocabulary_id": "vocab-testpfx-5112c3de3705486baxxxxxxx",
        "gmt_modified": "2025-04-22 14:23:35",
        "status": "OK"
      }
    ]

    Tabel berikut menjelaskan parameter respons utama.

    Parameter

    Tipe

    Deskripsi

    vocabulary_id

    string

    ID daftar hotword.

    gmt_create

    string

    Waktu pembuatan daftar hotword.

    gmt_modified

    string

    Waktu modifikasi terakhir daftar hotword.

    status

    string

    Status daftar hotword. Nilai yang valid:

    • OK: Daftar hotword siap digunakan.

    • UNDEPLOYED: Daftar hotword belum dideploy dan tidak dapat digunakan.

API RESTful

  • URL

    Tiongkok (Beijing):

    POST https://dashscope.aliyuncs.com/api/v1/services/audio/asr/customization

    Singapura (Internasional):

    POST https://dashscope-intl.aliyuncs.com/api/v1/services/audio/asr/customization
  • Header permintaan

    Parameter

    Tipe

    Wajib

    Deskripsi

    Authorization

    string

    Ya

    Token otentikasi. Formatnya adalah Bearer <your_api_key>. Ganti <your_api_key> dengan Kunci API Anda.

    Content-Type

    string

    Ya

    Tipe media data dalam badan permintaan. Nilainya harus application/json.

  • Body permintaan

    Contoh berikut menunjukkan badan permintaan dengan semua parameter yang tersedia. Anda dapat menghilangkan bidang opsional.

    Penting

    model: Model hotword kustom. Tetapkan ini ke speech-biasing.

    {
        "model": "speech-biasing",
        "input": {
            "action": "list_vocabulary",
            "prefix": "testpfx",
            "page_index": 0,
            "page_size": 10
        }
    }
  • Parameter permintaan

    Parameter

    Tipe

    Default

    Wajib

    Deskripsi

    model

    string

    -

    Ya

    Model hotword kustom. Nilainya harus speech-biasing.

    action

    string

    -

    Ya

    Tipe operasi. Tetapkan ini ke list_vocabulary.

    prefix

    string

    -

    Tidak

    Awalan kustom untuk daftar hotword. Harus kurang dari 10 karakter dan hanya berisi huruf kecil serta angka.

    page_index

    integer

    0

    Tidak

    Indeks halaman berbasis nol.

    page_size

    integer

    10

    Tidak

    Jumlah entri per halaman.

  • Parameter respons

    Klik untuk melihat contoh respons

    {
      "output": {
        "vocabulary_list": [
          {
            "gmt_create": "2025-12-19 11:47:11",
            "gmt_modified": "2025-12-19 11:47:11",
            "status": "OK",
            "vocabulary_id": "vocab-testpfx-xxxxxxxx"
          }
        ]
      },
      "usage": {
        "count": 1
      },
      "request_id": "10e8cde2-b711-4609-b19b-xxxxxx"
    }

    Tabel berikut menjelaskan parameter respons utama.

    Parameter

    Tipe

    Deskripsi

    vocabulary_id

    string

    ID daftar hotword.

    gmt_create

    string

    Waktu pembuatan daftar hotword.

    gmt_modified

    string

    Waktu modifikasi terakhir daftar hotword.

    status

    string

    Status daftar hotword. Nilai yang valid:

    • OK: Daftar hotword siap digunakan.

    • UNDEPLOYED: Daftar hotword belum dideploy dan tidak dapat digunakan.

  • Contoh kode

    Berikut adalah contoh cURL. Untuk contoh Java dan Python, lihat bagian SDK yang sesuai.

    Jika Anda belum mengatur variabel lingkungan $DASHSCOPE_API_KEY, gantilah dengan Kunci API Anda.

    # ======= Penting =======
    # Berikut adalah URL untuk wilayah Singapura. Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope.aliyuncs.com/api/v1/services/audio/asr/customization
    # Kunci API untuk wilayah Singapura dan Tiongkok (Beijing) berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
    # === Hapus komentar ini sebelum eksekusi ===
    
    curl -X POST https://dashscope-intl.aliyuncs.com/api/v1/services/audio/asr/customization \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
        "model": "speech-biasing",
        "input": {
            "action": "list_vocabulary",
            "prefix": "testpfx",
            "page_index": 0,
            "page_size": 10
        }
    }'

Kueri daftar hotword

Respons terhadap kueri daftar hotword tertentu tidak menyertakan ID daftar hotword karena Anda telah memberikan ID tersebut dalam permintaan.

SDK Python

  • Deskripsi API

    def query_vocabulary(self, vocabulary_id: str) -> List[dict]:
        '''
        Mengambil konten daftar hotword.
        param: vocabulary_id ID daftar hotword.
        return: Dictionary yang berisi daftar hotword.
        '''
  • Contoh kode

    import dashscope
    from dashscope.audio.asr import *
    import json
    import os
    
    # Kunci API untuk wilayah Tiongkok (Beijing) dan Singapura berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
    # Jika Anda belum mengonfigurasi variabel lingkungan, ganti baris berikut dengan Kunci API Model Studio Anda: dashscope.api_key = "sk-xxx"
    dashscope.api_key = os.environ.get('DASHSCOPE_API_KEY')
    
    # URL berikut untuk wilayah Singapura. Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope.aliyuncs.com/api/v1
    dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
    
    service = VocabularyService()
    # Saat melakukan kueri, ganti placeholder dengan ID daftar hotword aktual Anda.
    vocabulary = service.query_vocabulary("vocab-testpfx-xxx")
    print(f"Daftar hotword: {json.dumps(vocabulary, ensure_ascii=False)}")
  • Parameter respons

    Contoh respons

    {
      "gmt_create": "2025-12-19 11:47:11",
      "gmt_modified": "2025-12-19 11:47:11",
      "status": "OK",
      "target_model": "fun-asr",
      "vocabulary": [
        {
          "lang": "zh",
          "text": "Seediq Bale",
          "weight": 4
        }
      ]
    }

    Tabel berikut menjelaskan parameter respons utama.

    Parameter

    Type

    Deskripsi

    vocabulary

    object[]

    Array objek yang mendefinisikan hotword. Untuk detail bidangnya, lihat Ikhtisar hotword.

    gmt_create

    string

    Waktu pembuatan daftar hotword.

    gmt_modified

    string

    Waktu modifikasi terakhir daftar hotword.

    target_model

    string

    Model pengenalan ucapan untuk daftar hotword. Untuk informasi lebih lanjut, lihat Model yang didukung.

    Model ini harus sesuai dengan yang ditentukan dalam panggilan API berikutnya.

    status

    string

    Status daftar hotword:

    • OK: Daftar tersedia untuk digunakan.

    • UNDEPLOYED: Daftar belum dideploy dan tidak dapat digunakan.

SDK Java

  • Deskripsi API

    /**
     * Mengambil detail daftar hotword tertentu.
     *
     * @param vocabularyId ID daftar hotword yang akan diambil.
     * @return Objek Vocabulary yang merepresentasikan daftar hotword yang ditentukan.
     * @throws NoApiKeyException jika Kunci API tidak disediakan.
     * @throws InputRequiredException jika parameter wajib hilang.
     */
    public Vocabulary queryVocabulary(String vocabularyId)
        throws NoApiKeyException, InputRequiredException
  • Contoh kode

    import com.alibaba.dashscope.audio.asr.vocabulary.Vocabulary;
    import com.alibaba.dashscope.audio.asr.vocabulary.VocabularyService;
    import com.alibaba.dashscope.exception.InputRequiredException;
    import com.alibaba.dashscope.exception.NoApiKeyException;
    import com.alibaba.dashscope.utils.Constants;
    import com.google.gson.Gson;
    import com.google.gson.GsonBuilder;
    
    public class Main {
        // Kunci API untuk wilayah Tiongkok (Beijing) dan Singapura berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
        // Jika Anda belum mengonfigurasi variabel lingkungan, ganti baris berikut dengan Kunci API Model Studio Anda: public static String apiKey = "sk-xxx"
        public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
    
        public static void main(String[] args) throws NoApiKeyException, InputRequiredException {
            // URL berikut untuk wilayah Singapura. Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope.aliyuncs.com/api/v1
            Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
    
            VocabularyService service = new VocabularyService(apiKey);
            // Saat melakukan kueri, ganti placeholder dengan ID daftar hotword aktual Anda.
            Vocabulary vocabulary = service.queryVocabulary("vocab-testpfx-xxxx");
            Gson gson = new GsonBuilder()
                    .setPrettyPrinting()
                    .create();
            System.out.println("Daftar hotword: " + gson.toJson(vocabulary.getData()));
        }
    }
  • Parameter respons

    Contoh respons

    {
      "gmt_create": "2025-12-19 11:47:11",
      "gmt_modified": "2025-12-19 11:47:11",
      "status": "OK",
      "target_model": "fun-asr",
      "vocabulary": [
        {
          "lang": "zh",
          "text": "Seediq Bale",
          "weight": 4
        }
      ]
    }

    Tabel berikut menjelaskan parameter respons utama.

    Parameter

    Tipe

    Deskripsi

    vocabulary

    object[]

    Array objek yang mendefinisikan hotword. Untuk detail bidangnya, lihat Ikhtisar hotword.

    gmt_create

    string

    Waktu pembuatan daftar hotword.

    gmt_modified

    string

    Waktu modifikasi terakhir daftar hotword.

    target_model

    string

    Model pengenalan ucapan untuk daftar hotword. Untuk informasi lebih lanjut, lihat Model yang didukung.

    Model ini harus sesuai dengan yang ditentukan dalam panggilan API berikutnya.

    status

    string

    Status daftar hotword:

    • OK: Daftar tersedia untuk digunakan.

    • UNDEPLOYED: Daftar belum dideploy dan tidak dapat digunakan.

API RESTful

  • URL

    Tiongkok (Beijing):

    POST https://dashscope.aliyuncs.com/api/v1/services/audio/asr/customization

    Singapura (Internasional):

    POST https://dashscope-intl.aliyuncs.com/api/v1/services/audio/asr/customization
  • Header permintaan

    Parameter

    Tipe

    Wajib

    Deskripsi

    Authorization

    string

    Ya

    Token otentikasi. Formatnya adalah Bearer <your_api_key>. Ganti <your_api_key> dengan Kunci API Anda.

    Content-Type

    string

    Ya

    Tipe media data dalam badan permintaan. Nilainya harus application/json.

  • Request body

    Badan permintaan berikut mencakup semua parameter permintaan. Anda dapat menghilangkan bidang opsional sesuai kebutuhan.

    Penting

    model: Model hotword kustom. Tetapkan parameter ini ke speech-biasing.

    {
        "model": "speech-biasing",
        "input": {
            "action": "query_vocabulary",
            "vocabulary_id": "vocab-testpfx-xxxx"
        }
    }
  • Parameter permintaan

    Parameter

    Tipe

    Default

    Wajib

    Deskripsi

    model

    string

    -

    Ya

    Model hotword kustom. Nilainya harus speech-biasing.

    action

    string

    -

    Ya

    Operasi yang akan dilakukan. Tetapkan ini ke query_vocabulary.

    vocabulary_id

    string

    -

    Ya

    ID daftar hotword yang akan dikueri.

  • Parameter respons

    Contoh respons

    {
      "output": {
        "gmt_create": "2025-12-19 11:47:11",
        "gmt_modified": "2025-12-19 11:47:11",
        "status": "OK",
        "target_model": "fun-asr",
        "vocabulary": [
          {
            "lang": "zh",
            "text": "Seediq Bale",
            "weight": 4
          }
        ]
      },
      "usage": {
        "count": 1
      },
      "request_id": "3d461d3f-b2c4-4de5-xxxx"
    }

    Tabel berikut menjelaskan parameter respons utama.

    Parameter

    Tipe

    Deskripsi

    vocabulary

    object[]

    Array objek yang mendefinisikan hotword. Untuk detail bidangnya, lihat Ikhtisar hotword.

    gmt_create

    string

    Waktu pembuatan daftar hotword.

    gmt_modified

    string

    Waktu modifikasi terakhir daftar hotword.

    target_model

    string

    Model pengenalan ucapan untuk daftar hotword. Untuk informasi lebih lanjut, lihat Model yang didukung.

    Model ini harus sesuai dengan yang ditentukan dalam panggilan API berikutnya.

    status

    string

    Status daftar hotword:

    • OK: Daftar tersedia untuk digunakan.

    • UNDEPLOYED: Daftar belum dideploy dan tidak dapat digunakan.

  • Contoh kode

    Berikut adalah contoh cURL. Untuk contoh Java dan Python, lihat SDK yang sesuai.

    Jika Anda belum mengatur Kunci API sebagai variabel lingkungan, ganti $DASHSCOPE_API_KEY dengan Kunci API aktual Anda.

    # ======= Penting =======
    # URL berikut untuk wilayah Singapura. Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope.aliyuncs.com/api/v1/services/audio/asr/customization
    # Kunci API untuk wilayah Tiongkok (Beijing) dan Singapura berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
    # === Hapus komentar ini sebelum eksekusi ===
    
    curl -X POST https://dashscope-intl.aliyuncs.com/api/v1/services/audio/asr/customization \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
        "model": "speech-biasing",
        "input": {
            "action": "query_vocabulary",
            "vocabulary_id": "vocab-testpfx-xxxx"
        }
    }'

Perbarui daftar hotword

SDK Python

  • Deskripsi API

    def update_vocabulary(self, vocabulary_id: str, vocabulary: List[dict]) -> None:
        '''
        Mengganti daftar hotword yang ada dengan yang baru.
        param: vocabulary_id ID daftar hotword yang akan diganti.
        param: vocabulary Daftar hotword baru.
        '''
  • Contoh kode

    import dashscope
    from dashscope.audio.asr import *
    import os
    
    # Kunci API untuk wilayah Singapura dan Tiongkok (Beijing) berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
    # Jika Anda tidak menggunakan variabel lingkungan, ganti baris berikut dengan Kunci API Model Studio Anda: dashscope.api_key = "sk-xxx"
    dashscope.api_key = os.environ.get('DASHSCOPE_API_KEY')
    
    # URL berikut untuk wilayah Singapura. Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope.aliyuncs.com/api/v1
    dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
    
    service = VocabularyService()
    my_vocabulary = [
        {"text": "Seediq Bale", "weight": 4, "lang": "zh"}
    ]
    # Ganti dengan ID daftar hotword aktual Anda.
    service.update_vocabulary("vocab-testpfx-xxx", my_vocabulary)

SDK Java

  • Deskripsi API

    /**
     * Memperbarui daftar hotword. Operasi ini menimpa seluruh daftar.
     *
     * @param vocabularyId ID daftar hotword yang akan diperbarui.
     * @param vocabulary JsonArray yang berisi daftar hotword baru.
     * @throws NoApiKeyException jika Kunci API tidak disediakan.
     * @throws InputRequiredException jika parameter wajib hilang.
     */
    public void updateVocabulary(String vocabularyId, JsonArray vocabulary)
        throws NoApiKeyException, InputRequiredException
  • Contoh kode

    import com.alibaba.dashscope.audio.asr.vocabulary.VocabularyService;
    import com.alibaba.dashscope.exception.InputRequiredException;
    import com.alibaba.dashscope.exception.NoApiKeyException;
    import com.alibaba.dashscope.utils.Constants;
    import com.google.gson.JsonArray;
    import com.google.gson.JsonObject;
    
    import java.util.ArrayList;
    import java.util.List;
    
    public class Main {
        // Kunci API untuk wilayah Singapura dan Tiongkok (Beijing) berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
        // Jika Anda tidak menggunakan variabel lingkungan, ganti baris berikut dengan Kunci API Model Studio Anda: public static String apiKey = "sk-xxx"
        public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
    
        public static void main(String[] args) throws NoApiKeyException, InputRequiredException {
            // URL berikut untuk wilayah Singapura. Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope.aliyuncs.com/api/v1
            Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
    
            JsonArray vocabularyJson = new JsonArray();
            List<Hotword> wordList = new ArrayList<>();
            wordList.add(new Hotword("Wu Yigong", 4, "zh"));
            wordList.add(new Hotword("Queli Renjia", 4, "zh"));
    
            for (Hotword word : wordList) {
                JsonObject jsonObject = new JsonObject();
                jsonObject.addProperty("text", word.text);
                jsonObject.addProperty("weight", word.weight);
                jsonObject.addProperty("lang", word.lang);
                vocabularyJson.add(jsonObject);
            }
    
            VocabularyService service = new VocabularyService(apiKey);
            // Ganti dengan ID daftar hotword aktual Anda.
            service.updateVocabulary("vocab-testpfx-xxx", vocabularyJson);
        }
    }
    
    class Hotword {
        String text;
        int weight;
        String lang;
    
        public Hotword(String text, int weight, String lang) {
            this.text = text;
            this.weight = weight;
            this.lang = lang;
        }
    }

API RESTful

  • URL

    Tiongkok (Beijing):

    POST https://dashscope.aliyuncs.com/api/v1/services/audio/asr/customization

    Singapura (Internasional):

    POST https://dashscope-intl.aliyuncs.com/api/v1/services/audio/asr/customization
  • Header permintaan

    Parameter

    Tipe

    Wajib

    Deskripsi

    Authorization

    string

    Ya

    Token otentikasi. Formatnya adalah Bearer <your_api_key>. Ganti <your_api_key> dengan Kunci API Anda.

    Content-Type

    string

    Ya

    Tipe media data dalam badan permintaan. Nilainya harus application/json.

  • Body permintaan

    Badan permintaan berisi semua parameter permintaan. Anda dapat menghilangkan bidang opsional sesuai kebutuhan.

    Penting

    model: Model hotword kustom. Nilainya harus speech-biasing.

    {
        "model": "speech-biasing",
        "input": {
            "action": "update_vocabulary",
            "vocabulary_id": "vocab-testpfx-xxx",
            "vocabulary": [
              {"text": "Seediq Bale", "weight": 4, "lang": "zh"}
            ]
        }
    }
  • Parameter permintaan

    Parameter

    Tipe

    Default

    Wajib

    Deskripsi

    model

    string

    -

    Ya

    Model hotword kustom. Nilainya harus speech-biasing.

    action

    string

    -

    Ya

    Tipe operasi. Nilainya harus update_vocabulary.

    vocabulary_id

    string

    -

    Ya

    ID daftar hotword yang akan diperbarui.

    vocabulary

    object[]

    -

    Ya

    Daftar hotword yang diperbarui sebagai array objek. Untuk detail bidangnya, lihat Ikhtisar hotword.

  • Parameter respons

    Contoh respons

    {
      "output": {},
      "usage": {
        "count": 1
      },
      "request_id": "aee47022-2352-40fe-acfa-xxxx"
    }
  • Contoh kode

    Contoh berikut menggunakan cURL. Untuk contoh Java dan Python, lihat bagian SDK yang sesuai.

    Jika variabel lingkungan $DASHSCOPE_API_KEY belum diatur, gantilah dengan Kunci API aktual Anda.

    # ======= Penting =======
    # URL berikut untuk wilayah Singapura. Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope.aliyuncs.com/api/v1/services/audio/asr/customization
    # Kunci API untuk wilayah Singapura dan Tiongkok (Beijing) berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
    # === Hapus komentar ini sebelum eksekusi ===
    
    curl -X POST https://dashscope-intl.aliyuncs.com/api/v1/services/audio/asr/customization \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
        "model": "speech-biasing",
        "input": {
            "action": "update_vocabulary",
            "vocabulary_id": "vocab-testpfx-xxx",
            "vocabulary": [
              {"text": "Seediq Bale", "weight": 4, "lang": "zh"}
            ]
        }
    }'

Hapus daftar hotword

SDK Python

  • API

    def delete_vocabulary(self, vocabulary_id: str) -> None:
        '''
        Menghapus daftar hotword.
        @param vocabulary_id: ID daftar hotword yang akan dihapus.
        '''
  • Contoh kode

    import dashscope
    from dashscope.audio.asr import *
    import os
    
    # Kunci API untuk wilayah Singapura dan Tiongkok (Beijing) berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
    # Jika variabel lingkungan tidak dikonfigurasi, ganti baris berikut dengan Kunci API Model Studio Anda: dashscope.api_key = "sk-xxx"
    dashscope.api_key = os.environ.get('DASHSCOPE_API_KEY')
    
    # Berikut adalah URL untuk wilayah Singapura. Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope.aliyuncs.com/api/v1
    dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
    
    service = VocabularyService()
    # Ganti dengan ID daftar hotword aktual.
    service.delete_vocabulary("vocab-testpfx-xxxx")

SDK Java

  • API

    /**
     * Menghapus daftar hotword.
     *
     * @param vocabularyId ID daftar hotword yang akan dihapus.
     * @throws NoApiKeyException jika Kunci API kosong.
     * @throws InputRequiredException jika parameter wajib kosong.
     */
    public void deleteVocabulary(String vocabularyId)
        throws NoApiKeyException, InputRequiredException
  • Contoh kode

    import com.alibaba.dashscope.audio.asr.vocabulary.VocabularyService;
    import com.alibaba.dashscope.exception.InputRequiredException;
    import com.alibaba.dashscope.exception.NoApiKeyException;
    import com.alibaba.dashscope.utils.Constants;
    
    public class Main {
        // Kunci API untuk wilayah Singapura dan Tiongkok (Beijing) berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
        // Jika variabel lingkungan tidak dikonfigurasi, ganti baris berikut dengan Kunci API Model Studio Anda: public static String apiKey = "sk-xxx"
        public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
    
        public static void main(String[] args) throws NoApiKeyException, InputRequiredException {
            // Berikut adalah URL untuk wilayah Singapura. Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope-intl.aliyuncs.com/api/v1
            Constants.baseHttpApiUrl = "https://dashscope-intl.aliyuncs.com/api/v1";
    
            VocabularyService service = new VocabularyService(apiKey);
            // Ganti dengan ID daftar hotword aktual.
            service.deleteVocabulary("vocab-testpfx-xxxx");
        }
    }

API RESTful

  • URL

    Tiongkok (Beijing):

    POST https://dashscope.aliyuncs.com/api/v1/services/audio/asr/customization

    Singapura (Internasional):

    POST https://dashscope-intl.aliyuncs.com/api/v1/services/audio/asr/customization
  • Header permintaan

    Parameter

    Tipe

    Wajib

    Deskripsi

    Authorization

    string

    Ya

    Token otentikasi. Formatnya adalah Bearer <your_api_key>. Ganti <your_api_key> dengan Kunci API Anda.

    Content-Type

    string

    Ya

    Tipe media data dalam badan permintaan. Nilainya harus application/json.

  • Request body

    Badan permintaan mencakup parameter permintaan. Anda dapat menghilangkan bidang opsional.

    Penting

    model: Model hotword kustom yang digunakan. Ini harus diatur ke speech-biasing.

    {
        "model": "speech-biasing",
        "input": {
            "action": "delete_vocabulary",
            "vocabulary_id": "vocab-testpfx-xxx"
        }
    }
  • Parameter permintaan

    Parameter

    Jenis

    Default

    Wajib

    Deskripsi

    model

    string

    -

    Ya

    Model hotword kustom. Nilainya harus speech-biasing.

    action

    string

    -

    Ya

    Operasi yang akan dilakukan. Ini harus diatur ke delete_vocabulary.

    vocabulary_id

    string

    -

    Ya

    ID daftar hotword yang akan dihapus.

  • Parameter respons

    Contoh respons

    {
      "output": {},
      "usage": {
        "count": 1
      },
      "request_id": "aee47022-2352-40fe-acfa-xxxx"
    }
  • Contoh kode

    Berikut adalah contoh cURL. Untuk contoh Java dan Python, lihat bagian SDK di atas.

    Jika Anda tidak menggunakan variabel lingkungan, ganti $DASHSCOPE_API_KEY dengan Kunci API aktual Anda.

    # ======= Penting =======
    # Berikut adalah URL untuk wilayah Singapura. Jika Anda menggunakan model di wilayah Tiongkok (Beijing), ganti URL dengan: https://dashscope.aliyuncs.com/api/v1/services/audio/asr/customization
    # Kunci API untuk wilayah Singapura dan Tiongkok (Beijing) berbeda. Untuk mendapatkan Kunci API, lihat https://www.alibabacloud.com/help/en/model-studio/get-api-key
    # === Hapus komentar ini sebelum eksekusi ===
    
    curl -X POST https://dashscope-intl.aliyuncs.com/api/v1/services/audio/asr/customization \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
        "model": "speech-biasing",
        "input": {
            "action": "delete_vocabulary",
            "vocabulary_id": "vocab-testpfx-xxx"
        }
    }'

Kode error

Jika Anda mengalami error, lihat Pesan error.