Options
All
  • Public
  • Public/Protected
  • All
Menu

The client of voice translator.

Index

Functions

  • getCurrentListeningLanguage(): Language | null
  • Get current listening language.

    const vtClient = zmClient.getVoiceTranslatorClient();
    const language = vtClient.getCurrentListeningLanguage();
    if (language) {
    console.log(`Listening: ${language.name} (${language.code})`);
    }

    Returns Language | null

    Current listening language or null if not set.

  • getCurrentSpeakingLanguage(): Language | null
  • Get the current speaking language.

    const vtClient = zmClient.getVoiceTranslatorClient();
    const language = vtClient.getCurrentSpeakingLanguage();
    if (language) {
    console.log(`Speaking: ${language.name} (${language.code})`);
    }

    Returns Language | null

    Current speaking language or null if not set.

  • Get current voice timbre.

    const vtClient = zmClient.getVoiceTranslatorClient();
    const timbre = vtClient.getCurrentTimbre();
    if (timbre) {
    console.log(`Current voice: ${timbre.name}`);
    console.log(`Sample URL: ${timbre.voiceUrl}`);
    }

    Returns VoiceTimbre | null

    Current voice timbre configuration or null if not set.

  • getOriginalAudioBalance(): number | null
  • Get original audio balance.

    Returns number | null

  • Get voice translator status.

    const vtClient = zmClient.getVoiceTranslatorClient();
    const status = vtClient.getVoiceTranslatorStatus();
    console.log('Is enabled:', status.isVoiceTranslatorEnabled);
    console.log('Is running:', status.isVoiceTranslatorOn);
    console.log('Supported languages:', status.voiceTranslatorLanguage);

    Returns VoiceTranslatorStatus

    Voice translator status information.

  • Set listening language (the language you want to hear).

    Note:

    • Voice translator must be started before calling this function.
    • Check the voiceTranslatorLanguage from getVoiceTranslatorStatus to verify the language is supported.
    const vtClient = zmClient.getVoiceTranslatorClient();
    vtClient.setListeningLanguage('zh'); // Set listening language to Chinese
    throws

    {ExceptionCode.VOICE_TRANSLATOR_MISMATCH_STATE} - Voice translator must be started before performing this action

    throws

    {ExceptionCode.VOICE_TRANSLATOR_LANGUAGE_UNSUPPORTED} - The specified listening language is not supported

    Parameters

    • language: string

      The target language code to translate audio into (e.g., 'en', 'zh', 'ja').

    Returns ExecutedResult

  • Set original audio balance.

    Controls the volume balance between original audio and translated audio.

    • 0: Only translated audio.
    • 0.5: Equal mix of original and translated audio.
    • 1: Only original audio.

    Note:

    • Voice translator must be started before calling this function.
    const vtClient = zmClient.getVoiceTranslatorClient();
    vtClient.setOriginalAudioBalance(0.3); // Mostly translated audio with some original
    throws

    {ExceptionCode.VOICE_TRANSLATOR_MISMATCH_STATE} - Voice translator must be started before performing this action.

    throws

    {ExceptionCode.VOICE_TRANSLATOR_INCORRECT_BALANCE_RANGE} - The balance value must be between 0 and 1.

    Parameters

    • balance: number

      Balance value between 0 and 1 (inclusive).

    Returns ExecutedResult

  • Set speaking language (the language you are speaking).

    Note:

    • Check the voiceTranslatorLanguage from getVoiceTranslatorStatus to verify the language is supported.
    const vtClient = zmClient.getVoiceTranslatorClient();
    vtClient.setSpeakingLanguage('en'); // Set speaking language to English
    throws

    {ExceptionCode.VOICE_TRANSLATOR_ACCOUNT_DISABLE} - Voice translator is not enabled for this account

    throws

    {ExceptionCode.VOICE_TRANSLATOR_NO_AVAILABLE_LANGUAGE_LIST} - Voice translator language list is not available

    throws

    {ExceptionCode.VOICE_TRANSLATOR_LANGUAGE_UNSUPPORTED} - The specified speaking language is not supported

    Parameters

    • language: string

      The speaking language code (e.g., 'en', 'zh', 'ja').

    Returns ExecutedResult

  • Set translated voice style (timbre).

    Note:

    • Voice translator must be started before calling this function.
    • Check the voiceTranslatorVoiceTimberList from getVoiceTranslatorStatus to get available timbre IDs.
    const vtClient = zmClient.getVoiceTranslatorClient();
    const status = vtClient.getVoiceTranslatorStatus();
    const timbreId = status.voiceTranslatorVoiceTimberList[0].timbreIndex;
    vtClient.setTranslatedVoiceStyle(timbreId);
    throws

    {ExceptionCode.VOICE_TRANSLATOR_MISMATCH_STATE} - Voice translator must be started before performing this action.

    throws

    {ExceptionCode.VOICE_TRANSLATOR_INCORRECT_TIMBRE} - The specified voice timbre ID is invalid or not found.

    Parameters

    • timbreId: number

      The timbre index ID from the available voice timbre list.

    Returns ExecutedResult

  • Start voice translator.

    zmClient.on('voice-translator-started',(payload)=>{
    console.log('Voice translator started receiving audio')
    });

    const vtClient = zmClient.getVoiceTranslatorClient();
    vtClient.startVoiceTranslator();
    throws

    {ExceptionCode.VOICE_TRANSLATOR_ACCOUNT_DISABLE} - Voice translator is not enabled for this account

    throws

    {ExceptionCode.VOICE_TRANSLATOR_NO_AVAILABLE_LANGUAGE_LIST} - Voice translator language list is not available

    Returns ExecutedResult

  • Stop voice translator.

    const vtClient = zmClient.getVoiceTranslatorClient();
    vtClient.stopVoiceTranslator();

    Returns ExecutedResult