simple tts mp3
1.1.0
该软件包提供了两种方法,可以使用Google-TTS-API模块从文本创建MP3音频文件,它也与Typescript兼容,在NPM上找到它!
如果您喜欢,请在Github上留一颗星星
| 方法 | 选项[可选] | 描述 |
|---|---|---|
| createAudiofile | 文本,文件名,[language ='en'] | 从文本创建MP3音频文件并返回其最终路径-Promise(string) |
| getaudiobuffer | 文字,[语言='en'] | 从文本中创建MP3音频缓冲区并返回-Promise(Buffer) |
ex: ./folder/name )。检查Wiki以查看此软件包支持的所有语言。
npm install simple-tts-mp3 // Importing create file method from package
const { createAudioFile } = require ( 'simple-tts-mp3' ) ;
// Creates an "output.mp3" audio file with default English text
createAudioFile ( 'Hi, How are you?' , 'output' ) ;
// Creates an "output.mp3" audio file with Spanish text and promise resolved
createAudioFile ( 'Hola, ¿Cómo estás?' , 'output' , 'es' ) . then ( ( filepath ) => {
console . log ( filepath ) ;
} ) ;
// Creates an "output.mp3" audio file with Spanish text inside the "audios" folder and awaits filepath
const filepath = await createAudioFile ( 'Todo bien, gracias' , './audios/output' , 'es' ) ; // Importing create
const { getAudioBuffer } = require ( 'simple-tts-mp3' ) ;
// Creates an MP3 audio buffer with Spanish text and resolves the promise with it
getAudioBuffer ( 'Hola, ¿cómo estás?' , 'es' )
. then ( buffer => {
// Do something with the buffer
} ) ;
// Creates an MP3 audio buffer with default English text and awaits it
const buffer = await getAudioBuffer ( 'Hi, How are you?' ) ;