const xunfeiTTS = require('xf-tts-socket');
const { promisify } = require('util');
const tts = promisify(xunfeiTTS);
const test_async_await_mp3 = async (app_id, app_skey, app_akey) => {
const auth = { app_id, app_skey, app_akey };
const business = { aue: 'lame', sfl: 1, vcn: 'aisjiuxu', speed: 80, pitch: 50, volume: 100 };
const text = '两块钱不算多,去不了香港去不了新加坡';
const file = path.resolve('./test/test_async_await_mp3.mp3');
try {
await tts(auth, business, text, file);
} catch (e) {
console.log('test exception', e);
}
};
test_async_await_mp3('xxxxxx', 'xxxxxx', 'xxxxxx');
const xunfeiTTS = require('xf-tts-socket');
const test_callback_mp3 = (app_id, app_skey, app_akey) => {
const auth = { app_id, app_skey, app_akey };
const business = { aue: 'lame', sfl: 1 };
const text = '两块钱,不算贵,不用回去开家庭会。';
const file = path.resolve('./test/test_callback_mp3.mp3');
xunfeiTTS(auth, business, text, file, (err, ret) => {
console.log('test_callback_mp3 end', err);
});
};
test_callback_mp3('xxxxxx', 'xxxxxx', 'xxxxxx');
const xunfeiTTS = require('xf-tts-socket');
const { promisify } = require('util');
const tts = promisify(xunfeiTTS);
const test_async_await_pcm = async (app_id, app_skey, app_akey) => {
const auth = { app_id, app_skey, app_akey };
const business = { aue: 'raw', vcn: 'aisjiuxu', speed: 80, pitch: 50, volume: 100 };
const text = '去不了香港去不了新加坡,两块钱';
const file = path.resolve('./test/test_async_await_pcm.pcm');
try {
await tts(auth, business, text, file);
} catch (e) {
console.log('test exception', e);
}
};
test_async_await_pcm('xxxxxx', 'xxxxxx', 'xxxxxx');
const xunfeiTTS = require('xf-tts-socket');
const test_callback_pcm = (app_id, app_skey, app_akey) => {
const auth = { app_id, app_skey, app_akey };
const business = { aue: 'raw' };
const text = '香港去不了新加坡,两块钱';
const file = path.resolve('./test/test_callback_pcm.pcm');
xunfeiTTS(auth, business, text, file, (err, ret) => {
console.log('test_callback_pcm end', err);
});
};
test_callback_pcm('xxxxxx', 'xxxxxx', 'xxxxxx');