d4bf3627fd
新增运动节拍RepClock全套小程序页面、后端API与数据库服务,新增subhub子工具汇总页面,优化全局主页样式与配置,为web静态资源添加版本缓存参数,补充配套调试脚本
50 lines
2.6 KiB
JavaScript
50 lines
2.6 KiB
JavaScript
const path = require('path')
|
|
const envPath = path.join(process.env.USERPROFILE || 'C:\\Users\\Administrator', 'Toolbox_local_creds.env.local')
|
|
const fs = require('fs')
|
|
if (fs.existsSync(envPath)) {
|
|
process.env.USERPROFILE_CREDS = envPath
|
|
const text = fs.readFileSync(envPath, 'utf8')
|
|
for (const line of text.split(/\r?\n/)) {
|
|
if (!line || /^\s*#/.test(line)) continue
|
|
const i = line.indexOf('=')
|
|
if (i < 0) continue
|
|
const k = line.slice(0, i).trim(), v = line.slice(i + 1).trim().replace(/^["']|["']$/g, '')
|
|
if (k && !(k in process.env)) process.env[k] = v
|
|
}
|
|
console.log('[env] loaded Toolbox_local_creds.env.local from', envPath)
|
|
} else {
|
|
console.log('[env] NOT found', envPath)
|
|
}
|
|
console.log('[env] DASHSCOPE_API_KEY =', (process.env.DASHSCOPE_API_KEY || '').slice(0, 14) + '... len=' + (process.env.DASHSCOPE_API_KEY || '').length)
|
|
global.__builtin_fetch = globalThis.fetch
|
|
if (!global.__builtin_fetch) try { global.__builtin_fetch = require('node-fetch') } catch (_) { console.error('no fetch available') }
|
|
const tts = require('../../src/server/mp_rep_clock/tts')
|
|
;(async () => {
|
|
const card = {
|
|
title: '测试一下',
|
|
loopMode: 'loop_till_stop',
|
|
loopCount: 0,
|
|
announceLeadSeconds: '5,3,1',
|
|
steps: [
|
|
{ name: '热身开合跳', durationSec: 30, restSec: 10, type: 'action' },
|
|
{ name: '平板支撑', durationSec: 45, restSec: 15, type: 'action' },
|
|
],
|
|
}
|
|
console.log('\n=== 1. 看 buildCardTTSBatch lines ===')
|
|
const lines = tts.buildCardTTSBatch(card)
|
|
console.log('lines.length=', lines.length)
|
|
lines.forEach((l, i) => console.log(` [${i}] ${l}`))
|
|
|
|
console.log('\n=== 2. 合成第0条 (开始训练,测试一下) ===')
|
|
const s0 = await tts.synthesize(lines[0], 'female_01')
|
|
console.log('synthesize ok=', s0.ok, 'error=', s0.error || null, 'url=', s0.url || null, 'cached=', !!s0.cached, 'durationMs=', s0.durationMs)
|
|
|
|
console.log('\n=== 3. 全量 synthesizeBatch ===')
|
|
const batch = await tts.synthesizeBatch(card, 'female_01')
|
|
console.log('batch total=', batch.total, 'success=', batch.success)
|
|
batch.results.forEach((r, i) => console.log(` [${i}] ok=${r.ok} cached=${!!r.cached} err=${r.error || null} text=${r.text.slice(0, 20)} url=${(r.url || '').slice(0, 60)}`))
|
|
|
|
console.log('\n=== 4. 检查 uploads 目录是否生成了 mp3 ===')
|
|
try { const f = fs.readdirSync(tts.TTS_ROOT); console.log('TTS_ROOT=', tts.TTS_ROOT, 'files.Count=', f.length); f.slice(0, 10).forEach((x) => console.log(' ', x, Math.round((fs.statSync(path.join(tts.TTS_ROOT, x)).size / 1024)), 'KB')) } catch (e) { console.log('ERR read dir', e && e.message) }
|
|
})().catch(e => { console.error('FATAL', e); process.exit(1) })
|