Google Gemini AI モデルと Aspose.Words for Python via .NET を使用して文書翻訳を自動化します。DOC、DOCX、RTF、PDF、HTML、Markdown、ODT、TXT、EPUB ファイルを 300 以上の言語に翻訳し、元のレイアウトと書式を保持します。AI ベースのエンジンはソース言語を自動的に検出し(多言語文書でも)、認識できないフラグメントだけを未翻訳のまま残します。
認証には Google API キーが必要です。サポートされている AI モデルの全リストは、API リファレンスをご覧ください。
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 の追加要件を参照してください。