{"id":143,"date":"2025-09-20T00:43:32","date_gmt":"2025-09-19T16:43:32","guid":{"rendered":"https:\/\/code.lingapi.top\/?p=143"},"modified":"2025-09-20T00:43:33","modified_gmt":"2025-09-19T16:43:33","slug":"%e4%bd%bf%e7%94%a8whispergemini%e4%b8%ba%e5%a4%96%e8%af%ad%e8%a7%86%e9%a2%91%e6%b7%bb%e5%8a%a0%e4%b8%ad%e6%96%87%e5%ad%97%e5%b9%95","status":"publish","type":"post","link":"https:\/\/code.lingapi.top\/?p=143","title":{"rendered":"\u4f7f\u7528Whisper+Gemini\u4e3a\u5916\u8bed\u89c6\u9891\u6dfb\u52a0\u4e2d\u6587\u5b57\u5e55"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">\u5de5\u4f5c\u73af\u5883<\/h1>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Arch Linux\u8ba1\u7b97\u673a<\/li>\n\n\n\n<li>\u5f85\u7ffb\u8bd1mp4\u683c\u5f0f\u89c6\u9891<\/li>\n\n\n\n<li>Gemini api key<\/li>\n\n\n\n<li>NVIDIA\u663e\u5361<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">\u8bc6\u522b\u548c\u63d0\u53d6\u5b57\u5e55<\/h1>\n\n\n\n<p>\u9996\u5148\uff0c\u9700\u8981\u4ece\u89c6\u9891\u6587\u4ef6\u4e2d\uff0c\u5c06\u539f\u59cb\u5b57\u5e55\u63d0\u53d6\u51fa\u6765\u3002\u5982\u679c\u89c6\u9891\u4e2d\u5df2\u7ecf\u5185\u5d4c\u4e86\u5b57\u5e55\uff0c\u90a3\u4e48\u76f4\u63a5\u4f7f\u7528\u5de5\u5177\u63d0\u53d6\u5c31\u662f\u4e86\uff0c\u4f46\u5982\u679c\u6ca1\u6709\uff0c\u5c31\u9700\u8981\u4f7f\u7528AI\u6a21\u578b\u6765\u505a\u8fd9\u4ef6\u4e8b\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u4f7f\u7528\u6765\u81eaOpenAI\u7684<a href=\"https:\/\/github.com\/openai\/whisper\">Whisper<\/a>\u6765\u505a\u8fd9\u4ef6\u4e8b<\/p>\n\n\n\n<p>\u9996\u5148\uff0c\u786e\u4fdd\u5df2\u7ecf\u5b89\u88c5\u5fc5\u5907\u8f6f\u4ef6\u5305\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5b89\u88c5\u57fa\u7840\u4f9d\u8d56\nsudo pacman -S python python-pip ffmpeg git base-devel cmake<\/code><\/pre>\n\n\n\n<p>\u5728Arch Linux\u4e2d\uff0c\u65e0\u6cd5\u4f7f\u7528pip\u5305\u7ba1\u7406\u5668\uff0c\u6240\u4ee5\u9700\u8981\u751f\u6210\u4e00\u4e2apython\u865a\u62df\u73af\u5883\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u6ce8\u610f\uff01\u7531\u4e8eArch Linux\u8f6f\u4ef6\u5305\u8fc7\u65b0\uff0c\u4e00\u4e9b\u4f9d\u8d56\u9879\u5f88\u53ef\u80fd\u8fd8\u6ca1\u6709\u9488\u5bf9\u6700\u65b0\u7684Python\u7248\u672c\u6790\u51fa\u6587\u4ef6\uff0c\u6240\u4ee5\u9700\u8981\u5b89\u88c5Python\u7684\u5386\u53f2\u7248\u672c\uff01<\/p>\n<\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code># \u521b\u5efa\u4e00\u4e2a\u865a\u62dfpython\u73af\u5883\npython -m venv vosk-env\nsource whisper-env\/bin\/activate<\/code><\/pre>\n\n\n\n<p>\u5982\u6b64\u6784\u5efa\u4e00\u4e2a\u865a\u62dfpython\u73af\u5883\uff0c\u5728\u5176\u5185\u90e8\u53ef\u4ee5\u4f7f\u7528pip\u5305\u7ba1\u7406\u5668\u6765\u5b89\u88c5\u6240\u9700\u4f9d\u8d56\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5b89\u88c5 PyTorch with CUDA \u652f\u6301\npip install torch torchvision torchaudio --index-url https:\/\/download.pytorch.org\/whl\/cu121\n\n# \u5b89\u88c5 Whisper\npip install openai-whisper\n\n# \u5b89\u88c5 GPU \u52a0\u901f\u7ec4\u4ef6\npip install faster-whisper<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\uff0c\u5f00\u59cb\u4ece\u89c6\u9891\u6587\u4ef6\u4e2d\u63d0\u53d6\u5b57\u5e55\uff0c\u8fd9\u4e00\u6b65\u9700\u8981\u4f7f\u7528GPU\u52a0\u901f\uff0c\u5426\u5219\u63d0\u53d6\u901f\u5ea6\u4f1a\u975e\u5e38\u611f\u4eba\uff0c\u8fd9\u5c31\u8981\u6c42\u4f60\u5fc5\u987b\u62e5\u6709\u4e00\u5f20NVIDIA\u663e\u5361\uff08\u5fc5\u987b\u662fNVIDIA\uff01\uff09\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>whisper input.mp4 --model medium --output_format srt --output_dir output_dir<\/code><\/pre>\n\n\n\n<p>\u5982\u6b64\uff0c\u5c06\u4f7f\u7528 medium<em> <\/em>\u6a21\u578b\uff0c\u4eceimput.mp4\u4e2d\u63d0\u53d6\u5b57\u5e55\uff0c\u4f5c\u4e3asrt\u683c\u5f0f\u7684\u6587\u4ef6\u8f93\u51fa\u5230output_dir\u4e2d\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u5c06\u4f1a\u7528\u5230NVIDIA\u663e\u5361\u52a0\u901f\u8ba1\u7b97\uff0c\u8981\u6c42\u81f3\u5c11\u62e5\u67095GB\u663e\u5b58\uff0c\u5982\u679c\u4f60\u7684\u663e\u5361\u6ca1\u6709\u8fbe\u5230\u6b64\u8981\u6c42\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u66f4\u4e3a\u8ff7\u4f60\u7684\u6a21\u578b\uff0c\u53c2\u9605<a href=\"https:\/\/github.com\/openai\/whisper?tab=readme-ov-file#available-models-and-languages\">Whisper-models<\/a>\u3002<\/p>\n\n\n\n<p>\u81f3\u6b64\uff0c\u5b57\u5e55\u63d0\u53d6\u5df2\u7ecf\u5b8c\u5168\u7ed3\u675f\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u7ffb\u8bd1<\/h1>\n\n\n\n<p>\u63d0\u53d6\u51fa\u6765\u7684\u5b57\u5e55\u4f9d\u7136\u662f\u770b\u4e0d\u61c2\u7684\u9e1f\u8bed\uff0c\u8fd8\u4e0d\u80fd\u76f4\u63a5\u4f7f\u7528\uff0c\u9700\u8981\u5c06\u5b83\u7ffb\u8bd1\u6210\u4eba\u8bdd\u3002<\/p>\n\n\n\n<p>\u63a8\u8350\u4f7f\u7528<a href=\"https:\/\/github.com\/yazinsai\/srt-ai\">srt-ai<\/a>\u6765\u7ffb\u8bd1\u5b57\u5e55\u6587\u4ef6\uff0c\u8981\u4f7f\u7528srt-ai\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4e00\u4e2aGemini\u7684API\u5bc6\u94a5\uff0c\u6b64\u5904\u4e0d\u505a\u8d58\u8ff0\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/yazinsai\/srt-ai\ncd srt-ai\ncp .env.example .env.local\n# \u5728.env.local\u4e2d\u586b\u5165\u4f60\u7684Gemini API\u5bc6\u94a5\nnpm install\nnpm run dev<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\uff0c\u6253\u5f00\u6d4f\u89c8\u5668\u8bbf\u95eehttp:\/\/localhost:3000\uff0c\u901a\u8fc7Web\u754c\u9762\u4e0a\u4f20SRT\u6587\u4ef6\uff0c\u76ee\u6807\u8bed\u8a00\u9009\u62e9Simplified Chinese\uff0c\u7136\u540e\u5f00\u59cb\u7ffb\u8bd1\u3002\u7ffb\u8bd1\u5b8c\u6210\u540e\uff0cWeb\u5c06\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u7ffb\u8bd1\u597d\u7684\u6587\u4ef6\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u5c01\u88c5\u89c6\u9891<\/h1>\n\n\n\n<p>\u6211\u4eec\u4f7f\u7528ffmpeg\u6765\u5c06\u5b57\u5e55\u5d4c\u5165\u89c6\u9891\u4e2d\uff0c\u603b\u7684\u6765\u8bf4\uff0c\u6709\u4e24\u79cd\u65b9\u6cd5\uff0c\u5206\u4e3a\u786c\u5c01\u88c5\u548c\u8f6f\u5c01\u88c5\u3002<\/p>\n\n\n\n<p>\u786c\u5c01\u88c5\u5c31\u662f\u9010\u5e27\u5904\u7406\u89c6\u9891\uff0c\u5c06\u5b57\u5e55\u786c\u5d4c\u5165\u753b\u9762\u4e2d\uff0c\u597d\u5904\u662f\u517c\u5bb9\u6027\u5f3a\uff0c\u53ea\u8981\u662f\u4e2a\u80fd\u64ad\u653emp4\u7684\u64ad\u653e\u5668\u5c31\u53ef\u4ee5\u770b\u5230\u5b57\u5e55\uff0c\u574f\u5904\u5c31\u662f\u5b57\u5e55\u65e0\u6cd5\u81ea\u7531\u5f00\u5173\uff0c\u800c\u4e14\u5c01\u88c5\u65f6\u95f4\u957f\uff0c\u5c01\u88c5\u540e\u7684\u89c6\u9891\u6587\u4ef6\u5982\u679c\u4e0d\u989d\u5916\u538b\u7f29\u8c03\u4f18\u7684\u8bdd\uff0c\u4f53\u79ef\u4f1a\u66b4\u6da8\u3002<\/p>\n\n\n\n<p>\u8f6f\u5c01\u88c5\u5c31\u662f\u5229\u7528mp4\u683c\u5f0f\u7684\u5b57\u5e55\u8f68\u9053\uff0c\u5c06\u5b57\u5e55\u4fe1\u606f\u653e\u5165\u5b57\u5e55\u8f68\u9053\u4e2d\uff0c\u5728\u64ad\u653e\u65f6\u7531\u64ad\u653e\u5668\u8d1f\u8d23\u6e32\u67d3\u3002\u597d\u5904\u662f\u7075\u6d3b\u4e14\u5feb\u901f\uff0c\u5c01\u88c5\u65f6\u95f4\u77ed\uff0c\u4f53\u79ef\u4e0d\u4f1a\u53d1\u751f\u592a\u5927\u7684\u53d8\u5316\uff0c\u800c\u4e14\u5b57\u5e55\u53ef\u4ee5\u81ea\u7531\u5f00\u5173\uff0c\u4f46\u4e00\u4e9b\u64ad\u653e\u5668\u5f88\u53ef\u80fd\u4e0d\u4f1a\u53bb\u7ba1\u5b57\u5e55\u8f68\u9053\uff0c\u5bfc\u81f4\u4f7f\u7528\u8fd9\u79cd\u64ad\u653e\u5668\u65f6\u770b\u4e0d\u5230\u5b57\u5e55\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u786c\u5c01\u88c5<\/h2>\n\n\n\n<p>\u786c\u5c01\u88c5\u4e5f\u9700\u8981\u4f7f\u7528GPU\u52a0\u901f\uff0c\u5426\u5219\u901f\u5ea6\u4e5f\u5f88\u611f\u4eba\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ffmpeg -i input.mp4 -vf \"subtitles=subtitle.srt\" -c:v h264_nvenc -preset p6 -cq 23 -c:a copy output.mp4<\/code><\/pre>\n\n\n\n<p>\u4ee5\u9632\u4f60\u6ca1\u6709NVIDIA GPU\uff08\u90a3\u4f60\u662f\u600e\u4e48\u770b\u5230\u8fd9\u91cc\u7684\uff1f\uff09\uff0c\u8fd9\u91cc\u4e5f\u653e\u7eafCPU\u8ba1\u7b97\u7684\u786c\u5c01\u88c5\u65b9\u6cd5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ffmpeg -i input.mp4 -vf \"subtitles=subtitle.srt\" -c:v libx264 -crf 23 -preset fast -c:a copy output.mp4<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f6f\u5c01\u88c5<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>ffmpeg -i input.mp4 -i subtitle.srt -map 0 -map 1 -c copy -c:s mov_text -metadata:s:s:0 language=chi output.mp4<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u4f60\u53d1\u73b0\u5b57\u5e55\u4e0d\u540c\u6b65\uff0c\u53ef\u4ee5\u5728input.mp4\u540e\u9762\u52a0\u4e0a -itsoffset sec\u6765\u8c03\u6574\u504f\u79fb\u91cf\uff0c\u5176\u4e2dsec\u662f\u79d2\uff0c\u53ef\u4ee5\u4e3a\u8d1f\u6570\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5de5\u4f5c\u73af\u5883 \u8bc6\u522b\u548c\u63d0\u53d6\u5b57\u5e55 \u9996\u5148\uff0c\u9700\u8981\u4ece\u89c6\u9891\u6587\u4ef6\u4e2d\uff0c\u5c06\u539f\u59cb\u5b57\u5e55\u63d0\u53d6\u51fa\u6765\u3002\u5982\u679c\u89c6\u9891\u4e2d\u5df2\u7ecf\u5185\u5d4c\u4e86\u5b57\u5e55\uff0c\u90a3\u4e48\u76f4\u63a5\u4f7f\u7528\u5de5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-143","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/code.lingapi.top\/index.php?rest_route=\/wp\/v2\/posts\/143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code.lingapi.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code.lingapi.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code.lingapi.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code.lingapi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=143"}],"version-history":[{"count":2,"href":"https:\/\/code.lingapi.top\/index.php?rest_route=\/wp\/v2\/posts\/143\/revisions"}],"predecessor-version":[{"id":145,"href":"https:\/\/code.lingapi.top\/index.php?rest_route=\/wp\/v2\/posts\/143\/revisions\/145"}],"wp:attachment":[{"href":"https:\/\/code.lingapi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code.lingapi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code.lingapi.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}