google translate tts
1.0.0
แพ็คเกจนี้ใช้สำหรับการใช้ Google Translate เพื่อสร้างคลิปเสียงใน Node JS
ห้องสมุดนี้ได้รับการปรับปรุงให้ทำงานกับการเปลี่ยนแปลงใหม่ของ API แปลที่แนะนำโดย Google ในเดือนพฤศจิกายน 2563
ผู้สืบทอดทางจิตวิญญาณของ Google-TTS-API ซึ่งทำงานร่วมกับ API แปลก่อนหน้านี้
npm install google-translate-tts
หรือ
yarn add google-translate-tts
ค้นหาเสียงที่จะใช้:
const tts = require ( 'google-translate-tts' ) ;
// lookup by name
const voice = tts . voices . findByName ( 'English (United States)' ) ;
// lookup by code
const voice = tts . voices . findByCode ( 'en-US' ) ;
// an array of all voices
console . log ( tts . voices ) ;
/* Voice example:
* {
* code: 'en-US',
* name: 'English (United States)'
* }
*/ดาวน์โหลดคลิปเสียง:
const fs = require ( 'fs' ) ;
const tts = require ( 'google-translate-tts' ) ;
// notice that `tts.synthesize` returns a Promise<Buffer>
const saveFile = async ( ) => {
const buffer = await tts . synthesize ( {
text : 'Hello, world!' ,
voice : 'en-US' ,
slow : false // optional
} ) ;
fs . writeFileSync ( 'hello-world.mp3' , buffer ) ;
} ;
saveFile ( ) ;