mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
fix: 闭嘴功能
This commit is contained in:
parent
ce6559b644
commit
156a669ec6
5 changed files with 208 additions and 3 deletions
|
|
@ -5,7 +5,7 @@ import lodash from 'lodash'
|
|||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import puppeteer from '../../../lib/puppeteer/puppeteer.js'
|
||||
import {Config} from "./config.js";
|
||||
import { Config } from './config.js'
|
||||
// export function markdownToText (markdown) {
|
||||
// return remark()
|
||||
// .use(stripMarkdown)
|
||||
|
|
@ -296,3 +296,58 @@ export function getDefaultUserSetting () {
|
|||
ttsRole: Config.defaultTTSRole
|
||||
}
|
||||
}
|
||||
|
||||
export function parseDuration (duration) {
|
||||
const timeMap = {
|
||||
秒: 1000,
|
||||
分: 60 * 1000,
|
||||
小时: 60 * 60 * 1000
|
||||
}
|
||||
|
||||
// 去掉多余的空格并将单位转化为小写字母
|
||||
duration = duration.trim().toLowerCase()
|
||||
|
||||
// 去掉末尾的 "钟" 字符
|
||||
if (duration.endsWith('钟')) {
|
||||
duration = duration.slice(0, -1)
|
||||
}
|
||||
|
||||
// 提取数字和单位
|
||||
const match = duration.match(/^(\d+)\s*([\u4e00-\u9fa5]+)$/)
|
||||
|
||||
if (!match) {
|
||||
throw new Error('Invalid duration string: ' + duration)
|
||||
}
|
||||
|
||||
const num = parseInt(match[1], 10)
|
||||
const unit = match[2]
|
||||
|
||||
if (!(unit in timeMap)) {
|
||||
throw new Error('Unknown time unit: ' + unit)
|
||||
}
|
||||
|
||||
return num * timeMap[unit]
|
||||
}
|
||||
|
||||
export function formatDuration (duration) {
|
||||
const timeMap = {
|
||||
小时: 60 * 60 * 1000,
|
||||
分钟: 60 * 1000,
|
||||
秒钟: 1000
|
||||
}
|
||||
|
||||
const units = Object.keys(timeMap)
|
||||
let result = ''
|
||||
|
||||
for (let i = 0; i < units.length; i++) {
|
||||
const unit = units[i]
|
||||
const value = Math.floor(duration / timeMap[unit])
|
||||
|
||||
if (value > 0) {
|
||||
result += value + unit
|
||||
duration -= value * timeMap[unit]
|
||||
}
|
||||
}
|
||||
|
||||
return result || '0秒钟'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ const defaultConfig = {
|
|||
noiseScaleW: 0.668,
|
||||
lengthScale: 1.2,
|
||||
initiativeChatGroups: [],
|
||||
version: 'v2.0.19'
|
||||
version: 'v2.0.20'
|
||||
}
|
||||
const _path = process.cwd()
|
||||
let config = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue