{"id":2642,"date":"2024-06-04T00:02:40","date_gmt":"2024-06-03T16:02:40","guid":{"rendered":"https:\/\/blog.md5.red\/?p=2642"},"modified":"2024-06-04T17:36:43","modified_gmt":"2024-06-04T09:36:43","slug":"whisperx%e6%9c%ac%e5%9c%b0%e9%83%a8%e7%bd%b2","status":"publish","type":"post","link":"https:\/\/blog.md5.red\/?p=2642","title":{"rendered":"whisperX\u672c\u5730\u90e8\u7f72"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/pipeline.png\" class=\"highslide-image\" onclick=\"return hs.expand(this);\"><img decoding=\"async\" width=\"1024\" height=\"211\" src=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/pipeline-1024x211.png\" alt=\"\" class=\"wp-image-2645\" srcset=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/pipeline-1024x211.png 1024w, https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/pipeline-300x62.png 300w, https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/pipeline-768x158.png 768w, https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/pipeline.png 1448w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>\u5f00\u6e90\u9879\u76ee\u5730\u5740\uff1a<a href=\"https:\/\/github.com\/m-bain\/whisperX\">https:\/\/github.com\/m-bain\/whisperX<\/a><\/p>\n\n\n\n<p>    1\u3001\u652f\u6301\u5feb\u901f\u5b9e\u65f6\u8f6c\u5f55<\/p>\n\n\n\n<p>    2\u3001\u652f\u6301\u65f6\u95f4\u6233\u5bf9\u9f50<\/p>\n\n\n\n<p>    3\u3001\u652f\u6301\u8bf4\u8bdd\u4eba\u5206\u7c7b<\/p>\n\n\n\n<p>4\u3001\u652f\u6301\u8bed\u97f3\u6d3b\u52a8\u68c0\u6d4b<\/p>\n\n\n\n<p>5\u3001\u6548\u7387\u63d0\u5347<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u73af\u5883\u914d\u7f6e\uff1a<\/h2>\n\n\n\n<p>    1\u3001\u5b89\u88c5<a href=\"https:\/\/sms-activate.org\/?ref=5771312\" target=\"_blank\" rel=\"noreferrer noopener\">python3.10<\/a> \uff1a\u5b89\u88c5\u7684\u65f6\u5019\u8bb0\u5f97\u52fe\u9009Add python to PATH\uff0c\u5b89\u88c5\u5b8c\u6210cmd\u4e2d\u8f93\u5165python -V \u51fa\u73b0Python\u7248\u672c\u5373\u53ef<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/image.png\" class=\"highslide-image\" onclick=\"return hs.expand(this);\"><img decoding=\"async\" width=\"478\" height=\"87\" src=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/image.png\" alt=\"\" class=\"wp-image-2648\" style=\"width:340px;height:auto\" srcset=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/image.png 478w, https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/image-300x55.png 300w\" sizes=\"(max-width: 478px) 100vw, 478px\" \/><\/a><\/figure>\n\n\n\n<p>2\u3001\u5b89\u88c5<a href=\"https:\/\/developer.nvidia.com\/cuda-12-1-0-download-archive\" target=\"_blank\" rel=\"noreferrer noopener\">CUDA12.1<\/a>\uff1a\u5b89\u88c5\u5b8c\u6210cmd\u4e2d\u8f93\u5165nvidia-smi\u51fa\u73b0Nvidia\u7248\u672c\u5373\u53ef<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/cuda.jpg\" class=\"highslide-image\" onclick=\"return hs.expand(this);\"><img decoding=\"async\" width=\"1024\" height=\"458\" src=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/cuda-1024x458.jpg\" alt=\"\" class=\"wp-image-2653\" style=\"width:757px;height:auto\" srcset=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/cuda-1024x458.jpg 1024w, https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/cuda-300x134.jpg 300w, https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/cuda-768x343.jpg 768w, https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/cuda.jpg 1255w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>3\u3001\u5b89\u88c5<a href=\"https:\/\/developer.nvidia.com\/rdp\/cudnn-archive\" target=\"_blank\" rel=\"noreferrer noopener\">cuDNN for CUDA12.x<\/a>\uff08\u9700\u8981\u5148\u6ce8\u518c\uff09\uff1a\u5c063\u4e2a\u6587\u4ef6\u5939\u62f7\u8d1d\u5230CUDA\u5b89\u88c5\u76ee\u5f55<\/p>\n\n\n\n<p>4\u3001\u5b89\u88c5<a href=\"https:\/\/pytorch.org\/get-started\/locally\/\">PyTorch<\/a>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip3 install torch torchvision torchaudio --index-url https:\/\/download.pytorch.org\/whl\/cu121<\/code><\/pre>\n\n\n\n<p>\u9700\u8981\u5173\u6389\u68af\u5b50\uff08\u5f00\u68af\u5b50\u4f1a\u62a5\u9519\uff09\uff0c\u6700\u597d\u6302\u4e2aVPN\uff0c\u901f\u5ea6\u5feb\u5f88\u591a<\/p>\n\n\n\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5728python\u4e0b\u8f93\u5165<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import torch \ntorch.cuda.is_available()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/true.jpg\" class=\"highslide-image\" onclick=\"return hs.expand(this);\"><img decoding=\"async\" width=\"481\" height=\"169\" src=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/true.jpg\" alt=\"\" class=\"wp-image-2658\" style=\"width:312px;height:auto\" srcset=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/true.jpg 481w, https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/true-300x105.jpg 300w\" sizes=\"(max-width: 481px) 100vw, 481px\" \/><\/a><\/figure>\n\n\n\n<p>\u5982\u679c\u8fd4\u56detrue\u5219\u4ee3\u8868Torch\u53ef\u4ee5\u4f7f\u7528GPU\u663e\u5361\u4e86<\/p>\n\n\n\n<p>5\u3001\u5b89\u88c5whisperX\uff1apip install git+https:\/\/github.com\/m-bain\/whisperx.git<\/p>\n\n\n\n<p>6\u3001\u5b89\u88c5<a href=\"https:\/\/www.gyan.dev\/ffmpeg\/builds\/ffmpeg-git-essentials.7z\" target=\"_blank\" rel=\"noreferrer noopener\">ffmpeg<\/a><\/p>\n\n\n\n<p>7\u3001<s>\u4f7f\u7528<a href=\"https:\/\/github.com\/Pikurrot\/whisper-gui\">https:\/\/github.com\/Pikurrot\/whisper-gui<\/a>\u8fdb\u884c\u6d4b\u8bd5<\/s>\uff08\u6700\u7ec8\u672a\u80fd\u6210\u529f\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install gradio\ngit clone https:\/\/github.com\/Pikurrot\/whisper-gui\npython main.py --autolaunch<\/code><\/pre>\n\n\n\n<p>\u9009\u62e9\u6a21\u578b\u540e\uff0c\u7b2c\u4e00\u6b21\u4f7f\u7528\u4f1a\u4e0b\u8f7d\uff0c\u9700\u8981\u7b49\u5f85<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/2024-06-04-143448.jpg\" class=\"highslide-image\" onclick=\"return hs.expand(this);\"><img decoding=\"async\" width=\"676\" height=\"157\" src=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/2024-06-04-143448.jpg\" alt=\"\" class=\"wp-image-2673\" style=\"width:426px;height:auto\" srcset=\"https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/2024-06-04-143448.jpg 676w, https:\/\/blog.md5.red\/wp-content\/uploads\/2024\/06\/2024-06-04-143448-300x70.jpg 300w\" sizes=\"(max-width: 676px) 100vw, 676px\" \/><\/a><\/figure>\n\n\n\n<p>\u51fa\u73b0\u65e0\u6cd5\u4f7f\u7528cuda\u7684\u60c5\u51b5\uff0c\u5b98\u65b9\u9879\u76eeIssue\u91cc\u4e5f\u6709\u4eba\u9047\u5230\uff0c\u6ca1\u80fd\u89e3\u51b3\uff0c\u770b\u4e86\u4e0b\u4ee3\u7801\uff0c\u5e94\u8be5\u662f\u73af\u5883\u914d\u7f6e\u91ccgpu_support\u88ab\u8bbe\u7f6e\u4e3aNone\u4e86<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5c1d\u8bd5\u89e3\u51b3\uff1a<\/h2>\n\n\n\n<p>1\u3001\u5b89\u88c5<a href=\"https:\/\/docs.conda.io\/projects\/miniconda\/en\/latest\/\">Miniconda<\/a>\uff0c\u914d\u7f6e\u73af\u5883<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>conda create --name whisperx python=3.10\nconda activate whisperx<\/code><\/pre>\n\n\n\n<p>2\u3001\u5b89\u88c5pytorch<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia<\/code><\/pre>\n\n\n\n<p>3\u3001\u5b89\u88c5whisperx<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install git+https:\/\/github.com\/m-bain\/whisperx.git<\/code><\/pre>\n\n\n\n<p>4\u3001\u5b89\u88c5gradio<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install gradio<\/code><\/pre>\n\n\n\n<p>5\u3001<s>\u5b89\u88c5whisper-gui<\/s>\uff08\u6700\u7ec8\u672a\u80fd\u6210\u529f\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/Pikurrot\/whisper-gui<\/code><\/pre>\n\n\n\n<p>\u5d29\u6e83\uff0c\u8fd8\u662f\u65e0\u6cd5\u4f7f\u7528cuda<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5c1d\u8bd5\u5b9a\u4f4d\u95ee\u9898<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import os\nimport time\nimport torch\nimport os   #\u5f15\u7528OS\nimport whisperx\nimport gc \n\ndef whisperx_test():\n    #device = \"cpu\"\n    device = \"cuda\" \n    model_size = \"large-v3\"\n    audio_file = \"16k16bit.wav\"\n    batch_size = 16\n    compute_type = \"int8\" \n\n    # widnow CPU\n    #model = whisperx.load_model(\"tiny\", device, compute_type=compute_type)\n\n    # window GPU\n    model = whisperx.load_model(\"tiny\", device, compute_type=compute_type)\n\n    audio = whisperx.load_audio(audio_file)\n    result = model.transcribe(audio, batch_size=batch_size)\n\n    print(result&#91;\"segments\"])\n\nif __name__ == \"__main__\":\n    # print(torch.cuda.is_available())\n    start_time = time.time()  # \u5f00\u59cb\u65f6\u95f4\n    print(\"start time:\", start_time)\n    # whisper_test()\n    # faster_whisper_test()\n    whisperx_test()\n    end_time = time.time()  # \u7ed3\u675f\u65f6\u95f4\n    print(\"Execution time: \", end_time - start_time, \"seconds\")<\/code><\/pre>\n\n\n\n<p>\u62a5\u9519\uff1aAssertionError: Torch not compiled with CUDA enabled<\/p>\n\n\n\n<p>\u5e94\u8be5\u662fTorch\u73af\u5883\u5b89\u88c5\u95ee\u9898<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import torch \ntorch.cuda.is_available()<\/code><\/pre>\n\n\n\n<p>\u7ed3\u679c\u53d8\u6210\u4e86false<\/p>\n\n\n\n<p>\u91cd\u65b0\u5b89\u88c5\u4e00\u904dTorch\uff0c\u95ee\u9898\u89e3\u51b3\uff0cpython\u6d4b\u8bd5\u4ee3\u7801\u6b63\u5e38\uff0c\u4f46\u662fwhisper-gui\u8fd8\u662f\u4e0d\u80fd\u7528\uff0c\u4e5f\u8bb8\u6709BUG\u3002<\/p>\n\n\n\n<p>\u53c2\u8003\u94fe\u63a5\uff1a<a href=\"https:\/\/www.cnblogs.com\/aehyok\/p\/18183895\">https:\/\/www.cnblogs.com\/aehyok\/p\/18183895<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f00\u6e90\u9879\u76ee\u5730\u5740\uff1ahttps:\/\/github.com\/m-bain\/whisperX 1\u3001\u652f\u6301\u5feb\u901f\u5b9e\u65f6\u8f6c\u5f55 2\u3001 ...<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-2642","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/blog.md5.red\/index.php?rest_route=\/wp\/v2\/posts\/2642","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.md5.red\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.md5.red\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.md5.red\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.md5.red\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2642"}],"version-history":[{"count":25,"href":"https:\/\/blog.md5.red\/index.php?rest_route=\/wp\/v2\/posts\/2642\/revisions"}],"predecessor-version":[{"id":2690,"href":"https:\/\/blog.md5.red\/index.php?rest_route=\/wp\/v2\/posts\/2642\/revisions\/2690"}],"wp:attachment":[{"href":"https:\/\/blog.md5.red\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.md5.red\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.md5.red\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}