CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-tencentcloud-sdk-python-tmt

Tencent Cloud Machine Translation (TMT) SDK for Python providing comprehensive text, file, image, and speech translation capabilities

Overview
Eval results
Files

Tencent Cloud Machine Translation SDK

A comprehensive Python SDK for Tencent Cloud's Machine Translation (TMT) service, providing enterprise-grade translation capabilities across text, files, images, and speech. The SDK supports multiple language pairs, various content formats, and both synchronous and asynchronous translation workflows.

Package Information

  • Package Name: tencentcloud-sdk-python-tmt
  • Language: Python
  • Installation: pip install tencentcloud-sdk-python

Core Imports

from tencentcloud.tmt.v20180321.tmt_client import TmtClient
from tencentcloud.tmt.v20180321 import models

Common credential and configuration imports:

from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile

Basic Usage

from tencentcloud.common import credential
from tencentcloud.tmt.v20180321.tmt_client import TmtClient
from tencentcloud.tmt.v20180321 import models

# Initialize credentials and client
cred = credential.Credential("SecretId", "SecretKey")
client = TmtClient(cred, "ap-beijing")

# Basic text translation
req = models.TextTranslateRequest()
req.SourceText = "Hello, world!"
req.Source = "en"
req.Target = "zh"

resp = client.TextTranslate(req)
print(resp.TargetText)  # 你好,世界!

Architecture

The TMT SDK follows Tencent Cloud's standard architecture pattern:

  • TmtClient: Main service client handling API calls and authentication
  • Request Models: Strongly-typed parameter objects for each API operation
  • Response Models: Structured response objects with result data and metadata
  • Error Handling: Comprehensive error codes and exception handling via TencentCloudSDKException

The SDK supports multiple translation modes (synchronous/asynchronous), extensive language combinations, and various content types through a unified client interface.

Capabilities

Text Translation

Core text translation functionality supporting 20+ languages with automatic language detection, batch processing, and customizable translation parameters.

def TextTranslate(self, request: models.TextTranslateRequest) -> models.TextTranslateResponse: ...
def TextTranslateBatch(self, request: models.TextTranslateBatchRequest) -> models.TextTranslateBatchResponse: ...
def LanguageDetect(self, request: models.LanguageDetectRequest) -> models.LanguageDetectResponse: ...

Text Translation

File Translation

Document translation supporting multiple formats (PDF, DOCX, PPTX, XLSX, TXT, XML, HTML, Markdown, Properties) with asynchronous processing and progress tracking.

def FileTranslate(self, request: models.FileTranslateRequest) -> models.FileTranslateResponse: ...
def GetFileTranslate(self, request: models.GetFileTranslateRequest) -> models.GetFileTranslateResponse: ...

File Translation

Image Translation

OCR-based image translation for 13-18 languages with support for document scanning, line-by-line translation, and enhanced LLM-powered processing.

def ImageTranslate(self, request: models.ImageTranslateRequest) -> models.ImageTranslateResponse: ...
def ImageTranslateLLM(self, request: models.ImageTranslateLLMRequest) -> models.ImageTranslateLLMResponse: ...

Image Translation

Speech Translation

Audio translation combining speech recognition and translation for Chinese-English bidirectional processing, supporting streaming and batch modes.

def SpeechTranslate(self, request: models.SpeechTranslateRequest) -> models.SpeechTranslateResponse: ...

Speech Translation

Common Types

Language Codes

# Major supported languages (varies by capability)
zh = "zh"        # Simplified Chinese
zh_TW = "zh-TW"  # Traditional Chinese  
zh_HK = "zh-HK"  # Traditional Chinese (Hong Kong)
zh_TR = "zh-TR"  # Traditional Chinese (Traditional)
en = "en"        # English
ja = "ja"        # Japanese
ko = "ko"        # Korean
fr = "fr"        # French
de = "de"        # German
es = "es"        # Spanish
it = "it"        # Italian
pt = "pt"        # Portuguese
ru = "ru"        # Russian
ar = "ar"        # Arabic
tr = "tr"        # Turkish
vi = "vi"        # Vietnamese
th = "th"        # Thai
ms = "ms"        # Malay
id = "id"        # Indonesian
hi = "hi"        # Hindi

Error Handling

from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException

try:
    response = client.TextTranslate(request)
except TencentCloudSDKException as e:
    error_code = e.code
    error_message = e.message

Common error codes include service limits, authentication failures, unsupported languages, and quota exhaustion. See the Error Codes Reference for complete details.

Install with Tessl CLI

npx tessl i tessl/pypi-tencentcloud-sdk-python-tmt
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/tencentcloud-sdk-python-tmt@3.0.x