google translate tts
1.0.0
이 패키지는 Google Translate를 사용하여 Node JS에서 오디오 클립을 작성하는 것입니다.
이 라이브러리는 2020 년 11 월에 Google이 도입 한 Translate API에 대한 새로운 변경 사항을 사용하도록 업데이트되었습니다.
이전 번역 API와 함께 일한 Google-TTS-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 ( ) ;