feat: 新增运动节拍训练工具套件与子工具页面
新增运动节拍RepClock全套小程序页面、后端API与数据库服务,新增subhub子工具汇总页面,优化全局主页样式与配置,为web静态资源添加版本缓存参数,补充配套调试脚本
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const envPath = path.join(process.env.USERPROFILE || 'C:\\Users\\Administrator', 'Toolbox_local_creds.env.local')
|
||||
if (fs.existsSync(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
|
||||
}
|
||||
}
|
||||
global.__builtin_fetch = globalThis.fetch
|
||||
const API_KEY = process.env.DASHSCOPE_API_KEY
|
||||
|
||||
const CASES = [
|
||||
{
|
||||
name: 'T1 model=qwen-audio-3.0-tts-flash, voice=longanyang, text2audio/audio-synthesis',
|
||||
url: 'https://dashscope.aliyuncs.com/api/v1/services/aigc/text2audio/audio-synthesis',
|
||||
headers: { 'X-DashScope-Async': 'enable' },
|
||||
body: { model: 'qwen-audio-3.0-tts-flash', input: { text: '热身开合跳' }, parameters: { voice: 'longanyang', format: 'mp3', sample_rate: 24000 } }
|
||||
},
|
||||
{
|
||||
name: 'T2 model=cosyvoice-v3-flash, voice=longanyang',
|
||||
url: 'https://dashscope.aliyuncs.com/api/v1/services/aigc/text2audio/audio-synthesis',
|
||||
headers: { 'X-DashScope-Async': 'enable' },
|
||||
body: { model: 'cosyvoice-v3-flash', input: { text: '热身开合跳' }, parameters: { voice: 'longanyang', format: 'mp3', sample_rate: 24000 } }
|
||||
},
|
||||
{
|
||||
name: 'T3 model=cosyvoice-v3-plus, voice=longruoxi',
|
||||
url: 'https://dashscope.aliyuncs.com/api/v1/services/aigc/text2audio/audio-synthesis',
|
||||
headers: { 'X-DashScope-Async': 'enable' },
|
||||
body: { model: 'cosyvoice-v3-plus', input: { text: '热身开合跳' }, parameters: { voice: 'longruoxi', format: 'mp3', sample_rate: 24000 } }
|
||||
},
|
||||
{
|
||||
name: 'T4 qwen-audio-3.0-tts-plus, voice=longruoxi_v1',
|
||||
url: 'https://dashscope.aliyuncs.com/api/v1/services/aigc/text2audio/audio-synthesis',
|
||||
headers: { 'X-DashScope-Async': 'enable' },
|
||||
body: { model: 'qwen-audio-3.0-tts-plus', input: { text: '热身开合跳' }, parameters: { voice: 'longruoxi_v1', format: 'mp3', sample_rate: 24000 } }
|
||||
},
|
||||
]
|
||||
|
||||
async function runCase(c) {
|
||||
console.log('\n======== ' + c.name + ' ========')
|
||||
try {
|
||||
const resp = await global.__builtin_fetch(c.url, {
|
||||
method: 'POST',
|
||||
headers: Object.assign({ 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, c.headers || {}),
|
||||
body: JSON.stringify(c.body),
|
||||
})
|
||||
console.log('status=', resp.status, 'CT=', resp.headers.get('content-type'))
|
||||
const j = await resp.json()
|
||||
console.log(JSON.stringify(j).slice(0, 600))
|
||||
if (j && j.output && j.output.task_id) {
|
||||
console.log('task_id=', j.output.task_id, '— poll 2 次看看:')
|
||||
for (let k = 0; k < 2; k++) {
|
||||
await new Promise(r => setTimeout(r, 2000))
|
||||
const poll = await global.__builtin_fetch('https://dashscope.aliyuncs.com/api/v1/tasks/' + j.output.task_id, { headers: { 'Authorization': `Bearer ${API_KEY}` } })
|
||||
const p = await poll.json()
|
||||
console.log(' poll k=', k, 'status=', p && p.output && p.output.task_status, 'url=', p && p.output && p.output.audio_url && String(p.output.audio_url).slice(0, 80), 'msg=', p && p.message && String(p.message).slice(0, 80))
|
||||
if (p && p.output && (p.output.task_status === 'SUCCEEDED' || p.output.task_status === 'FAILED' || p.output.audio_url)) break
|
||||
}
|
||||
}
|
||||
} catch (e) { console.error('ERR', e && e.message ? e.message : e) }
|
||||
}
|
||||
|
||||
;(async () => {
|
||||
for (const c of CASES) await runCase(c)
|
||||
})()
|
||||
Reference in New Issue
Block a user