قم بأتمتة ترجمة مستندات DOCX باستخدام نماذج Google Gemini AI مع Aspose.Words لـ Python via .NET. ترجم ملفات DOCX إلى أكثر من 300 لغة مع الحفاظ على التخطيط الأصلي، والتنسيق، وبنية المستند.
يكتشف محرك الذكاء الاصطناعي اللغة المصدر تلقائيًا — حتى في المستندات ذات اللغات المختلطة. المثال التالي يوضح كيفية ترجمة مستند DOCX في Python:
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 بنا في مستودعات PyPi. يرجى اتباع التعليمات خطوة بخطوة حول كيفية تثبيت "Aspose.Words for Python via .NET" في بيئة المطور لديك.
هذه الحزمة متوافقة مع Python ≥3.5 و <3.12. إذا قمت بتطوير برنامج لنظام التشغيل Linux، فيرجى إلقاء نظرة على المتطلبات الإضافية لدول gcc و libpython في وثائق المنتج.