{"id":24216,"date":"2025-01-24T15:52:23","date_gmt":"2025-01-24T07:52:23","guid":{"rendered":"http:\/\/139.9.1.231\/?p=24216"},"modified":"2025-01-24T15:52:24","modified_gmt":"2025-01-24T07:52:24","slug":"kokoro-tts","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2025\/01\/24\/kokoro-tts\/","title":{"rendered":"Kokoro TTS\uff1a\u652f\u6301\u591a\u8bed\u8a00\u7684\u8f7b\u91cf\u7ea7TTS\u6a21\u578b"},"content":{"rendered":"\n<p>\u6700\u8fd1\uff0cHuggingFace\u6a21\u578b\u8d8b\u52bf\u699c\u4e0a\u6709\u4e00\u4e2a\u5f88\u706b\u7684\u5f00\u6e90\u6a21\u578b<strong>Kokoro-82M<\/strong>\u3002<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\"><strong>\u5f00\u6e90\u6a21\u578b\uff1a<\/strong><a href=\"https:\/\/huggingface.co\/hexgrad\/Kokoro-82M\"><strong><em>https:\/\/huggingface.co\/hexgrad\/Kokoro-82M<\/em><\/strong><\/a><\/p>\n\n\n\n<p><strong>Kokoro-82M\u4e0d\u662f\u5927\u6a21\u578b\uff0c\u800c\u662f\u4e00\u4e2a\u53c2\u6570\u91cf\u53ea\u670982M\u7684TTS\uff08Text-to-Speech\uff09\u6a21\u578b\u3002\u867d\u7136\u6a21\u578b\u4e0d\u5927\uff0c\u4f46\u662fKokoro-82M\u5728TTS Arena\u699c\u5355\u4e0a\u6392\u884c\u7b2c\u4e00\uff01<\/strong>TTS Arena \u662f\u4e00\u4e2a\u7528\u4e8e\u8bc4\u4f30\u8bed\u97f3\u5408\u6210\u6a21\u578b\u7684\u5e73\u53f0\uff0c\u5176\u7075\u611f\u6765\u6e90\u4e8e LMsys \u7684 Chatbot Arena\u3002\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u8f93\u5165\u6587\u672c\u5e76\u5bf9\u6bd4\u4e24\u4e2a\u6a21\u578b\u7684\u5408\u6210\u8bed\u97f3\u6765\u6295\u7968\u9009\u62e9\u66f4\u81ea\u7136\u7684\u7ed3\u679c\uff0c\u6a21\u578b\u540d\u79f0\u5728\u6295\u7968\u540e\u624d\u4f1a\u663e\u793a\u3002\u8be5\u5e73\u53f0\u65e8\u5728\u89e3\u51b3\u8bed\u97f3\u5408\u6210\u9886\u57df\u7f3a\u4e4f\u6709\u6548\u8d28\u91cf\u8bc4\u4f30\u65b9\u6cd5\u7684\u95ee\u9898\uff0c\u901a\u8fc7\u516c\u5f00\u6392\u540d\u4f7f\u7ed3\u679c\u66f4\u900f\u660e\u4e14\u6613\u4e8e\u8bbf\u95ee\u3002\u867d\u7136\u8fd9\u4e2a\u6392\u884c\u699c\u5f88\u6709\u53c2\u8003\u610f\u4e49\u3002<\/p>\n\n\n\n<p>\u5728\u4eba\u5de5\u667a\u80fd\u8bed\u97f3\u5408\u6210\u6280\u672f\u5feb\u901f\u53d1\u5c55\u7684\u4eca\u5929\uff0cKokoro TTS \u4ee5\u5176\u8f7b\u91cf\u7ea7\u8bbe\u8ba1\u548c\u9ad8\u6548\u6027\u80fd\u8131\u9896\u800c\u51fa\u3002\u4f5c\u4e3a\u4e00\u4e2a\u4ec5\u670982M\u53c2\u6570\u7684\u6587\u672c\u8f6c\u8bed\u97f3\uff08TTS\uff09\u6a21\u578b\uff0cKokoro \u5728 TTS Spaces Arena \u4e2d\u51fb\u8d25\u4e86\u8bb8\u591a\u53c2\u6570\u89c4\u6a21\u66f4\u5927\u7684\u7ade\u4e89\u5bf9\u624b\uff0c\u6210\u4e3a\u8bed\u97f3\u5408\u6210\u9886\u57df\u7684\u4e00\u9897\u65b0\u661f\u3002<\/p>\n\n\n\n<p id=\"h_18450040389_1\"><strong>\u6a21\u578b\u67b6\u6784\u4e0e\u53c2\u6570\u89c4\u6a21<\/strong><\/p>\n\n\n\n<p>Kokoro TTS \u57fa\u4e8e StyleTTS 2 \u67b6\u6784\uff0c\u5176\u53c2\u6570\u89c4\u6a21\u4ec5\u4e3a82M\uff0c\u8fdc\u4f4e\u4e8e\u8bb8\u591a\u4e3b\u6d41 TTS \u6a21\u578b\uff08\u5982 XTTS v2 \u7684467M \u53c2\u6570\u548c MetaVoice \u76841.2B \u53c2\u6570\uff09\uff0c\u4f46\u5728\u5355\u58f0\u9053\u8bbe\u7f6e\u4e0b\u8868\u73b0\u5353\u8d8a\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"790\" height=\"334\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2025\/01\/image-92.png\" alt=\"\" class=\"wp-image-24222\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2025\/01\/image-92.png 790w, http:\/\/139.9.1.231\/wp-content\/uploads\/2025\/01\/image-92-300x127.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2025\/01\/image-92-768x325.png 768w\" sizes=\"(max-width: 790px) 100vw, 790px\" \/><\/figure>\n\n\n\n<p id=\"h_18450040389_2\"><strong>\u652f\u6301\u7684\u8bed\u97f3\u4e0e\u8bed\u8a00<\/strong><\/p>\n\n\n\n<p>Kokoro \u6700\u65b0\u7248\uff080.23\uff09\u652f\u6301\u591a\u8bed\u8a00\u652f\u6301\u4e0e\u58f0\u97f3\u514b\u9686\uff0c\u5305\u62ec\uff1a<strong>\u4e2d\u3001\u82f1\u3001\u6cd5\u3001\u65e5\u3001\u97e9<\/strong>\u3002\u6bcf\u79cd\u8bed\u8a00\u652f\u6301\u591a\u79cd\u97f3\u8272\u4ee5\u53ca\u7537\u3001\u5973\u58f0\uff0c\u6bcf\u79cd\u8bed\u97f3\u5305\u90fd\u7ecf\u8fc7\u4e13\u4e1a\u8c03\u6821\uff0c\u786e\u4fdd\u97f3\u8d28\u6e05\u6670\u81ea\u7136\u3002\u82f1\u8bed\u652f\u6301\u7f8e\u56fd\u82f1\u8bed\u548c\u82f1\u56fd\u82f1\u8bed\uff0c\u5e76\u63d0\u4f9b\u4e8610\u79cd\u72ec\u7279\u7684\u8bed\u97f3\u5305\uff0c\u5305\u62ec\u7537\u58f0\u548c\u5973\u58f0\uff08\u5982 af_bella\u3001af_sarah\u3001am_adam \u7b49\uff09\u3002<\/p>\n\n\n\n<p>\u4e0d\u8fc7\u8fd8\u4e0d\u652f\u6301\u4e2d\u6587\u6216\u97e9\u6587\u4e2d\u4e0e\u82f1\u8bed\u6df7\u5408\u7684\u60c5\u51b5\u3002<\/p>\n\n\n\n<p id=\"h_18450040389_3\"><strong>\u6027\u80fd\u4f18\u52bf\u4e0e\u521b\u65b0\u70b9<\/strong><\/p>\n\n\n\n<p>Kokoro \u7684\u8bad\u7ec3\u6570\u636e\u91cf\u4e0d\u5230100\u5c0f\u65f6\uff0c\u8fdc\u4f4e\u4e8e\u5176\u4ed6\u6a21\u578b\uff08\u5982 XTTS v2 \u768410,000\u5c0f\u65f6\uff09\uff0c\u4f46\u5176\u5728 TTS Spaces Arena \u4e2d\u6392\u540d\u7b2c\u4e00\uff0c\u8bc1\u660e\u4e86\u5176\u5728\u53c2\u6570\u6548\u7387\u4e0a\u7684\u4f18\u52bf\u3002\u6b64\u5916\uff0cKokoro \u91c7\u7528\u00a0espeak-ng\u00a0\u8fdb\u884c\u5b57\u5f62\u5230\u97f3\u7d20\uff08g2p\uff09\u8f6c\u6362\uff0c\u8fdb\u4e00\u6b65\u63d0\u5347\u4e86\u8bed\u97f3\u5408\u6210\u7684\u81ea\u7136\u5ea6\u3002<\/p>\n\n\n\n<p id=\"h_18450040389_5\"><strong>\u672c\u5730\u90e8\u7f72\u6b65\u9aa4<\/strong><\/p>\n\n\n\n<p><strong>\u6a21\u578b\u5730\u5740\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/link.zhihu.com\/?target=https%3A\/\/huggingface.co\/hexgrad\/Kokoro-82M\" target=\"_blank\">https:\/\/huggingface.co\/hexgrad\/Kokoro-82M<\/a><\/strong><\/p>\n\n\n\n<p>\u4ee5\u4e0b\u6b65\u9aa4\u4e3anotebook\u4e2d\u4f7f\u7528<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># 1\ufe0f\u20e3 Install dependencies silently\n!git lfs install\n!git clone https:\/\/huggingface.co\/hexgrad\/Kokoro-82M\n%cd Kokoro-82M\n!<a href=\"https:\/\/zhida.zhihu.com\/search?content_id=252712206&amp;content_type=Article&amp;match_order=1&amp;q=apt-get&amp;zhida_source=entity\" target=\"_blank\" rel=\"noreferrer noopener\">apt-get<\/a> -qq -y install espeak-ng &gt; \/dev\/null 2&gt;&amp;1\n!pip install -q phonemizer torch transformers scipy munch\n\n# 2\ufe0f\u20e3 Build the model and load the default voicepack\nfrom models import build_model\nimport torch\ndevice = 'cuda' if torch.cuda.is_available() else 'cpu'\nMODEL = build_model('kokoro-v0_19.pth', device)\nVOICE_NAME = &#91;\n    'af', # Default voice is a 50-50 mix of Bella &amp; Sarah\n    'af_bella', 'af_sarah', 'am_adam', 'am_michael',\n    'bf_emma', 'bf_isabella', 'bm_george', 'bm_lewis',\n    'af_nicole', 'af_sky',\n]&#91;0]\nVOICEPACK = torch.load(f'voices\/{VOICE_NAME}.pt', weights_only=True).to(device)\nprint(f'Loaded voice: {VOICE_NAME}')\n\n# 3\ufe0f\u20e3 Call generate, which returns 24khz audio and the phonemes used\nfrom <a href=\"https:\/\/zhida.zhihu.com\/search?content_id=252712206&amp;content_type=Article&amp;match_order=2&amp;q=kokoro&amp;zhida_source=entity\" target=\"_blank\" rel=\"noreferrer noopener\">kokoro<\/a> import generate\ntext = \"How could I know? It's an unanswerable question. Like asking an unborn child if they'll lead a good life. They haven't even been born.\"\naudio, out_ps = generate(MODEL, text, VOICEPACK, lang=VOICE_NAME&#91;0])\n# Language is determined by the first letter of the VOICE_NAME:\n#    'a' =&gt; American English =&gt; en-us\n#    'b' =&gt; British English =&gt; en-gb\n\n# 4\ufe0f\u20e3 Display the 24khz audio and print the output phonemes\nfrom IPython.display import display, Audio\ndisplay(Audio(data=audio, rate=24000, autoplay=True))\nprint(out_ps)<\/code><\/pre>\n\n\n\n<p id=\"h_18450040389_6\"><strong>API \u63a5\u53e3\u4e0e Docker \u5316\u90e8\u7f72<\/strong><\/p>\n\n\n\n<p>Kokoro-FastAPI \u662f\u4e00\u4e2a\u57fa\u4e8e Docker \u7684 FastAPI \u5c01\u88c5\uff0c\u652f\u6301 NVIDIA GPU \u52a0\u901f\u548c\u961f\u5217\u5904\u7406\u529f\u80fd\u3002\u7528\u6237\u53ef\u4ee5\u901a\u8fc7 API \u63a5\u53e3\u53d1\u9001\u6587\u672c\u8f6c\u8bed\u97f3\u8bf7\u6c42\uff0c\u5e76\u83b7\u53d6\u9ad8\u8d28\u91cf\u7684\u8bed\u97f3\u8f93\u51fa\u3002<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">Kokoro-FastAPI\u5730\u5740\uff1a<strong><em><a href=\"https:\/\/github.com\/remsky\/Kokoro-FastAPI\">https:\/\/github.com\/remsky\/Kokoro-FastAPI<\/a><\/em><\/strong><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\uff0cHuggingFace\u6a21\u578b\u8d8b\u52bf\u699c\u4e0a\u6709\u4e00\u4e2a\u5f88\u706b\u7684\u5f00\u6e90\u6a21\u578bKokoro-82M\u3002 \u5f00\u6e90\u6a21\u578b\uff1ahttps:\/\/ &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2025\/01\/24\/kokoro-tts\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Kokoro TTS\uff1a\u652f\u6301\u591a\u8bed\u8a00\u7684\u8f7b\u91cf\u7ea7TTS\u6a21\u578b<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[40,4,34],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/24216"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=24216"}],"version-history":[{"count":13,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/24216\/revisions"}],"predecessor-version":[{"id":24230,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/24216\/revisions\/24230"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=24216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=24216"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=24216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}