feat: 音频工具 — Piper本地TTS(中英语音+语速调节) + Whisper音频转文字(中英日粤+时间轴) + 声音克隆占位; 服务端全本地模型

This commit is contained in:
personal82555 committed 2026-10-12 11:52:53 +08:00
1 parent 6bc2120c05
commit 54fba4d97a
11 files changed
+831 -2

No files matched your search

+1
View File
@@ -14,6 +14,7 @@ declare module '@vue/runtime-core' {
AiRetouch: typeof import('./src/tools/ai-retouch/ai-retouch.vue')['default']
App: typeof import('./src/App.vue')['default']
AsciiTextDrawer: typeof import('./src/tools/ascii-text-drawer/ascii-text-drawer.vue')['default']
AudioTools: typeof import('./src/tools/audio-tools/audio-tools.vue')['default']
BarcodeBatchGenerator: typeof import('./src/tools/batch-barcode-generator/barcode-batch-generator.vue')['default']
'Base.layout': typeof import('./src/layouts/base.layout.vue')['default']
Base64FileConverter: typeof import('./src/tools/base64-file-converter/base64-file-converter.vue')['default']
+104
View File
@@ -0,0 +1,104 @@
"""Audio tool operations: TTS (edge-tts) and ASR (faster-whisper)."""
import asyncio
import os
import re
FFMPEG_BIN = "ffmpeg"
MAX_TTS_CHARS = 2000
MAX_ASR_MB = 30
VOICE_FILES = {
"zh_CN-huayan-medium": "晓妍(女·标准中文)",
"en_US-amy-medium": "Amy(女·英语)",
}
_asr_model = None
def _get_asr():
global _asr_model
if _asr_model is None:
from faster_whisper import WhisperModel
_asr_model = WhisperModel("small", device="cpu", compute_type="int8")
return _asr_model
PIPER_DIR = os.environ.get("PIPER_DIR", "/app/piper-models")
_piper_voices = {}
def _load_voice(voice: str):
from piper import PiperVoice
if voice not in _piper_voices:
model = os.path.join(PIPER_DIR, voice + ".onnx")
if not os.path.exists(model):
raise ValueError("音色不存在: " + voice)
_piper_voices[voice] = PiperVoice.load(model)
return _piper_voices[voice]
def run_tts(text: str, voice: str, rate_pct: int, pitch_hz: int, out_path: str):
import subprocess
import tempfile
import wave
text = (text or "").strip()
if not text:
raise ValueError("请输入文字内容")
if len(text) > MAX_TTS_CHARS:
raise ValueError(f"文字过长(最多 {MAX_TTS_CHARS} 字)")
if voice not in VOICE_FILES:
voice = "zh_CN-huayan-medium"
rate_pct = max(-50, min(100, int(rate_pct)))
v = _load_voice(voice)
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as tf:
wav_path = tf.name
try:
with open(wav_path, "wb") as f:
with wave.open(f, "wb") as wf:
v.synthesize_wav(text, wf)
# post-process: speed (atempo) + pitch-free, output mp3
tempo = 1 + rate_pct / 100.0
tempo = max(0.5, min(2.0, tempo))
argv = [FFMPEG_BIN, "-y", "-i", wav_path, "-filter:a", f"atempo={tempo:.4f}",
"-c:a", "libmp3lame", "-b:a", "192k", out_path]
env = dict(os.environ)
env.pop("HTTPS_PROXY", None)
r = subprocess.run(argv, capture_output=True, timeout=120, env=env)
if r.returncode != 0:
# fallback: plain wav->mp3
r = subprocess.run([FFMPEG_BIN, "-y", "-i", wav_path, "-c:a", "libmp3lame",
"-b:a", "192k", out_path], capture_output=True, timeout=120, env=env)
if r.returncode != 0:
raise RuntimeError("音频转码失败")
finally:
try:
os.remove(wav_path)
except Exception:
pass
if not os.path.exists(out_path) or os.path.getsize(out_path) < 100:
raise RuntimeError("TTS 生成失败")
def run_asr(audio_path: str, language: str):
model = _get_asr()
language = language if language in ("zh", "en", "ja", "yue") else None
segments, info = model.transcribe(audio_path, language=language, beam_size=2, vad_filter=True)
out = []
texts = []
for s in segments:
item = {"start": round(s.start, 1), "end": round(s.end, 1), "text": s.text.strip()}
out.append(item)
texts.append(s.text.strip())
return {
"text": "\n".join(texts),
"segments": out[:200],
"language": info.language,
"probability": round(info.language_probability, 2),
}
# voices served by local piper models
VOICES = [
{"value": k, "label": v, "lang": k.split("_")[0]}
for k, v in VOICE_FILES.items()
]
+101 -1
View File
@@ -44,7 +44,7 @@ AUTH_PASS = os.environ.get("AUTH_PASS", "")
PROJECT_NAME = os.environ.get("PROJECT_NAME", "IT-Tools")
TRIAL_FILE = os.environ.get("TRIAL_FILE", "/app/data/trials.json")
TRIAL_MS = int(os.environ.get("TRIAL_MS_MIN", "30")) * 60 * 1000
PROTECTED_TOOLS = {"translator", "image-ocr", "pdf-ocr", "ai-retouch", "label-designer", "doc-convert", "image-tools", "pdf-tools", "video-tools"}
PROTECTED_TOOLS = {"translator", "image-ocr", "pdf-ocr", "ai-retouch", "label-designer", "doc-convert", "image-tools", "pdf-tools", "video-tools", "audio-tools"}
MACHINE_RE = re.compile(r"^\d{10,16}$")
# verify() messages that unconditionally block activation
@@ -463,6 +463,13 @@ def sites_api(method: str, path: str, payload: dict) -> tuple[int, dict]:
return 404, {"code": 404, "message": "not found", "data": None}
def _int_str(v, lo, hi, default=0):
try:
return max(lo, min(hi, int(float(v))))
except Exception:
return default
def check(machine: str, tool: str) -> int:
if not machine or not MACHINE_RE.match(machine):
return 403
@@ -950,11 +957,104 @@ class Handler(BaseHTTPRequestHandler):
except Exception:
pass
def _handle_tts(self):
import audio_ops
machine = self.headers.get("X-Machine-Id", "")
status = check(machine, "audio-tools")
if status != 200:
self._reply(403, json.dumps({"code": 403, "message": "需要授权或免费试用已结束"}, ensure_ascii=False).encode("utf-8"), "application/json")
return
try:
length = int(self.headers.get("Content-Length") or 0)
raw = self.rfile.read(length) if length else b"{}"
payload = json.loads(raw.decode("utf-8") or "{}")
import uuid as _uuid
out_path = "/tmp/tts-" + _uuid.uuid4().hex[:10] + ".mp3"
try:
audio_ops.run_tts(
str(payload.get("text") or ""),
str(payload.get("voice") or ""),
_int_str(payload.get("rate"), -50, 100, 0),
_int_str(payload.get("pitch"), -50, 50, 0),
out_path,
)
with open(out_path, "rb") as f:
out = f.read()
finally:
try:
os.remove(out_path)
except Exception:
pass
self.send_response(200)
self.send_header("Content-Type", "audio/mpeg")
self.send_header("Content-Length", str(len(out)))
self.end_headers()
self.wfile.write(out)
except ValueError as e:
self._reply(400, json.dumps({"code": 400, "message": str(e)}, ensure_ascii=False).encode("utf-8"), "application/json")
except Exception as e: # noqa: BLE001
self._reply(500, json.dumps({"code": 500, "message": "合成失败: " + str(e)[:200]}, ensure_ascii=False).encode("utf-8"), "application/json")
def _handle_asr(self):
import audio_ops
import uuid as _uuid
import video_ops
machine = self.headers.get("X-Machine-Id", "")
status = check(machine, "audio-tools")
if status != 200:
self._reply(403, json.dumps({"code": 403, "message": "需要授权或免费试用已结束"}, ensure_ascii=False).encode("utf-8"), "application/json")
return
workdir = None
try:
ctype = self.headers.get("Content-Type", "")
length = int(self.headers.get("Content-Length") or 0)
if length > audio_ops.MAX_ASR_MB * 1024 * 1024 + 1024 * 1024:
self._reply(413, json.dumps({"code": 413, "message": "音频超过 " + str(audio_ops.MAX_ASR_MB) + "MB 限制"}, ensure_ascii=False).encode(), "application/json")
return
raw = self.rfile.read(length) if length else b""
env = {"REQUEST_METHOD": "POST", "CONTENT_TYPE": ctype, "CONTENT_LENGTH": str(length)}
fs = cgi.FieldStorage(fp=io.BytesIO(raw), environ=env, keep_blank_values=True)
fobj = fs["file"] if ("file" in fs.keys()) else None
if fobj is None or not fobj.filename:
self._reply(400, json.dumps({"code": 400, "message": "缺少音频文件"}, ensure_ascii=False).encode(), "application/json")
return
fname = os.path.basename(fobj.filename or "audio")
ext = os.path.splitext(fname)[1].lower()
if ext not in (".mp3", ".wav", ".m4a", ".ogg", ".flac", ".aac", ".webm", ".mp4", ".wma", ".opus"):
self._reply(400, json.dumps({"code": 400, "message": "不支持的音频格式 " + ext}, ensure_ascii=False).encode(), "application/json")
return
lang = fs["language"].value if "language" in fs.keys() else ""
workdir = "/tmp/asr-" + _uuid.uuid4().hex[:10]
os.makedirs(workdir, exist_ok=True)
fpath = os.path.join(workdir, "in" + ext)
with open(fpath, "wb") as f:
f.write(fobj.file.read())
# normalize to wav mono 16k for whisper (handles mp4/m4a containers too)
wav = os.path.join(workdir, "in.wav")
argv, _ = video_ops.build_cmd("audio", fpath, None, {"fmt": "wav"})
fout = os.path.join(workdir, "tmp.wav")
argv[argv.index(fout) if fout in argv else len(argv) - 1] = fout
video_ops.run_ffmpeg(argv, timeout=600)
result = audio_ops.run_asr(fout, lang)
body = json.dumps({"code": 200, "message": "ok", "data": result}, ensure_ascii=False).encode("utf-8")
self._reply(200, body, "application/json")
except Exception as e: # noqa: BLE001
self._reply(500, json.dumps({"code": 500, "message": "识别失败: " + str(e)[:200]}, ensure_ascii=False).encode("utf-8"), "application/json")
finally:
if workdir and os.path.isdir(workdir):
shutil.rmtree(workdir, ignore_errors=True)
def do_POST(self):
parsed = parse.urlparse(self.path)
if parsed.path.startswith("/user"):
self._handle_user("POST")
return
if parsed.path == "/tts":
self._handle_tts()
return
if parsed.path == "/asr":
self._handle_asr()
return
if parsed.path == "/video":
self._handle_video()
return
+3
View File
@@ -275,6 +275,9 @@ tools:
title: Image OCR
description: Extract text from images with OCR - click, drag & drop or paste a screenshot, get recognized lines with confidence scores, copy or download as TXT.
audio-tools:
title: 'Audio tools'
description: 'Text to speech, speech to text, voice clone - AI audio toolkit'
video-tools:
title: 'Video tools'
description: 'Video convert, compress, trim, speed, audio extract, GIF convert and more'
+3
View File
@@ -272,6 +272,9 @@ tools:
title: 图片OCR文字识别
description: 上传、拖拽或粘贴截图识别图片中的文字,逐行输出识别结果和置信度,支持复制全部和下载TXT。
audio-tools:
title: '音频工具'
description: '文字转音频(14 种音色)、音频转文字(中英日粤自动检测)、声音克隆等 AI 语音工具'
video-tools:
title: '视频工具'
description: '视频格式转换、压缩、裁剪、变速、提取音频、GIF 互转等 11 个常用视频处理工具,服务端高速处理'
+1
View File
@@ -23,6 +23,7 @@ const groups: { title: string; items: Item[] }[] = [
{ name: 'IT网站收藏', icon: '藏', desc: '内置 91 个精选开发站点(社区/文档/工具/AI/设计/视频/媒体平台),数据存用户本地,可自选目录', tag: '全新' },
{ name: '文档格式转换', icon: '转', desc: 'Word/PDF/TXT/RTF/ODT/EPUB/MOBI/AZW3/HTML 九格式互转,自建 calibre 引擎,批量打包下载', tag: '全新' },
{ name: '视频工具', icon: '视', desc: '格式转换、压缩、裁剪、旋转、变速、消音、提取音频、截图、GIF 互转等 11 个工具,服务端 ffmpeg 高速处理,最大 2GB', tag: '全新' },
{ name: '音频工具', icon: '音', desc: '文字转音频(本地神经音色,离线可用)、音频转文字(中英日粤自动检测,Whisper 引擎)、声音克隆(部署中),全部本地模型不外传', tag: '全新' },
],
},
{
+6
View File
@@ -54,6 +54,12 @@ const FEATURES: Feature[] = [
icon: '🎥',
points: ['格式转换/压缩/裁剪/旋转/变速/消音/提取音频/截图/GIF互转等 11 个工具', '服务端 ffmpeg 高速转码,最大支持 2GB 视频', '处理完在线预览,一键下载结果'],
},
{
path: '/audio-tools',
name: '音频工具',
icon: '🎙️',
points: ['文字转音频:本地神经 TTS,离线可用速度快', '音频转文字:Whisper 引擎,中英日粤自动检测带时间轴', '声音克隆:5 秒样本克隆音色(即将上线)'],
},
{
path: '/label-designer',
name: '面单设计',
+597
View File
@@ -0,0 +1,597 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useHead } from '@vueuse/head';
import { licenseHeaders } from '../license/license';
import GenHistory from '@/tools/gen-history/GenHistory.vue';
import { useGenHistory } from '@/tools/gen-history/gen-history';
useHead({ title: '音频工具 - IT-TOOLS-PRO' });
const genHist = useGenHistory('audio-tools');
// ============ 文字转音频 (TTS) ============
const VOICES = [
{ value: 'zh_CN-huayan-medium', label: '晓妍(女声·标准中文)' },
{ value: 'en_US-amy-medium', label: 'Amy(女声·英语)' },
];
const ttsText = ref('');
const ttsVoice = ref('zh_CN-huayan-medium');
const ttsRate = ref(0);
const ttsPitch = ref(0);
const ttsBusy = ref(false);
const ttsError = ref('');
const ttsUrl = ref('');
const ttsSize = ref(0);
const ttsName = ref('');
async function genTts() {
if (!ttsText.value.trim()) {
ttsError.value = '请输入文字内容';
return;
}
ttsBusy.value = true;
ttsError.value = '';
try {
const res = await fetch('/relay/tts', {
method: 'POST',
headers: { 'Content-Type': 'application/json', ...licenseHeaders() },
body: JSON.stringify({ text: ttsText.value, voice: ttsVoice.value, rate: ttsRate.value, pitch: ttsPitch.value }),
});
if (!res.ok) {
const b = await res.json().catch(() => ({}));
throw new Error(b.message || `合成失败(${res.status})`);
}
const blob = await res.blob();
if (ttsUrl.value) {
URL.revokeObjectURL(ttsUrl.value);
}
ttsUrl.value = URL.createObjectURL(blob);
ttsSize.value = blob.size;
const vn = VOICES.find(v => v.value === ttsVoice.value)?.label ?? '';
ttsName.value = `${vn} · ${ttsText.value.slice(0, 16)}…`;
genHist.add({ title: `TTS: ${ttsText.value.slice(0, 30)}`, detail: `${vn}(${(blob.size / 1024).toFixed(0)}KB)` });
}
catch (e: any) {
ttsError.value = String(e?.message || e);
}
finally {
ttsBusy.value = false;
}
}
function downloadTts() {
const a = document.createElement('a');
a.href = ttsUrl.value;
a.download = '语音合成.mp3';
a.click();
}
// ============ 音频转文字 (ASR) ============
const asrFile = ref<File | null>(null);
const asrInput = ref<HTMLInputElement>();
const asrLang = ref('');
const asrBusy = ref(false);
const asrError = ref('');
const asrText = ref('');
const asrSegments = ref<{ start: number; end: number; text: string }[]>([]);
const asrLangDetected = ref('');
const asrCopied = ref(false);
const asrSpent = ref(0);
function pickAsr() {
asrInput.value?.click();
}
function onAsrFile(e: Event) {
const input = e.target as HTMLInputElement;
asrFile.value = input.files?.[0] ?? null;
input.value = '';
asrText.value = '';
asrSegments.value = [];
}
function onAsrDrop(e: DragEvent) {
asrFile.value = e.dataTransfer?.files?.[0] ?? null;
asrText.value = '';
asrSegments.value = [];
}
function fmtTime(s: number) {
const m = Math.floor(s / 60);
const sec = (s % 60).toFixed(1);
return `${m}:${Number(sec) < 10 ? '0' : ''}${sec}`;
}
async function runAsr() {
if (!asrFile.value) {
asrError.value = '请先选择音频文件';
return;
}
asrBusy.value = true;
asrError.value = '';
const t0 = Date.now();
try {
const fd = new FormData();
fd.append('file', asrFile.value);
fd.append('language', asrLang.value);
const res = await fetch('/relay/asr', { method: 'POST', body: fd, headers: licenseHeaders() });
const b = await res.json().catch(() => ({}));
if (!res.ok) {
throw new Error(b.message || `识别失败(${res.status})`);
}
asrText.value = b.data?.text ?? '';
asrSegments.value = b.data?.segments ?? [];
asrLangDetected.value = b.data?.language ?? '';
asrSpent.value = Math.round((Date.now() - t0) / 1000);
genHist.add({ title: `语音识别: ${asrFile.value.name}`, detail: `${asrText.value.slice(0, 40)}…(${asrSpent.value}s)` });
}
catch (e: any) {
asrError.value = String(e?.message || e);
}
finally {
asrBusy.value = false;
}
}
async function copyAsr() {
try {
await navigator.clipboard.writeText(asrText.value);
asrCopied.value = true;
setTimeout(() => (asrCopied.value = false), 1500);
}
catch { /* ignore */ }
}
// ============ tabs ============
type TabId = 'tts' | 'asr' | 'clone';
const tab = ref<TabId>('tts');
const TABS: { id: TabId; name: string; icon: string; desc: string; status?: string }[] = [
{ id: 'tts', name: '文字转音频', icon: '🔊', desc: '输入文字一键生成语音,本地神经音色(中文/英语),语速可调' },
{ id: 'asr', name: '音频转文字', icon: '📝', desc: '上传音频/视频自动识别文字,中英日粤自动检测' },
{ id: 'clone', name: '声音克隆', icon: '🎭', desc: '上传几秒参考音频即可克隆音色朗读任意文本' },
];
const tabDesc = computed(() => TABS.find(t => t.id === tab.value)?.desc ?? '');
</script>
<template>
<div class="at-root">
<div class="at-hero">
<div class="at-hero-title">AudioKit · 音频工具箱</div>
<div class="at-hero-sub">
文字转音频、音频转文字、声音克隆——AI 语音三件套,服务端高速处理
</div>
</div>
<!-- tab cards -->
<div class="at-tabs">
<div
v-for="t in TABS"
:key="t.id"
class="at-tab"
:class="{ active: tab === t.id }"
@click="tab = t.id"
>
<span class="at-tab-icon">{{ t.icon }}</span>
<span class="at-tab-name">{{ t.name }}</span>
<span class="at-tab-desc">{{ t.desc }}</span>
</div>
</div>
<!-- TTS panel -->
<div v-if="tab === 'tts'" class="at-panel">
<div class="at-panel-title">
🔊 文字转音频 <span class="at-panel-sub">{{ tabDesc }}</span>
</div>
<textarea v-model="ttsText" class="at-textarea" rows="5" placeholder="输入要转换为语音的文字,最多 2000 字…" />
<div class="at-row">
<div class="at-field">
<label class="at-label">音色</label>
<select v-model="ttsVoice" class="at-select">
<option v-for="v in VOICES" :key="v.value" :value="v.value">{{ v.label }}</option>
</select>
</div>
<div class="at-field">
<label class="at-label">语速 {{ ttsRate > 0 ? '+' : '' }}{{ ttsRate }}%</label>
<input v-model.number="ttsRate" type="range" min="-50" max="100" step="5" class="at-slider">
</div>
</div>
<div class="at-actions">
<button class="at-btn" :disabled="ttsBusy || !ttsText.trim()" @click="genTts">
{{ ttsBusy ? '⏳ 合成中…' : '🚀 生成语音' }}
</button>
</div>
<div v-if="ttsError" class="at-error">{{ ttsError }}</div>
<div v-if="ttsUrl" class="at-result">
<audio :src="ttsUrl" controls class="at-audio" />
<div class="at-result-bar">
<span class="at-result-name">{{ ttsName }}({{ (ttsSize / 1024).toFixed(0) }} KB)</span>
<button class="at-btn at-btn-sm" @click="downloadTts">⬇ 下载 MP3</button>
</div>
</div>
</div>
<!-- ASR panel -->
<div v-if="tab === 'asr'" class="at-panel">
<div class="at-panel-title">
📝 音频转文字 <span class="at-panel-sub">{{ tabDesc }}</span>
</div>
<div class="at-drop" @click="pickAsr" @dragover.prevent @drop.prevent="onAsrDrop">
<input ref="asrInput" type="file" hidden accept="audio/*,.m4a,.wma,.opus,.mp4,.webm" @change="onAsrFile">
<template v-if="!asrFile">
<div class="at-drop-hint">📁 点击选择或拖拽音频/视频文件(最大 30MB)</div>
<div class="at-drop-sub">支持 MP3 / WAV / M4A / OGG / FLAC / AAC / MP4 / WEBM</div>
</template>
<div v-else class="at-file">
🎧 {{ asrFile.name }} <span class="at-file-size">({{ (asrFile.size / 1024 / 1024).toFixed(1) }} MB)</span>
<a href="javascript:;" class="at-clear" @click.stop="asrFile = null">✕ 换一个</a>
</div>
</div>
<div class="at-row">
<div class="at-field">
<label class="at-label">识别语言</label>
<select v-model="asrLang" class="at-select">
<option value="">自动检测</option>
<option value="zh">中文</option>
<option value="en">英语</option>
<option value="ja">日语</option>
<option value="yue">粤语</option>
</select>
</div>
</div>
<div class="at-actions">
<button class="at-btn" :disabled="asrBusy || !asrFile" @click="runAsr">
{{ asrBusy ? '⏳ 识别中(音频越长耗时越久)…' : '🚀 开始识别' }}
</button>
</div>
<div v-if="asrError" class="at-error">{{ asrError }}</div>
<div v-if="asrText" class="at-result">
<div class="at-result-bar">
<span class="at-result-name">
识别结果({{ asrSegments.length }} 段 · 检测语言 {{ asrLangDetected }} · 用时 {{ asrSpent }}s)
</span>
<button class="at-btn at-btn-sm" @click="copyAsr">{{ asrCopied ? '已复制 ✓' : '复制全文' }}</button>
</div>
<div class="at-asr-text">{{ asrText }}</div>
<div v-if="asrSegments.length" class="at-segments">
<div v-for="(s, i) in asrSegments.slice(0, 50)" :key="i" class="at-seg">
<span class="at-seg-time">{{ fmtTime(s.start) }}</span>
<span class="at-seg-text">{{ s.text }}</span>
</div>
</div>
</div>
</div>
<!-- clone panel -->
<div v-if="tab === 'clone'" class="at-panel">
<div class="at-panel-title">
🎭 声音克隆 <span class="at-panel-sub">{{ tabDesc }}</span>
</div>
<div class="at-soon">
<div class="at-soon-icon">🔧</div>
<div class="at-soon-title">声音克隆功能部署中,即将上线</div>
<div class="at-soon-desc">
基于 GPT-SoVITS 本地大模型:上传 5-10 秒参考音频即可克隆音色,让 AI 用你的声音朗读任意文本。
模型部署完成后本页面自动开放,无需更新站点。
</div>
<div class="at-soon-tips">
<div>✓ 支持中文零样本克隆(5 秒样本)</div>
<div>✓ 克隆音色可保存复用</div>
<div>✓ 本地模型推理,参考音频不外传</div>
</div>
</div>
</div>
<GenHistory tool="audio-tools" label="音频处理记录" class="mt-20px" />
</div>
</template>
<style lang="less" scoped>
.at-root {
max-width: 900px;
margin: 0 auto;
padding-bottom: 60px;
}
.at-hero {
text-align: center;
margin: 10px 0 22px;
.at-hero-title {
font-size: 24px;
font-weight: 800;
background: linear-gradient(48deg, #25636c 0%, #3b956f 55%, #14a058 100%);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.at-hero-sub {
margin-top: 8px;
font-size: 13px;
opacity: 0.6;
}
}
.at-tabs {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
margin-bottom: 16px;
.at-tab {
border: 1px solid rgba(128, 128, 128, 0.22);
border-radius: 12px;
padding: 12px 14px;
cursor: pointer;
transition: border-color 0.15s, box-shadow 0.15s;
display: flex;
flex-direction: column;
gap: 3px;
&:hover {
border-color: rgba(24, 160, 88, 0.5);
}
&.active {
border-color: #18a058;
box-shadow: 0 0 0 1px #18a058;
}
.at-tab-icon {
font-size: 22px;
}
.at-tab-name {
font-size: 14.5px;
font-weight: 700;
}
.at-tab-desc {
font-size: 11.5px;
opacity: 0.55;
line-height: 1.55;
}
}
}
.at-panel {
border: 1.5px solid rgba(24, 160, 88, 0.4);
border-radius: 14px;
padding: 18px 20px;
background: rgba(24, 160, 88, 0.03);
.at-panel-title {
font-size: 16px;
font-weight: 800;
margin-bottom: 12px;
.at-panel-sub {
font-size: 12px;
font-weight: 400;
opacity: 0.55;
margin-left: 8px;
}
}
}
.at-textarea {
width: 100%;
box-sizing: border-box;
border: 1px solid rgba(128, 128, 128, 0.35);
border-radius: 9px;
padding: 10px 12px;
font-size: 14px;
font-family: inherit;
resize: vertical;
outline: none;
margin-bottom: 12px;
&:focus {
border-color: #18a058;
}
}
.at-row {
display: flex;
gap: 18px;
flex-wrap: wrap;
margin-bottom: 12px;
.at-field {
min-width: 180px;
flex: 1;
.at-label {
display: block;
font-size: 12px;
opacity: 0.65;
margin-bottom: 4px;
}
.at-select {
width: 100%;
box-sizing: border-box;
border: 1px solid rgba(128, 128, 128, 0.35);
border-radius: 7px;
padding: 6px 10px;
font-size: 13px;
background: #fff;
outline: none;
}
.at-slider {
width: 100%;
}
}
}
.at-drop {
border: 1.5px dashed rgba(128, 128, 128, 0.4);
border-radius: 10px;
text-align: center;
padding: 16px;
cursor: pointer;
margin-bottom: 12px;
transition: border-color 0.15s;
&:hover {
border-color: #18a058;
}
.at-drop-hint {
font-size: 13.5px;
font-weight: 600;
}
.at-drop-sub {
font-size: 11.5px;
opacity: 0.5;
margin-top: 4px;
}
.at-file {
font-size: 13.5px;
font-weight: 600;
.at-file-size {
font-weight: 400;
opacity: 0.55;
}
.at-clear {
color: #d03050;
margin-left: 12px;
text-decoration: none;
font-weight: 400;
}
}
}
.at-actions {
margin-bottom: 6px;
}
.at-btn {
background: #18a058;
color: #fff;
border: none;
border-radius: 9px;
padding: 9px 26px;
font-size: 14px;
font-weight: 700;
cursor: pointer;
&:hover:not(:disabled) {
opacity: 0.85;
}
&:disabled {
opacity: 0.45;
cursor: not-allowed;
}
&.at-btn-sm {
padding: 6px 16px;
font-size: 12.5px;
}
}
.at-error {
color: #d03050;
font-size: 12.5px;
margin-top: 8px;
}
.at-result {
margin-top: 14px;
.at-audio {
width: 100%;
}
.at-result-bar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-top: 8px;
flex-wrap: wrap;
.at-result-name {
font-size: 12.5px;
opacity: 0.7;
}
}
.at-asr-text {
background: rgba(128, 128, 128, 0.07);
border-radius: 9px;
padding: 12px 14px;
font-size: 13.5px;
line-height: 1.9;
white-space: pre-wrap;
margin-top: 10px;
}
.at-segments {
margin-top: 10px;
max-height: 240px;
overflow: auto;
border: 1px solid rgba(128, 128, 128, 0.18);
border-radius: 9px;
padding: 8px 12px;
.at-seg {
display: flex;
gap: 10px;
font-size: 12.5px;
padding: 3px 0;
.at-seg-time {
color: #18a058;
font-weight: 600;
flex-shrink: 0;
font-variant-numeric: tabular-nums;
}
.at-seg-text {
opacity: 0.85;
}
}
}
}
.at-soon {
text-align: center;
padding: 24px 10px;
.at-soon-icon {
font-size: 34px;
margin-bottom: 8px;
}
.at-soon-title {
font-size: 16px;
font-weight: 800;
margin-bottom: 8px;
}
.at-soon-desc {
font-size: 13px;
opacity: 0.65;
line-height: 1.8;
max-width: 480px;
margin: 0 auto 14px;
}
.at-soon-tips {
display: inline-block;
text-align: left;
font-size: 12.5px;
opacity: 0.75;
line-height: 2;
}
}
</style>
+12
View File
@@ -0,0 +1,12 @@
import { Microphone2 } from '@vicons/tabler';
import { defineTool } from '../tool';
import { translate } from '@/plugins/i18n.plugin';
export const tool = defineTool({
name: translate('tools.audio-tools.title'),
path: '/audio-tools',
description: translate('tools.audio-tools.description'),
keywords: ['audio', 'tts', 'speech', 'voice', 'asr', 'transcribe', 'clone', '语音', '文字转语音', '音频转文字', '声音克隆', '识别'],
component: () => import('./audio-tools.vue'),
icon: Microphone2,
});
+2 -1
View File
@@ -82,6 +82,7 @@ import { tool as pdfOcr } from './pdf-ocr';
import { tool as pdfTools } from './pdf-tools';
import { tool as imageTools } from './image-tools';
import { tool as videoTools } from './video-tools';
import { tool as audioTools } from './audio-tools';
import { tool as docConvert } from './doc-convert';
import { tool as aiRetouch } from './ai-retouch';
import { tool as wifiQrCodeGenerator } from './wifi-qr-code-generator';
@@ -153,7 +154,7 @@ export const toolsByCategory: ToolCategory[] = [
},
{
name: 'Images and videos',
components: [qrCodeGenerator, wifiQrCodeGenerator, batchBarcodeGenerator, codeReader, imageOcr, pdfOcr, pdfTools, imageTools, videoTools, docConvert, aiRetouch, labelDesigner, siteBookmarks, svgPlaceholderGenerator, cameraRecorder],
components: [qrCodeGenerator, wifiQrCodeGenerator, batchBarcodeGenerator, codeReader, imageOcr, pdfOcr, pdfTools, imageTools, videoTools, audioTools, docConvert, aiRetouch, labelDesigner, siteBookmarks, svgPlaceholderGenerator, cameraRecorder],
},
{
name: 'Development',
+1
View File
@@ -15,6 +15,7 @@ export const PROTECTED_TOOLS: Record<string, string> = {
'/image-tools': '图片工具',
'/pdf-tools': 'PDF工具',
'/video-tools': '视频工具',
'/audio-tools': '音频工具',
};
export const TRIAL_MS = 30 * 60 * 1000; // 每个功能免费 30 分钟