GithubHelp home page GithubHelp logo

fabriziocafolla / openai-chatgpt-opentranslator Goto Github PK

View Code? Open in Web Editor NEW
29.0 4.0 13.0 27 KB

Python command that uses openai to perform text translations

Home Page: https://pypi.org/project/opentranslator/

License: GNU General Public License v3.0

Python 88.12% Shell 9.03% Makefile 2.84%
chatgpt chatgpt-api chatgpt-python openai chatgpt3 openai-api python-translator python3

openai-chatgpt-opentranslator's Introduction

Opentranslator - OpenAI | ChatGPT | Translate with python

Opentranslator is a simple command that can be used from the terminal to translate text (text plain or from a file). It uses OpenAI API to perform all operations, you can choose which ai engine to use by passing it as a parameter.

The following project was born to study OpenAI and how it works. If you would contribute open a pull request or issue on GitHub.

Mantained by

Usage

Required

  • Python >= 3.7
  • OpenAI Account

Input text

# You can save your OPENAI_API_KEY permanently in the user's environment
export OPENAI_API_KEY="${YOUR_OPENAI_API_KEY}"

pip install opentranslator

opentranslator --translate english --text "Ciao Mondo!"

Text from file

opentranslator --translate english --filepath examples/it.txt

Other

Arg -vvv: output all info with cost of request (in progress)

Dev mode

  1. Setup env
git clone https://github.com/FabrizioCafolla/chatgpt-translate-app.git

cd chatgpt-translate-app

echo 'export OPENAI_API_KEY="${YOUR_OPENAI_API_KEY}"' > .env

chmod +x scritps/*.sh

./scripts/setup.sh

source .activate
  1. Usage
python opentranslator/app.py --filepath examples/it.txt --translate english

python opentranslator/app.py --filepath examples/en.txt --translate italian

python opentranslator/app.py --text "Ciao Mondo!" --translate english

Contributors

License

The project is made available under the GPL-3.0 license. See the LICENSE file for more information.

openai-chatgpt-opentranslator's People

Contributors

fabriziocafolla avatar nyreed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

openai-chatgpt-opentranslator's Issues

πŸ› [BUG] - setup.sh fails if pre-commit not installed in global packages.

Description

System: MacOS 12.6.5 (Monterey) - ARM64.
Python 3.11.2 (homebrew, ARM64)
pip 23.1.2

Per instructions:
Running ./scripts/setup.sh fails with
command not found: pre-commit

Installing pre-commit into global python packages (pip install pre-commit outside of venv) and running the script again results in success.

FIX

include pre-commit in requirements.txt
invoke via "python -m pre_commit" in seup.sh

Reproduction steps

Running `./scripts/setup.sh` fails with `command not found: pre-commit`

Logs

No response

OS

Mac

OS Version

System: MacOS 12.6.5 (Monterey) - ARM64.
Python 3.11.2 (homebrew, ARM64)
pip 23.1.2

πŸ› [BUG] - Project doesnt build due to upstream issue with isort / poetry.

Description

Cannot build due to incompatibility between upstream isort update and breaking changes in poetry configuration.
This is impacting a lot of projects.

See PyCQA/isort#2083 (comment)

Fix is to run pre-commit auto-update in the setup.sh file.
I will create a PR for this small issue.

Reproduction steps

run ./scripts/setup.sh as instructed in install.

Expected behaviour: project builds.

Logs

Successfully installed aiohttp-3.8.4 aiosignal-1.3.1 async-timeout-4.0.2 attrs-23.1.0 certifi-2022.12.7 cfgv-3.3.1 charset-normalizer-3.1.0 click-8.1.3 distlib-0.3.6 filelock-3.12.0 frozenlist-1.3.3 identify-2.5.23 idna-3.4 multidict-6.0.4 nodeenv-1.7.0 openai-0.27.5 platformdirs-3.5.0 pre-commit-3.2.2 pyyaml-6.0 requests-2.29.0 tqdm-4.65.0 urllib3-1.26.15 virtualenv-20.23.0 yarl-1.9.2
pre-commit installed at .git/hooks/pre-commit
[INFO] Installing environment for https://github.com/pycqa/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/Users/brand/.cache/pre-commit/repocydpt8qy/py_env-python3/bin/python', '-mpip', 'install', '.')
return code: 1
stdout:
    Processing /Users/brand/.cache/pre-commit/repocydpt8qy
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'error'
stderr:
      error: subprocess-exited-with-error

      Γ— Preparing metadata (pyproject.toml) did not run successfully.
      β”‚ exit code: 1
      ╰─> [17 lines of output]
          Traceback (most recent call last):
            File "/Users/brand/.cache/pre-commit/repocydpt8qy/py_env-python3/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
              main()
            File "/Users/brand/.cache/pre-commit/repocydpt8qy/py_env-python3/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
              json_out['return_val'] = hook(**hook_input['kwargs'])
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/Users/brand/.cache/pre-commit/repocydpt8qy/py_env-python3/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
              return hook(metadata_directory, config_settings)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/private/var/folders/s1/jbydn_pn0mn2x0qqqfcvzddw0000gn/T/pip-build-env-0x6uaksp/overlay/lib/python3.11/site-packages/poetry/core/masonry/api.py", line 40, in prepare_metadata_for_build_wheel
              poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/private/var/folders/s1/jbydn_pn0mn2x0qqqfcvzddw0000gn/T/pip-build-env-0x6uaksp/overlay/lib/python3.11/site-packages/poetry/core/factory.py", line 57, in create_poetry
              raise RuntimeError("The Poetry configuration is invalid:\n" + message)
          RuntimeError: The Poetry configuration is invalid:
            - [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$'

          [end of output]

      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed

    Γ— Encountered error while generating package metadata.
    ╰─> See above for output.

OS

Mac

OS Version

System: MacOS 12.6.5 (Monterey) - ARM64.
Python 3.11.2 (homebrew, ARM64)
pip 23.1.2

Add Google FreeπŸ’‘ [REQUEST] - <title>

Summary

Are you able to add new engine like Google Pygtrans or some others free service, openai cost too much for translate game to multi languages.
And how to use your code with CLI to translate a game to multi languages with one command?

Implementation PR

No response

Reference Issues

No response

Basic Example

No response

Drawbacks

No response

πŸ’‘ [REQUEST] - Automating the translation of large text files.

Summary

Would it be possible to split a text file into multiple smaller queries and have the results of all those parts merged back together to create a final translated file? Currently, if a document has a lot of text, we have to do this task manually, and when there are many parts, it becomes a really burdensome task.

Implementation PR

No response

Reference Issues

No response

Basic Example

No response

Drawbacks

No response

πŸ’‘ [REQUEST] - Add support Korean and Japanese

Summary

Currently when trying to translate Korean or Japanese it doesn't work. Can you add support for these languages? I was able to translate the examples without any issue and other languages but was unable to translate those two languages. Can you also add in an a way to export the translation to a file?

Implementation PR

No response

Reference Issues

No response

Basic Example

No response

Drawbacks

No response

πŸ’‘ [REQUEST] - <workflow on windows>

Summary

I am sorry that I am a layman in coding.

I tried the Dev codes in Linux, and it worked.

However, when I tried it in Windows, it failed.

Would you mind providing a workflow for Windows? Thanks.

Implementation PR

No response

Reference Issues

No response

Basic Example

No response

Drawbacks

No response

We need a version that supports browser login not via API

Summary

I got chatGPT plus

it can translate entire subtitle but you have to split it into like 1 minute frames and type again and again

which takes huge time

can you modify it so that we can use chat GPT plus subscription not API?

Reference Issues

No response

Basic Example

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.