Spaces:
Sleeping
Sleeping
|
Download docs/ko/APIS.md from ryusaksun/PDFTranslate: direct link, hf CLI and curl.
- Browser
- Download file 2.79 kB
-
https://huggingface.co/spaces/ryusaksun/PDFTranslate/resolve/main/docs/ko/APIS.md
- Command line
-
hf download hf://spaces/ryusaksun/PDFTranslate/docs/ko/APIS.md
-
curl -L -o APIS.md https://huggingface.co/spaces/ryusaksun/PDFTranslate/resolve/main/docs/ko/APIS.md
2.79 kB
| > [!CAUTION] | |
| > | |
| > μ΄ λ¬Έμλ μ€λλ λ¬Έμμ λλ€. μ°Έκ³ νμ§ λ§μμμ€. | |
| <h2 id="λͺ©μ°¨">λͺ©μ°¨</h2> | |
| νμ¬ νλ‘μ νΈλ λ κ°μ§ μ νμ API λ₯Ό μ§μνλ©°, λͺ¨λ λ°©λ²μλ Redis κ° νμν©λλ€; | |
| - [Python μμμ ν¨μ νΈμΆ](#api-python) | |
| - [HTTP νλ‘ν μ½](#api-http) | |
| --- | |
| <h2 id="api-python">Python</h2> | |
| `pdf2zh` λ Python μ μ€μΉλ λͺ¨λμ΄λ―λ‘, λ€λ₯Έ νλ‘κ·Έλ¨μμ νΈμΆν μ μλ λ κ°μ§ λ©μλλ₯Ό Python μ€ν¬λ¦½νΈμμ μ 곡ν©λλ€. | |
| μλ₯Ό λ€μ΄, Google Translate λ₯Ό μ¬μ©νμ¬ μμ΄ λ¬Έμλ₯Ό μ€κ΅μ΄λ‘ λ²μνλ €λ©΄ λ€μ μ½λλ₯Ό μ¬μ©ν μ μμ΅λλ€: | |
| ```python | |
| from pdf2zh_next import translate, translate_stream | |
| params = { | |
| 'lang_in': 'en', | |
| 'lang_out': 'zh', | |
| 'service': 'google', | |
| 'thread': 4, | |
| } | |
| ``` | |
| νμΌλ‘ λ²μνκΈ°: | |
| ```python | |
| (file_mono, file_dual) = translate(files=['example.pdf'], **params)[0] | |
| ``` | |
| μ€νΈλ¦ΌμΌλ‘ λ²μνκΈ° | |
| ```python | |
| with open('example.pdf', 'rb') as f: | |
| (stream_mono, stream_dual) = translate_stream(stream=f.read(), **params) | |
| ``` | |
| [β¬οΈ 맨 μλ‘ μ΄λ](#toc) | |
| --- | |
| <h2 id="api-http">HTTP</h2> | |
| λ³΄λ€ μ μ°ν λ°©λ²μΌλ‘, λ€μκ³Ό κ°μ κ²½μ° HTTP νλ‘ν μ½μ μ¬μ©νμ¬ νλ‘κ·Έλ¨κ³Ό ν΅μ ν μ μμ΅λλ€: | |
| 1. λ°±μλ μ€μΉ λ° μ€ν | |
| ```bash | |
| pip install pdf2zh_next[backend] | |
| pdf2zh_next --flask | |
| pdf2zh_next --celery worker | |
| ``` | |
| 2. λ€μκ³Ό κ°μ΄ HTTP νλ‘ν μ½ μ¬μ©: | |
| - λ²μ μμ μ μΆ | |
| ```bash | |
| curl http://localhost:11008/v1/translate -F "file=@example.pdf" -F "data={\"lang_in\":\"en\",\"lang_out\":\"zh\",\"service\":\"google\",\"thread\":4}" | |
| {"id":"d9894125-2f4e-45ea-9d93-1a9068d2045a"} | |
| ``` | |
| - μ§ν μν νμΈ | |
| ```bash | |
| curl http://localhost:11008/v1/translate/d9894125-2f4e-45ea-9d93-1a9068d2045a | |
| {"info":{"n":13,"total":506},"state":"PROGRESS"} | |
| ``` | |
| - μ§ν μν νμΈ _(μλ£ μ)_ | |
| ```bash | |
| curl http://localhost:11008/v1/translate/d9894125-2f4e-45ea-9d93-1a9068d2045a | |
| {"state":"SUCCESS"} | |
| ``` | |
| - λ¨μΌ μΈμ΄ νμΌ μ μ₯ | |
| ```bash | |
| curl http://localhost:11008/v1/translate/d9894125-2f4e-45ea-9d93-1a9068d2045a/mono --output example-mono.pdf | |
| ``` | |
| - μ΄μ€ μΈμ΄ νμΌ μ μ₯ | |
| ```bash | |
| curl http://localhost:11008/v1/translate/d9894125-2f4e-45ea-9d93-1a9068d2045a/dual --output example-dual.pdf | |
| ``` | |
| - μ€ν μ€μΈ κ²½μ° μ€λ¨νκ³ μμ μμ | |
| ```bash | |
| curl http://localhost:11008/v1/translate/d9894125-2f4e-45ea-9d93-1a9068d2045a -X DELETE | |
| ``` | |
| [β¬οΈ 맨 μλ‘ μ΄λ](#toc) | |
| --- | |
| <div align="right"> | |
| <h6><small>μ΄ νμ΄μ§μ μΌλΆ λ΄μ©μ GPT μ μν΄ λ²μλμμΌλ©° μ€λ₯κ° ν¬ν¨λ μ μμ΅λλ€.</small></h6> |