EADST

Baidu Translation API Code

Baidu Translation API Code

import requests
import hashlib
import random

def translate_text(text, from_lang='en', to_lang='zh'):
    app_id = '202300xx' # update your app_id and app_key
    app_key = 'OFxx' #  app_id and app_key can be applied from https://cloud.baidu.com/
    url = "http://api.fanyi.baidu.com/api/trans/vip/translate"
    salt = random.randint(32768, 65536)
    sign = app_id + text + str(salt) + app_key
    sign = hashlib.md5(sign.encode()).hexdigest()
    headers = {'Content-Type': 'application/x-www-form-urlencoded'}
    payload = {'appid': app_id, 'q': text, 'from': from_lang, 'to': to_lang, 'salt': salt, 'sign': sign}
    response = requests.post(url, params=payload, headers=headers)
    response_json = response.json()
    return response_json['trans_result'][0]['dst']
       
      
相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
Streamlit Qwen Zip API TTS Mixtral Translation Pillow Cloudreve 论文 Template LLM Freesound C++ CUDA Windows LaTeX LeetCode Password git-lfs XML 强化学习 Datetime Bipartite 报税 mmap Review GPTQ Git LLAMA 证件照 Jetson Tiktoken Nginx ChatGPT HuggingFace Disk Ubuntu RGB 签证 净利润 tqdm DeepStream Data OpenCV Safetensors Markdown Linux Video Breakpoint 多线程 WAN Firewall Quantization RL Color Paper Hilton GIT DeepSeek GGML Interview 关于博主 Base64 JSON FP64 Crawler icon QWEN Augmentation v2ray Algorithm Excel Gemma Pickle SPIE Sklearn CTC Hungarian 顶会 PIP ms-swift Michelin Bitcoin Miniforge WebCrawler SAM Django EXCEL Rebuttal MD5 Jupyter NLP Bert Dataset scipy AI 版权 uwsgi Diagram PyCharm Web FastAPI 云服务器 GPT4 diffusers InvalidArgumentError OCR Transformers BF16 Conda UNIX Vmess Agent Magnet hf IndexTTS2 git Claude FP8 CC Llama YOLO OpenAI Permission Math Clash Anaconda Use PDB torchinfo TensorRT PyTorch CEIR 继承 Animate 算法题 Qwen2 Distillation VSCode Proxy Qwen2.5 阿里云 Attention Vim v0.dev Baidu CV Land Bin 域名 音频 Pandas 腾讯云 论文速读 Ptyhon COCO Quantize Github printf 图形思考法 Tensor FlashAttention HaggingFace Python NameSilo LoRA Logo NLTK 多进程 VPN FP16 News TensorFlow CSV Tracking PDF RAR Plate UI Plotly 飞书 tar TSV Statistics llama.cpp Random ResNet-50 图标 BeautifulSoup Input VGG-16 SQLite ONNX CAM 搞笑 Paddle 递归学习法 logger transformers Image2Text Hotel Numpy Domain Shortcut Search 第一性原理 Heatmap Card SVR BTC Google Docker ModelScope Knowledge Pytorch Website CLAP XGBoost uWSGI SQL FP32 公式 Food GoogLeNet 财报
站点统计

本站现有博文333篇,共被浏览925558

本站已经建立2632天!

热门文章
文章归档
回到顶部