อัตโนมัติการแปลเอกสารโดยใช้โมเดล Google Gemini AI กับ Aspose.Words สำหรับ Node.js via .NET . แปลไฟล์ DOC, DOCX, RTF, PDF, HTML, Markdown, ODT, TXT และ EPUB เป็นภาษากว่า 300 ภาษา พร้อมรักษาเค้าโครงและรูปแบบเดิมของเอกสารไว้. เครื่องยนต์ที่ใช้ AI จะตรวจจับภาษาต้นฉบับโดยอัตโนมัติ — แม้ในเอกสารหลายภาษา — และจะไม่แปลเฉพาะส่วนที่ไม่สามารถระบุได้.
การรับรองความถูกต้องต้องใช้คีย์ API ของ Google. สำหรับรายการโมเดล AI ที่รองรับทั้งหมด ดูที่ เอกสารอ้างอิง API.
เริ่มแปลเอกสารใน JavaScript วันนี้ — ลองดูการสาธิตสดด้านบน.
npm install @aspose/words
สำเนา
const aw = require('@aspose/words');
const doc = new aw.Document("Document.docx");
const apiKey = process.env.API_KEY;
// ใช้โมเดลภาษาเชิงกำเนิดของ Google
const model = aw.AI.AiModel.createGemini15Flash();
model.setApiKey(apiKey);
const translatedDoc = model.translate(doc, aw.AI.Language.Arabic);
translatedDoc.save("Output.docx");
const aw = require('@aspose/words');
const doc = new aw.Document("Document.docx");
// Pass an empty string if the self-hosted model does not require an API key.
const model = new CustomAiModel("my-model-24b", "https://your-server.com/v1");
model.setApiKey("");
const translatedDoc = model.translate(doc, aw.AI.Language.Arabic);
translatedDoc.save("Output.docx");
class CustomAiModel extends aw.AI.OpenAiModel {
constructor(name, url) {
super(name);
this._url = url;
}
get url() {
return this._url;
}
}
We host our Node.js via .Net packages in NPM repositories. Please follow the step-by-step instructions on how to install "Aspose.Words for Node.js via .NET" to your developer environment.
This package is compatible with Node.js 14.17.0 or higher.