-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
36 lines (31 loc) · 803 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const PicoTTS = require('./lib/')
const {WaveFile} = require('wavefile')
const File = require('fs')
const c = new PicoTTS({
ta_file: 'lang/fr-FR_ta.bin',
sg_file: 'lang/fr-FR_nk0_sg.bin',
volume: 90,
speed: 95,
pitch: 105,
debug: false
})
const samples = []
c
.on('error', err => {
console.error(err)
})
.on('data', (chunk, isLastChunk) => {
// console.log('CHUNK', isLastChunk)
for ( let i = 0 ; i < chunk.byteLength ; i += 2 ) {
const s = chunk.readInt16LE(i, i + 2)
samples.push(s)
}
})
.on('end', () => {
const wav = new WaveFile()
wav.fromScratch(1, 16000, 16, samples)
File.writeFileSync('test.wav', wav.toBuffer())
})
// const text = 'Lecture des meilleures chansons de Céline Dion dans le salon.'
const text = 'Bonjour à tous'
console.log(c.speak(text))