2
0

More than 1 year has passed since last update.

deeplAPIでファイルを翻訳する方法

Posted at

はじめに

deeplを使った翻訳アプリを作成したいと思い、調べて実装致しました。

対象

・Python学習者
・deeplで翻訳アプリを作成したい方

開発環境

・macOS Monterey バージョン12.3.1
・Python 3.10.8

本題

① deeplAPIを利用する際は、以下のサイトで登録する必要があります。
https://www.deepl.com/pro-api?cta=header-pro-api

② ライブラリをインストールする

pip install --upgrade deepl

③初期設定

import deepl

translator = deepl.Translator("認証キー")

④実装

translator.translate_document_from_filepath(
    "translate-test.docx",  #翻訳対象ファイル
    "translate-test-ja.docx", #翻訳後のファイル
    source_lang='DE', #元ファイルの言語
    target_lang="JA" #翻訳したい言語
)

参考サイト

まとめ

現在は、Djangoを使ってアプリを作成しており、実装出来次第、こちらで共有したいと思います。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0