{"id":1154,"date":"2025-05-28T13:52:42","date_gmt":"2025-06-04T06:01:41","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=1154"},"modified":"2025-06-04T13:52:42","modified_gmt":"2025-06-04T06:01:41","slug":"1154","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/uncategorized\/1154\/","title":{"rendered":"\u89e3\u6c7a gtts.tts.gTTSError: 200 (OK) \u932f\u8aa4\uff1a\u6700\u65b0 Python TTS API \u4f7f\u7528\u6307\u5357"},"content":{"rendered":"<p>\u5728\u4f7f\u7528 Google Text-to-Speech (gTTS) \u6642\uff0c\u60a8\u53ef\u80fd\u6703\u9047\u5230\u4ee5\u4e0b\u932f\u8aa4\u4fe1\u606f\uff1a<\/p>\n<p>&#8220;`<br \/>\ngtts.tts.gTTSError: 200 (OK) from TTS API. Probable cause: Unknown<br \/>\n&#8220;`<\/p>\n<p>\u9019\u500b\u932f\u8aa4\u901a\u5e38\u8868\u793a\u5728\u8abf\u7528 TTS API \u6642\u51fa\u73fe\u4e86\u554f\u984c\uff0c\u5118\u7ba1\u8fd4\u56de\u7684\u72c0\u614b\u78bc\u70ba 200\uff0c\u8868\u793a\u8acb\u6c42\u6210\u529f\uff0c\u4f46\u5be6\u969b\u4e0a\u53ef\u80fd\u662f\u56e0\u70ba\u591a\u7a2e\u539f\u56e0\u5c0e\u81f4\u7684\u932f\u8aa4\u3002\u4e0b\u9762\u5c07\u4ecb\u7d39\u5982\u4f55\u6392\u67e5\u548c\u89e3\u6c7a\u9019\u500b\u554f\u984c\u3002<\/p>\n<p>### \u932f\u8aa4\u8ffd\u8e64<\/p>\n<p>\u4ee5\u4e0b\u662f\u932f\u8aa4\u767c\u751f\u7684\u5806\u68e7\u8ffd\u8e64\uff1a<\/p>\n<p>&#8220;`<br \/>\n  File &#8220;main.py&#8221;, line 35, in <module><br \/>\n    main()<br \/>\n  File &#8220;main.py&#8221;, line 24, in main<br \/>\n    result = WebCrawer_test2.Start(&#8220;https:\/\/www.twgreatdaily.com\/cat91&#8221;,1)<br \/>\n  File &#8220;\/Users\/steven\/Desktop\/\u6211\u7684SSD\u5099\u4efd\/Users\/\u310b\/Desktop\/\u5099\u4efd\/WebCrawer_test2.py&#8221;, line 294, in Start<br \/>\n    Start_sub(article_Ind,len(article_url))<br \/>\n  File &#8220;\/Users\/steven\/Desktop\/\u6211\u7684SSD\u5099\u4efd\/Users\/\u310b\/Desktop\/\u5099\u4efd\/WebCrawer_test2.py&#8221;, line 270, in Start_sub<br \/>\n    create_speak(title[article_Ind-1],content[article_Ind-1],article_Ind)<br \/>\n  File &#8220;\/Users\/steven\/Desktop\/\u6211\u7684SSD\u5099\u4efd\/Users\/\u310b\/Desktop\/\u5099\u4efd\/WebCrawer_test2.py&#8221;, line 230, in create_speak<br \/>\n    tts.save(path+&#8221;title.mp3&#8243;)<br \/>\n  File &#8220;\/usr\/local\/lib\/python3.8\/site-packages\/gtts\/tts.py&#8221;, line 312, in save<br \/>\n    self.write_to_fp(f)<br \/>\n  File &#8220;\/usr\/local\/lib\/python3.8\/site-packages\/gtts\/tts.py&#8221;, line 294, in write_to_fp<br \/>\n    raise gTTSError(tts=self, response=r)<br \/>\n&#8220;`<\/p>\n<p>### \u89e3\u6c7a\u65b9\u6848<\/p>\n<p>\u70ba\u4e86\u78ba\u4fdd gTTS \u6b63\u5e38\u904b\u4f5c\uff0c\u5efa\u8b70\u60a8\u57f7\u884c\u4ee5\u4e0b\u5e7e\u500b\u6b65\u9a5f\uff1a<\/p>\n<p>1. **\u66f4\u65b0 gTTS \u548c\u76f8\u95dc\u4f9d\u8cf4**\uff1a<br \/>\n   \u78ba\u4fdd\u60a8\u4f7f\u7528\u7684\u662f\u6700\u65b0\u7248\u672c\u7684 gTTS \u548c gTTS-token\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u5347\u7d1a\uff1a<\/p>\n<p>   &#8220;`bash<br \/>\n   pip install gTTS &#8211;upgrade<br \/>\n   pip install gTTS-token &#8211;upgrade<br \/>\n   &#8220;`<\/p>\n<p>   \u6216\u8005\uff0c\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f Python 3\uff0c\u5247\u57f7\u884c\uff1a<\/p>\n<p>   &#8220;`bash<br \/>\n   pip3 install gTTS &#8211;upgrade<br \/>\n   pip3 install gTTS-token &#8211;upgrade<br \/>\n   &#8220;`<\/p>\n<p>2. **\u6aa2\u67e5\u7db2\u7d61\u9023\u63a5**\uff1a<br \/>\n   \u6709\u6642\u5019\uff0c\u7db2\u7d61\u554f\u984c\u53ef\u80fd\u5c0e\u81f4 API \u8acb\u6c42\u5931\u6557\u3002\u8acb\u6aa2\u67e5\u60a8\u7684\u7db2\u7d61\u9023\u63a5\u662f\u5426\u6b63\u5e38\uff0c\u4e26\u91cd\u8a66\u8acb\u6c42\u3002<\/p>\n<p>3. **\u6aa2\u67e5 API \u4f7f\u7528\u9650\u5236**\uff1a<br \/>\n   \u78ba\u4fdd\u60a8\u6c92\u6709\u8d85\u904e Google TTS API \u7684\u4f7f\u7528\u9650\u5236\u3002\u67e5\u770b Google \u7684\u6587\u6a94\u4ee5\u4e86\u89e3\u76f8\u95dc\u9650\u5236\u3002<\/p>\n<p>4. **\u6355\u7372\u4f8b\u5916**\uff1a<br \/>\n   \u5728\u60a8\u7684\u4ee3\u78bc\u4e2d\u4f7f\u7528\u4f8b\u5916\u8655\u7406\u4f86\u6355\u7372 gTTSError\uff0c\u9019\u6a23\u53ef\u4ee5\u63d0\u4f9b\u66f4\u591a\u7684\u932f\u8aa4\u4e0a\u4e0b\u6587\uff0c\u4e26\u9632\u6b62\u7a0b\u5e8f\u5d29\u6f70\u3002\u4f8b\u5982\uff1a<\/p>\n<p>   &#8220;`python<br \/>\n   from gtts import gTTS, gTTSError<\/p>\n<p>   try:<br \/>\n       tts = gTTS(text=&#8217;Hello, world!&#8217;, lang=&#8217;en&#8217;)<br \/>\n       tts.save(&#8216;hello.mp3&#8217;)<br \/>\n   except gTTSError as e:<br \/>\n       print(f&#8221;An error occurred: {e}&#8221;)<br \/>\n   &#8220;`<\/p>\n<p>\u9019\u4e9b\u6b65\u9a5f\u61c9\u8a72\u80fd\u5e6b\u52a9\u60a8\u89e3\u6c7a gTTS \u4e2d\u7684 gTTSError\u3002\u96a8\u8457 Python \u548c Google TTS API \u7684\u4e0d\u65b7\u66f4\u65b0\uff0c\u6301\u7e8c\u95dc\u6ce8\u76f8\u95dc\u6587\u6a94\u4ee5\u7372\u53d6\u6700\u65b0\u4fe1\u606f\u5c07\u662f\u5341\u5206\u91cd\u8981\u7684\u3002<\/p>\n<p>\u5e0c\u671b\u9019\u7bc7\u6587\u7ae0\u80fd\u5e6b\u52a9\u60a8\u9806\u5229\u89e3\u6c7a\u554f\u984c\uff0c\u5feb\u4f86\u8a66\u8a66\u4ee5\u4e0a\u65b9\u6cd5\u5427\uff01<br \/>\n&#8212;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4f7f\u7528 Google Text-to-Speech&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-1154","post","type-post","status-publish","format-aside","hentry","category-uncategorized","post_format-post-format-aside"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/scFK27-1154","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/1154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=1154"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/1154\/revisions"}],"predecessor-version":[{"id":1155,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/1154\/revisions\/1155"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=1154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=1154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=1154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}