Google Gemini AI 모델과 Aspose.Words for Python via .NET 를 사용하여 DOCX 문서 번역을 자동화합니다. DOCX 파일을 300개 이상의 언어로 번역하면서 원본 레이아웃, 서식 및 문서 구조를 유지합니다.
AI 엔진은 원본 언어를 자동으로 감지합니다 — 혼합 언어 문서에서도 가능합니다. 다음 예제는 Python 에서 DOCX 문서를 번역하는 방법을 보여줍니다:
pip install aspose-words
복사
doc = aw.Document("Document.docx")
api_key = os.getenv("API_KEY")
# Google 생성형 언어 모델 사용.
model = aw.ai.AiModel.create(aw.ai.AiModelType.GEMINI_FLASH_LATEST).with_api_key(api_key)
translated_doc = model.translate(doc, aw.ai.Language.ARABIC)
translated_doc.save("Output.docx")
doc = aw.Document("Document.docx")
# Pass an empty string if the self-hosted model does not require an API key.
model = CustomAiModel("my-model-24b", "https://your-server.com/v1").with_api_key("")
translated_doc = model.translate(doc, aw.ai.Language.ARABIC)
translated_doc.save("Output.docx")
class CustomAiModel(aw.ai.OpenAiModel):
def __init__(self, name, url):
super().__init__(name)
self._url = url
@property
def url(self):
return self._url
이 패키지는 Python ≥3.5 및 <3.12 와 호환됩니다. Linux용 소프트웨어를 개발하는 경우 제품 설명서 에서 gcc 및 libpython 에 대한 추가 요구 사항을 살펴보십시오.