博客
关于我
python谷歌翻译,2021年9月10日亲测可用,一次可以翻译十万,强烈star
阅读量:797 次
发布时间:2023-03-06

本文共 1136 字,大约阅读时间需要 3 分钟。

pygtransTranslate API 开源库 Documentation

安装

使用 pip 安装 pygtransTranslate:

pip install pygtrans

基本使用

导入库

from pygtrans import Translate

检测语言

client = Translate()
text = client.detect('Answer the question.')
# text.language 将返回检测到的语言

翻译句子

text = client.translate('Look at these pictures and answer the questions.')
# text.translatedText 将返回翻译后的文本

批量翻译

texts = [
'Good morning. What can I do for you?',
'Read aloud and underline the sentences about booking a flight.',
'May I have your name and telephone number?'
]
translated_texts = client.translate(texts)
# translated_texts 是一个包含所有翻译结果的列表

支持多语言

# 翻译到中文
text = client.translate('请多多指教')
# text.translatedText -> '请多多指教'
# 翻译到日语
text = client.translate('请多多指教', target='ja')
# text.translatedText -> 'お知らせ下さい'
# 翻译到韩语
text = client.translate('请多多指教', target='ko')
# text.translatedText -> '조언 부탁드립니다'

文本到语音

tts = client.tts('やめて', target='ja')
# 生成语音文件,保存为 'やめて.mp3'
with open('やめて.mp3', 'wb') as f:
f.write(tts)

高级功能

支持大规模请求

pygtransTranslate 可以处理长列表的翻译任务,支持超过 10 万个请求,适合大规模自动化任务。

API 键

请参考 pygtrans API 文档 获取详细信息。


开源项目

此外,pygtransTranslate 是一个开源项目,旨在为开发者提供简单易用的翻译 API 接口。

转载地址:http://krafk.baihongyu.com/

你可能感兴趣的文章
python CV2裁剪图片并保存
查看>>
python进阶(2):pyecharts使用
查看>>
python cv2读取rtsp实时码流按时生成连续视频文件
查看>>
Python Dataframe Groupby Mean和Std
查看>>
python datetime
查看>>
python datetime笔记
查看>>
python day01
查看>>
python day10
查看>>
Python Day17 Django 03
查看>>
python day21
查看>>
python decode和encode
查看>>
Python del 语句
查看>>
Python Dict 理解创建和更新字典
查看>>
Python Discord Bot - python clear_reaction() 清除所有反应而不是特定反应
查看>>
python django mysql写入中文乱码_django自动创建的mysql表里面中文乱码问题
查看>>
python docx的超链接网址和链接文本
查看>>
python elasticsearch 导出数据到json文件导入到另一个es中
查看>>
python进阶(1):json的使用
查看>>
python ETL工具 pyetl
查看>>
Python eval 函数说明
查看>>