{"id":4867,"date":"2025-08-08T20:04:41","date_gmt":"2025-08-08T11:04:41","guid":{"rendered":"https:\/\/eternalsphere.net\/echoes\/?p=4867"},"modified":"2025-08-08T20:04:41","modified_gmt":"2025-08-08T11:04:41","slug":"1gnmdlgjomr3zqs","status":"publish","type":"post","link":"https:\/\/eternalsphere.net\/echoes\/index.php\/2025\/08\/08\/1gnmdlgjomr3zqs\/","title":{"rendered":"\u57fa\u4e8e Ubuntu Server \u7684\u79c1\u6709\u5316\u9ad8\u7cbe\u5ea6\u8bed\u97f3\u8f6c\u5199\u670d\u52a1\u642d\u5efa\uff08\u4e24\u6309\u94ae\u6781\u7b80\u7248\uff09"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u76ee\u6807\uff1a\u5728\u4e00\u53f0 Ubuntu Server + RTX 2080 \u7684\u73af\u5883\u4e2d\uff0c\u90e8\u7f72\u57fa\u4e8e Whisper <code>large-v2<\/code> \u7684\u8bed\u97f3\u8f6c\u5199\u670d\u52a1\uff0c\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\uff0c\u4ec5\u4fdd\u7559\u4e24\u79cd\u4ea4\u4e92\u6a21\u5f0f\uff1a<br>1\uff09<strong>\u4e00\u4e2a\u6309\u94ae<\/strong>\uff1a\u70b9\u51fb\u5f00\u59cb\u5f55\u97f3\uff1b\u518d\u6b21\u70b9\u51fb\u81ea\u52a8\u505c\u6b62\u5e76\u4e0a\u4f20\u8bc6\u522b\u3002<br>2\uff09<strong>\u4e00\u4e2a\u6309\u94ae<\/strong>\uff1a\u4e0a\u4f20\u672c\u5730\u97f3\u9891\u6587\u4ef6\u8bc6\u522b\u3002<br>\u8bbe\u8ba1\u91cd\u70b9\uff1a<strong>\u9ad8\u51c6\u786e\u7387\u3001\u6574\u6bb5\u8bc6\u522b\u3001\u79c1\u6709\u90e8\u7f72\u3001\u65e0\u5916\u7f51\u4f9d\u8d56\u3001\u6700\u5c11\u4ea4\u4e92\u63a7\u4ef6<\/strong>\u3002<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">1. \u67b6\u6784\u4e0e\u5de5\u4f5c\u6d41<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1.1 \u67b6\u6784\u6982\u89c8<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u524d\u7aef\uff08\u6d4f\u89c8\u5668\uff09<\/strong>\uff1a\u7eaf HTML + \u539f\u751f JavaScript\u3002\n<ul class=\"wp-block-list\">\n<li>\u6309\u94ae A\uff1a\u5f55\u97f3\u201c\u5207\u6362\u952e\u201d\uff08toggle\uff09\uff1a\u7b2c\u4e00\u6b21\u70b9\u51fb\u5f00\u59cb\u5f55\u97f3\uff0c\u7b2c\u4e8c\u6b21\u70b9\u51fb\u505c\u6b62\u5e76\u81ea\u52a8\u4e0a\u4f20\u3002<\/li>\n\n\n\n<li>\u6309\u94ae B\uff1a\u6587\u4ef6\u9009\u62e9\u5668\uff1a\u4e0a\u4f20\u672c\u5730\u97f3\u9891\u8fdb\u884c\u8bc6\u522b\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u540e\u7aef\uff08Ubuntu Server\uff09<\/strong>\uff1aFastAPI \u63d0\u4f9b\u63a5\u53e3\uff1b<code>faster-whisper<\/code> \u8c03\u7528 Whisper <code>large-v2<\/code> \u8fdb\u884c\u8f6c\u5199\uff1bFFmpeg \u7528\u4e8e\u97f3\u9891\u8f6c\u7801\u3002<\/li>\n\n\n\n<li><strong>GPU \u63a8\u7406<\/strong>\uff1aRTX 2080\uff088GB\uff09+ FP16 \u7cbe\u5ea6\uff1b\u53ea\u8fd0\u884c\u5355\u4e00\u670d\u52a1\uff0c\u65e0\u684c\u9762\u73af\u5883\u5360\u7528\u663e\u5b58\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">1.2 \u5de5\u4f5c\u8fc7\u7a0b\uff08\u4e0e\u9700\u6c42\u5bf9\u9f50\uff09<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6a21\u5f0f\u4e00\uff1a\u5f55\u97f3\u8bc6\u522b<\/strong><br>\u70b9\u51fb\u6309\u94ae\u5f00\u59cb\u5f55\u97f3 \u2192 \u81ea\u7136\u8868\u8fbe\uff08\u4e2d\u9014\u505c\u987f\u4e0d\u89e6\u53d1\u5207\u5206\uff09\u2192 \u518d\u6b21\u70b9\u51fb\u7ed3\u675f \u2192 \u4e00\u6b21\u6027\u4e0a\u4f20\u6574\u6bb5\u97f3\u9891 \u2192 \u540e\u7aef\u8f6c\u5199 \u2192 \u8fd4\u56de\u5b8c\u6574\u6587\u672c\uff08\u542b\u81ea\u52a8\u65ad\u53e5\u4e0e\u6807\u70b9\uff09\u3002<\/li>\n\n\n\n<li><strong>\u6a21\u5f0f\u4e8c\uff1a\u6587\u4ef6\u8bc6\u522b<\/strong><br>\u9009\u62e9\u672c\u5730\u97f3\u9891 \u2192 \u4e0a\u4f20 \u2192 \u540e\u7aef\u8f6c\u5199 \u2192 \u8fd4\u56de\u5b8c\u6574\u6587\u672c\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">2. \u73af\u5883\u51c6\u5907<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">2.1 \u7cfb\u7edf\u4e0e\u9a71\u52a8\uff08Ubuntu 20.04\/22.04\/24.04 \u7686\u53ef\uff09<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt -y upgrade\nsudo apt -y install build-essential pkg-config git curl wget unzip ffmpeg python3 python3-venv python3-pip\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2.2 NVIDIA \u9a71\u52a8\u4e0e CUDA\uff08RTX 2080 \/ Turing\uff09<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u63a8\u8350\u5b89\u88c5\u5b98\u65b9\u9a71\u52a8\uff08525+\uff09\uff0cCUDA 11\/12 \u4efb\u4e00\u7248\u672c\u5747\u53ef\uff1b\u672c\u9879\u76ee\u53ea\u9700\u901a\u8fc7 PyTorch\/CTranslate2 \u4f7f\u7528 CUDA\uff0c\u4e0d\u5f3a\u4f9d\u8d56\u7279\u5b9a CUDA \u7248\u672c\u3002<\/li>\n\n\n\n<li>\u9a71\u52a8\u5b89\u88c5\u7565\uff08\u6309\u4f01\u4e1a\u65e2\u6709\u6d41\u7a0b\u6216\u53d1\u884c\u7248\u63a8\u8350\u65b9\u5f0f\uff09\uff1b\u5b89\u88c5\u5b8c\u6210\u540e\u9a8c\u8bc1\uff1a<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>nvidia-smi\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u51fa\u73b0\u663e\u5361\u4e0e\u9a71\u52a8\u4fe1\u606f\u5373\u4e3a\u6b63\u5e38\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u9879\u76ee\u7ed3\u6784<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>whisper_tool\/\n\u251c\u2500\u2500 app.py                # FastAPI \u5165\u53e3\n\u251c\u2500\u2500 transcribe.py         # \u8f6c\u5199\u903b\u8f91\uff08faster-whisper \u5c01\u88c5\uff09\n\u251c\u2500\u2500 static\/\n\u2502   \u2514\u2500\u2500 index.html        # \u524d\u7aef\u9875\u9762\uff08\u4e24\u6309\u94ae\uff09\n\u251c\u2500\u2500 uploads\/              # \u4e34\u65f6\u97f3\u9891\u4fdd\u5b58\n\u2514\u2500\u2500 requirements.txt      # Python \u4f9d\u8d56\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">4. Python \u4f9d\u8d56\u4e0e\u6a21\u578b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">4.1 \u521b\u5efa\u865a\u62df\u73af\u5883\u5e76\u5b89\u88c5\u4f9d\u8d56<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/opt\nsudo mkdir -p whisper_tool &amp;&amp; sudo chown $USER:$USER whisper_tool\ncd whisper_tool\n\npython3 -m venv venv\nsource venv\/bin\/activate\n\ncat &gt; requirements.txt &lt;&lt; 'EOF'\nfastapi==0.110.0\nuvicorn&#091;standard]==0.29.0\npydub==0.25.1\nfaster-whisper==1.0.0\npython-multipart==0.0.9\nEOF\n\npip install -U pip\npip install -r requirements.txt\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4.2 \u8bf4\u660e\uff1a\u4e3a\u4f55\u9009\u62e9 <code>faster-whisper<\/code><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528\u76f8\u540c\u7684 Whisper \u6743\u91cd\uff08<code>large-v2<\/code>\uff09\uff0c\u8f6c\u5199\u51c6\u786e\u7387\u4e0e\u539f\u751f\u57fa\u672c\u4e00\u81f4\u3002<\/li>\n\n\n\n<li>FP16 \u4e0b\u663e\u5b58\u5360\u7528\u66f4\u4f4e\uff0c<strong>RTX 2080\uff088GB\uff09\u53ef\u7a33\u5b9a\u8fd0\u884c <code>large-v2<\/code><\/strong>\u3002<\/li>\n\n\n\n<li>\u63a8\u7406\u901f\u5ea6\u4e0e\u8d44\u6e90\u4f7f\u7528\u66f4\u4f18\uff0c\u9002\u5408\u65e0\u684c\u9762\u670d\u52a1\u7aef\u957f\u671f\u8fd0\u884c\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">5. \u540e\u7aef\u4ee3\u7801<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">5.1 <code>transcribe.py<\/code><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># transcribe.py\nimport os\nimport uuid\nfrom faster_whisper import WhisperModel\n\n# \u8fd0\u884c\u53c2\u6570\uff1a\u4e2d\u6587\u53ef\u663e\u5f0f\u6307\u5b9a language=\"zh\"\uff1b\u6df7\u5408\u573a\u666f\u53ef\u7701\u7565\u8bed\u8a00\u81ea\u52a8\u8bc6\u522b\nMODEL_NAME = \"large-v2\"\nCOMPUTE_TYPE = \"float16\"   # \u5728 RTX 2080 \u4e0a\u4f7f\u7528 FP16 \u8282\u7701\u663e\u5b58\nBEAM_SIZE = 5              # \u63d0\u5347\u51c6\u786e\u7387\uff08\u76f8\u5bf9\u901f\u5ea6\u6298\u4e2d\uff09\nLANGUAGE = None            # \u6307\u5b9a \"zh\" \u6216 None(\u81ea\u52a8)\uff1b\u6309\u9700\u4fee\u6539\n\n# \u6a21\u578b\u5e38\u9a7b\u5185\u5b58\uff0c\u907f\u514d\u91cd\u590d\u52a0\u8f7d\nmodel = WhisperModel(MODEL_NAME, compute_type=COMPUTE_TYPE)\n\nUPLOAD_DIR = os.path.join(os.path.dirname(__file__), \"uploads\")\nos.makedirs(UPLOAD_DIR, exist_ok=True)\n\ndef run_transcribe(file_path: str):\n    # \u8fd9\u91cc\u4e0d\u505a\u7ec6\u788e\u5207\u5206\uff0c\u6574\u6bb5\u8bc6\u522b\uff0c\u5145\u5206\u5229\u7528\u4e0a\u4e0b\u6587\uff0c\u83b7\u5f97\u66f4\u81ea\u7136\u7684\u65ad\u53e5\u548c\u6807\u70b9\n    segments, info = model.transcribe(\n        file_path,\n        beam_size=BEAM_SIZE,\n        language=LANGUAGE,\n        vad_filter=False   # \u6ee1\u8db3\u201c\u6574\u6bb5\u4e0a\u4f20\u6574\u6bb5\u8bc6\u522b\u201d\u7684\u8bc9\u6c42\uff1b\u82e5\u9700\u989d\u5916\u7a33\u5065\u53ef True\n    )\n    text = \"\".join(seg.text for seg in segments)\n    return {\n        \"text\": text.strip(),\n        \"duration\": getattr(info, \"duration\", None),\n        \"language\": getattr(info, \"language\", None),\n    }\n\ndef make_temp_path(suffix=\".wav\"):\n    return os.path.join(UPLOAD_DIR, f\"{uuid.uuid4().hex}{suffix}\")\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5.2 <code>app.py<\/code><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># app.py\nimport os\nimport shutil\nimport subprocess\nfrom fastapi import FastAPI, UploadFile, Response\nfrom fastapi.staticfiles import StaticFiles\nfrom fastapi.middleware.cors import CORSMiddleware\nfrom transcribe import run_transcribe, make_temp_path\n\napp = FastAPI(title=\"Whisper Tool (Two-Button Edition)\")\n\n# \u5982\u9700\u8de8\u57df\uff0c\u6309\u9700\u914d\u7f6e\u5141\u8bb8\u7684\u6765\u6e90\napp.add_middleware(\n    CORSMiddleware,\n    allow_origins=&#091;\"*\"],  # \u5185\u7f51\u6216\u53d7\u63a7\u73af\u5883\u53ef\u653e\u5f00\uff1b\u516c\u7f51\u5efa\u8bae\u9650\u5236\u5177\u4f53\u57df\u540d\n    allow_credentials=True,\n    allow_methods=&#091;\"*\"],\n    allow_headers=&#091;\"*\"],\n)\n\n# \u9759\u6001\u9875\u9762\nSTATIC_DIR = os.path.join(os.path.dirname(__file__), \"static\")\napp.mount(\"\/\", StaticFiles(directory=STATIC_DIR, html=True), name=\"static\")\n\n# \u7b80\u5355\u7684\u8f6c\u7801\u51fd\u6570\uff1a\u786e\u4fdd\u7edf\u4e00\u4e3a wav \/ pcm_s16le\uff0c\u4fbf\u4e8e\u6a21\u578b\u89e3\u6790\ndef ensure_wav(input_path: str) -&gt; str:\n    if input_path.lower().endswith(\".wav\"):\n        return input_path\n    out_path = input_path.rsplit(\".\", 1)&#091;0] + \".wav\"\n    cmd = &#091;\n        \"ffmpeg\", \"-y\", \"-i\", input_path,\n        \"-ar\", \"16000\", \"-ac\", \"1\", \"-c:a\", \"pcm_s16le\", out_path\n    ]\n    subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)\n    return out_path\n\n@app.post(\"\/api\/transcribe\/record\")\nasync def transcribe_record(file: UploadFile):\n    # \u5f55\u97f3\u6a21\u5f0f\u4e0a\u4f20\u7684 Blob\uff08webm \/ mp3 \/ wav \u7b49\uff09\n    raw_path = make_temp_path(\".\" + (file.filename.split(\".\")&#091;-1] if \".\" in file.filename else \"webm\"))\n    with open(raw_path, \"wb\") as f:\n        shutil.copyfileobj(file.file, f)\n    wav_path = ensure_wav(raw_path)\n    result = run_transcribe(wav_path)\n    # \u6e05\u7406\u4e34\u65f6\u6587\u4ef6\uff08\u6309\u9700\u4fdd\u7559\u4ee5\u4fbf\u5ba1\u8ba1\/\u6392\u9519\uff09\n    for p in {raw_path, wav_path}:\n        try:\n            if os.path.exists(p):\n                os.remove(p)\n        except Exception:\n            pass\n    return result\n\n@app.post(\"\/api\/transcribe\/upload\")\nasync def transcribe_upload(file: UploadFile):\n    # \u672c\u5730\u97f3\u9891\u6587\u4ef6\u8bc6\u522b\n    raw_path = make_temp_path(\".\" + (file.filename.split(\".\")&#091;-1] if \".\" in file.filename else \"bin\"))\n    with open(raw_path, \"wb\") as f:\n        shutil.copyfileobj(file.file, f)\n    wav_path = ensure_wav(raw_path)\n    result = run_transcribe(wav_path)\n    for p in {raw_path, wav_path}:\n        try:\n            if os.path.exists(p):\n                os.remove(p)\n        except Exception:\n            pass\n    return result\n\n@app.get(\"\/healthz\")\ndef healthz():\n    return {\"ok\": True}\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">6. \u524d\u7aef\u9875\u9762\uff08\u4e24\u6309\u94ae\u6781\u7b80 UI\uff09<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">6.1 <code>static\/index.html<\/code><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"zh\"&gt;\n&lt;head&gt;\n  &lt;meta charset=\"utf-8\" \/&gt;\n  &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" \/&gt;\n  &lt;title&gt;\u8bed\u97f3\u8f6c\u5199\uff08\u4e24\u6309\u94ae\u7248\uff09&lt;\/title&gt;\n  &lt;style&gt;\n    body { font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; margin: 24px; }\n    .btn { padding: 10px 16px; margin-right: 12px; cursor: pointer; border: 1px solid #333; border-radius: 6px; }\n    .btn.rec { background: #f2f2f2; }\n    .btn.upload { background: #e8f5ff; }\n    #result { white-space: pre-wrap; margin-top: 16px; padding: 12px; border: 1px dashed #aaa; border-radius: 6px; min-height: 120px; }\n    #status { margin-top: 8px; color: #555; }\n  &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n  &lt;h2&gt;\u8bed\u97f3\u8f6c\u5199\uff08\u4e24\u6309\u94ae\u7248\uff09&lt;\/h2&gt;\n\n  &lt;button id=\"recBtn\" class=\"btn rec\"&gt;\ud83c\udfa4 \u70b9\u51fb\u5f00\u59cb\u5f55\u97f3&lt;\/button&gt;\n  &lt;label class=\"btn upload\"&gt;\n    \ud83d\udcc1 \u9009\u62e9\u97f3\u9891\u6587\u4ef6\n    &lt;input id=\"fileInput\" type=\"file\" accept=\"audio\/*\" style=\"display:none;\" \/&gt;\n  &lt;\/label&gt;\n\n  &lt;div id=\"status\"&gt;\u72b6\u6001\uff1a\u7a7a\u95f2&lt;\/div&gt;\n  &lt;div id=\"result\" placeholder=\"\u8bc6\u522b\u7ed3\u679c\u5c06\u5728\u6b64\u663e\u793a\u2026\"&gt;&lt;\/div&gt;\n\n  &lt;script&gt;\n    const recBtn = document.getElementById('recBtn');\n    const fileInput = document.getElementById('fileInput');\n    const statusEl = document.getElementById('status');\n    const resultEl = document.getElementById('result');\n\n    let mediaRecorder;\n    let chunks = &#091;];\n    let recording = false;\n\n    \/\/ \u5207\u6362\u5f55\u97f3\uff1a\u7b2c\u4e00\u6b21\u70b9\u51fb\u5f00\u59cb\uff1b\u7b2c\u4e8c\u6b21\u70b9\u51fb\u505c\u6b62\u5e76\u4e0a\u4f20\n    recBtn.addEventListener('click', async () =&gt; {\n      if (!recording) {\n        try {\n          const stream = await navigator.mediaDevices.getUserMedia({ audio: true });\n          mediaRecorder = new MediaRecorder(stream, { mimeType: 'audio\/webm' });\n          chunks = &#091;];\n          mediaRecorder.ondataavailable = e =&gt; { if (e.data.size &gt; 0) chunks.push(e.data); };\n          mediaRecorder.onstop = async () =&gt; {\n            const blob = new Blob(chunks, { type: 'audio\/webm' });\n            await uploadBlob(blob, '\/api\/transcribe\/record');\n          };\n          mediaRecorder.start();\n          recording = true;\n          recBtn.textContent = '\u23f9\ufe0f \u70b9\u51fb\u505c\u6b62\u5e76\u4e0a\u4f20';\n          statusEl.textContent = '\u72b6\u6001\uff1a\u5f55\u97f3\u4e2d\u2026';\n        } catch (err) {\n          statusEl.textContent = '\u72b6\u6001\uff1a\u65e0\u6cd5\u8bbf\u95ee\u9ea6\u514b\u98ce\uff08\u8bf7\u68c0\u67e5\u6743\u9650\u6216\u8bbe\u5907\uff09';\n        }\n      } else {\n        mediaRecorder.stop();\n        recording = false;\n        recBtn.textContent = '\ud83c\udfa4 \u70b9\u51fb\u5f00\u59cb\u5f55\u97f3';\n        statusEl.textContent = '\u72b6\u6001\uff1a\u5904\u7406\u4e2d\u2026';\n      }\n    });\n\n    \/\/ \u6587\u4ef6\u4e0a\u4f20\u8bc6\u522b\n    fileInput.addEventListener('change', async (e) =&gt; {\n      const file = e.target.files&#091;0];\n      if (!file) return;\n      statusEl.textContent = '\u72b6\u6001\uff1a\u5904\u7406\u4e2d\u2026';\n      await uploadBlob(file, '\/api\/transcribe\/upload');\n      fileInput.value = '';\n    });\n\n    async function uploadBlob(blob, endpoint) {\n      const form = new FormData();\n      form.append('file', blob, 'audio.webm');\n      try {\n        const res = await fetch(endpoint, { method: 'POST', body: form });\n        const data = await res.json();\n        if (data &amp;&amp; data.text !== undefined) {\n          resultEl.textContent += (resultEl.textContent ? '\\n' : '') + '\u25b6 ' + data.text;\n          statusEl.textContent = '\u72b6\u6001\uff1a\u5b8c\u6210';\n        } else {\n          statusEl.textContent = '\u72b6\u6001\uff1a\u89e3\u6790\u5931\u8d25';\n        }\n      } catch (e) {\n        statusEl.textContent = '\u72b6\u6001\uff1a\u4e0a\u4f20\u6216\u8bc6\u522b\u5931\u8d25';\n      }\n    }\n  &lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">7. \u542f\u52a8\u4e0e\u8bbf\u95ee<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">7.1 \u542f\u52a8\u670d\u52a1<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/opt\/whisper_tool\nsource venv\/bin\/activate\nuvicorn app:app --host 0.0.0.0 --port 8000\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6d4f\u89c8\u5668\u8bbf\u95ee\uff1a<code>http:\/\/&lt;\u670d\u52a1\u5668IP&gt;:8000\/<\/code><br>\uff08\u4f8b\u5982\u5185\u7f51 <code>http:\/\/192.168.1.50:8000\/<\/code>\uff09<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">8. \u670d\u52a1\u5e38\u9a7b\u4e0e\u53cd\u5411\u4ee3\u7406\uff08\u53ef\u9009\uff09<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">8.1 \u4f7f\u7528 systemd \u5e38\u9a7b<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tee \/etc\/systemd\/system\/whisper-tool.service &gt;\/dev\/null &lt;&lt;'EOF'\n&#091;Unit]\nDescription=Whisper Tool Service\nAfter=network.target\n\n&#091;Service]\nUser=%i\nWorkingDirectory=\/opt\/whisper_tool\nExecStart=\/opt\/whisper_tool\/venv\/bin\/uvicorn app:app --host 0.0.0.0 --port 8000\nRestart=always\nEnvironment=PYTHONUNBUFFERED=1\n\n&#091;Install]\nWantedBy=multi-user.target\nEOF\n\nsudo systemctl daemon-reload\nsudo systemctl enable whisper-tool\nsudo systemctl start whisper-tool\nsudo systemctl status whisper-tool --no-pager\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u82e5\u4ee5\u6307\u5b9a\u7528\u6237\u8fd0\u884c\uff0c\u5c06 <code>%i<\/code> \u66ff\u6362\u4e3a\u8be5\u7528\u6237\u540d\uff0c\u6216\u76f4\u63a5\u5199 <code>User=youruser<\/code>\u3002<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">8.2 \u53cd\u5411\u4ee3\u7406\u4e0e HTTPS\uff08\u53ef\u9009\uff09<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u751f\u4ea7\u73af\u5883\u53ef\u901a\u8fc7 Nginx\/Caddy \u505a\u53cd\u5411\u4ee3\u7406\u4e0e TLS\uff1b\u4ec5\u5185\u7f51\u4f7f\u7528\u53ef\u5ffd\u7565\u3002<\/li>\n\n\n\n<li>\u82e5\u516c\u7f51\u66b4\u9732\uff0c\u5efa\u8bae\uff1a\n<ul class=\"wp-block-list\">\n<li>\u9650\u5236\u8bbf\u95ee\u6765\u6e90 IP<\/li>\n\n\n\n<li>\u57fa\u672c\u8ba4\u8bc1\u6216\u7b80\u5355\u767b\u5f55\u9875<\/li>\n\n\n\n<li>\u8bf7\u6c42\u4f53\u5927\u5c0f\u9650\u5236\uff08\u9632\u6b62\u8d85\u5927\u6587\u4ef6\u5360\u6ee1\u78c1\u76d8\/\u663e\u5b58\uff09<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">9. \u53c2\u6570\u4e0e\u6027\u80fd\u5efa\u8bae<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6a21\u578b<\/strong>\uff1a<code>large-v2<\/code>\uff08\u6700\u9ad8\u51c6\u786e\u7387\u573a\u666f\uff09<\/li>\n\n\n\n<li><strong>\u7cbe\u5ea6<\/strong>\uff1a<code>float16<\/code>\uff08RTX 2080 \u7684 8GB \u663e\u5b58\u8db3\u591f\uff09<\/li>\n\n\n\n<li><strong>beam_size<\/strong>\uff1a5\uff08\u51c6\u786e\u7387\u4f18\u5148\uff1b\u53ef\u5728 1~5 \u95f4\u8c03\uff09<\/li>\n\n\n\n<li><strong>\u8bed\u8a00<\/strong>\uff1a\u4e2d\u6587\u4e3a\u4e3b\u53ef\u8bbe <code>language=\"zh\"<\/code>\uff1b\u591a\u8bed\u6df7\u5408\u53ef\u8bbe <code>None<\/code>\uff08\u81ea\u52a8\u68c0\u6d4b\uff09\u3002<\/li>\n\n\n\n<li><strong>\u5e76\u53d1<\/strong>\uff1a\u5355 GPU \u4e0b\u5efa\u8bae\u4e32\u884c\u5904\u7406\u6216\u6392\u961f\uff0c\u907f\u514d\u663e\u5b58\u7d27\u5f20\u3002<\/li>\n\n\n\n<li><strong>\u6587\u4ef6\u5927\u5c0f<\/strong>\uff1a\u524d\u7aef\u5f55\u97f3\u5efa\u8bae\u4e0d\u8d85\u8fc7\u6570\u5206\u949f\u4e00\u6bb5\uff1b\u8d85\u957f\u6587\u4ef6\u53ef\u5728\u540e\u7aef\u5206\u6bb5\u5904\u7406\u518d\u62fc\u5408\u6587\u672c\u3002<\/li>\n\n\n\n<li><strong>\u8d44\u6e90\u56de\u6536<\/strong>\uff1a\u4e0a\u4f20\u5904\u7406\u540e\u6e05\u7406\u4e34\u65f6\u6587\u4ef6\u5939\uff0c\u4fdd\u7559\u671f\u4e0e\u5408\u89c4\u7b56\u7565\u89c6\u73af\u5883\u51b3\u5b9a\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">10. \u5b89\u5168\u4e0e\u9690\u79c1\uff08\u79c1\u6709\u90e8\u7f72\u8981\u70b9\uff09<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5168\u7a0b\u672c\u5730\u63a8\u7406\uff0c<strong>\u4e0d\u5c06\u97f3\u9891\u6216\u6587\u672c\u4e0a\u4f20\u7b2c\u4e09\u65b9<\/strong>\u3002<\/li>\n\n\n\n<li>\u9ed8\u8ba4\u4e0d\u843d\u76d8\u4fdd\u5b58\u97f3\u9891\u4e0e\u6587\u672c\uff0c\u4ec5\u505a\u4e34\u65f6\u7f13\u5b58\uff1b\u5982\u9700\u7559\u5b58\uff0c\u5148\u8bc4\u4f30\u5408\u89c4\u4e0e\u914d\u989d\u3002<\/li>\n\n\n\n<li>\u516c\u7f51\u66b4\u9732\u65f6\u52a1\u5fc5\u4e0a HTTPS\u3001\u9274\u6743\u4e0e\u901f\u7387\u9650\u5236\u3002<\/li>\n\n\n\n<li>\u65e5\u5fd7\u4e2d\u4e0d\u8bb0\u5f55\u539f\u59cb\u97f3\u9891\u8def\u5f84\u4e0e\u6587\u672c\u5185\u5bb9\uff08\u6216\u91c7\u7528\u8131\u654f\/\u53ef\u914d\u7f6e\u5f00\u5173\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">11. \u5e38\u89c1\u95ee\u9898\u4e0e\u6392\u969c<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u95ee\u9898<\/th><th>\u5904\u7406\u5efa\u8bae<\/th><\/tr><\/thead><tbody><tr><td><code>CUDA out of memory<\/code><\/td><td>\u786e\u8ba4\u65e0\u684c\u9762\/\u5176\u4ed6\u5360\u7528\uff1b\u4fdd\u6301\u5355\u4efb\u52a1\uff1b\u5fc5\u8981\u65f6\u5c06 <code>beam_size<\/code> \u8c03\u5c0f\u6216\u5207 <code>base\/small\/medium<\/code> \u4e34\u65f6\u6392\u969c\u3002<\/td><\/tr><tr><td>\u4e0a\u4f20 mp3\/webm \u65e0\u6cd5\u8bc6\u522b<\/td><td>\u786e\u4fdd\u5df2\u5b89\u88c5 <code>ffmpeg<\/code>\uff0c\u5e76\u4f7f\u7528\u7edf\u4e00\u8f6c\u7801\u5230 16k \u5355\u58f0\u9053 PCM WAV\u3002<\/td><\/tr><tr><td>\u6d4f\u89c8\u5668\u65e0\u9ea6\u514b\u98ce\u6743\u9650<\/td><td>\u68c0\u67e5 HTTPS\uff08\u90e8\u5206\u6d4f\u89c8\u5668\u5bf9\u975e HTTPS \u7684\u9ea6\u514b\u98ce\u6743\u9650\u66f4\u4e25\u683c\uff09\u6216\u7ad9\u70b9\u6743\u9650\u8bbe\u7f6e\u3002<\/td><\/tr><tr><td>\u7ed3\u679c\u5ef6\u8fdf\u8f83\u957f<\/td><td><code>large-v2<\/code> \u7cbe\u5ea6\u66f4\u9ad8\u4f46\u66f4\u91cd\uff1b\u82e5\u8ffd\u6c42\u66f4\u5feb\u53ef\u6539 <code>medium<\/code>\uff0c\u6216\u4f7f\u7528\u66f4\u5f3a\u663e\u5361\u3002<\/td><\/tr><tr><td>\u4e2d\u82f1\u6587\u6df7\u8bf4\u65ad\u53e5\u4e0d\u7406\u60f3<\/td><td>\u53d6\u6d88\u56fa\u5b9a\u8bed\u8a00\uff0c\u4f7f\u7528\u81ea\u52a8\u8bed\u8a00\u68c0\u6d4b\uff1b\u6216\u542f\u7528 <code>beam_size<\/code>\u3001\u4fdd\u6301\u6574\u6bb5\u8bc6\u522b\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">12. \u6210\u54c1\u7279\u6027\u56de\u987e\uff08\u4e0e\u9700\u6c42\u4e00\u81f4\u6027\uff09<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4e24\u4e2a\u6309\u94ae\uff1a<strong>\u201c\u5f55\u97f3\/\u505c\u6b62\u5e76\u4e0a\u4f20\u201d<\/strong> \u4e0e <strong>\u201c\u4e0a\u4f20\u6587\u4ef6\u8bc6\u522b\u201d<\/strong> \u2705<\/li>\n\n\n\n<li>\u6574\u6bb5\u8bc6\u522b\uff1a\u4e0d\u6309\u79d2\u5207\u5206\uff0c<strong>\u66f4\u81ea\u7136\u7684\u65ad\u53e5\u4e0e\u6807\u70b9<\/strong> \u2705<\/li>\n\n\n\n<li>\u9ad8\u51c6\u786e\u7387\uff1a\u4f7f\u7528 <code>large-v2<\/code> + beam search \u2705<\/li>\n\n\n\n<li>\u79c1\u6709\u90e8\u7f72\uff1aUbuntu Server \u672c\u5730 GPU \u63a8\u7406 \u2705<\/li>\n\n\n\n<li>\u7b80\u5355\u53ef\u7528\uff1a\u7eaf\u9759\u6001\u524d\u7aef + \u7b80\u6d01 API \u2705<\/li>\n\n\n\n<li>\u8131\u654f\u5408\u89c4\uff1a\u4e0d\u4f7f\u7528\u5916\u90e8\u670d\u52a1\uff0c\u4e0d\u8bb0\u5f55\u654f\u611f\u65e5\u5fd7 \u2705<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0a\u6d41\u7a0b\u843d\u5730\u540e\uff0c\u5373\u53ef\u5728\u6d4f\u89c8\u5668\u4fa7\u4ee5<strong>\u6700\u5c11\u7684\u4ea4\u4e92<\/strong>\u5b8c\u6210\u9ad8\u8d28\u91cf\u8bed\u97f3\u8f6c\u5199\uff1a\u70b9\u51fb\u5f00\u59cb\u5f55\u97f3\u2192\u518d\u6b21\u70b9\u51fb\u81ea\u52a8\u4e0a\u4f20\u8bc6\u522b\uff0c\u6216\u76f4\u63a5\u4e0a\u4f20\u672c\u5730\u97f3\u9891\u6587\u4ef6\uff0c\u4e24\u79cd\u6a21\u5f0f\u540c\u65f6\u5177\u5907\uff0c\u6ee1\u8db3\u9ad8\u51c6\u786e\u7387\u4e0e\u5b8c\u6574\u8bed\u4e49\u7684\u6838\u5fc3\u8bc9\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6807\uff1a\u5728\u4e00\u53f0 Ubuntu Server + RTX 2080 \u7684\u73af\u5883\u4e2d\uff0c\u90e8\u7f72\u57fa\u4e8e Whisper large-v2 \u7684\u8bed\u97f3\u8f6c\u5199\u670d\u52a1\uff0c\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\uff0c\u4ec5\u4fdd\u7559\u4e24\u79cd\u4ea4\u4e92\u6a21\u5f0f\uff1a1\uff09\u4e00\u4e2a\u6309\u94ae\uff1a\u70b9\u51fb\u5f00\u59cb\u5f55\u97f3\uff1b\u518d\u6b21\u70b9\u51fb\u81ea\u52a8\u505c\u6b62\u5e76\u4e0a\u4f20\u8bc6\u522b\u30022\uff09\u4e00\u4e2a\u6309\u94ae\uff1a\u4e0a\u4f20\u672c\u5730\u97f3\u9891\u6587\u4ef6\u8bc6\u522b\u3002\u8bbe\u8ba1\u91cd\u70b9\uff1a\u9ad8\u51c6\u786e\u7387\u3001\u6574\u6bb5\u8bc6\u522b\u3001\u79c1\u6709\u90e8\u7f72\u3001\u65e0\u5916\u7f51\u4f9d\u8d56\u3001\u6700\u5c11\u4ea4\u4e92\u63a7\u4ef6\u3002 1. \u67b6\u6784\u4e0e\u5de5\u4f5c\u6d41 1.1 \u67b6\u6784\u6982\u89c8 1.2 \u5de5\u4f5c\u8fc7\u7a0b\uff08\u4e0e\u9700\u6c42\u5bf9\u9f50\uff09 2. \u73af\u5883\u51c6\u5907 2.1 \u7cfb\u7edf\u4e0e\u9a71\u52a8\uff08Ubuntu 20.04\/22.04\/24.04 \u7686\u53ef\uff09 2.2 NVIDIA \u9a71\u52a8\u4e0e CUDA\uff08RTX 2080 \/ Turing\uff09 \u51fa\u73b0\u663e\u5361\u4e0e\u9a71\u52a8\u4fe1\u606f\u5373\u4e3a\u6b63\u5e38\u3002 3. \u9879\u76ee\u7ed3\u6784 4. Python \u4f9d\u8d56\u4e0e\u6a21\u578b 4.1 \u521b\u5efa\u865a\u62df\u73af\u5883\u5e76\u5b89\u88c5\u4f9d\u8d56 4.2 \u8bf4\u660e\uff1a\u4e3a\u4f55\u9009\u62e9 faster-whisper 5. \u540e\u7aef\u4ee3\u7801 5.1 transcribe.py 5.2 app.py 6. \u524d\u7aef\u9875\u9762\uff08\u4e24\u6309\u94ae\u6781\u7b80 UI\uff09 6.1 &hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[88],"tags":[],"class_list":["post-4867","post","type-post","status-publish","format-standard","hentry","category-4brz75t44cdxjqe"],"_links":{"self":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4867","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/comments?post=4867"}],"version-history":[{"count":1,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4867\/revisions"}],"predecessor-version":[{"id":4868,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/posts\/4867\/revisions\/4868"}],"wp:attachment":[{"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/media?parent=4867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/categories?post=4867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eternalsphere.net\/echoes\/index.php\/wp-json\/wp\/v2\/tags?post=4867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}