{"id":1226,"date":"2012-02-08T16:58:48","date_gmt":"2012-02-08T07:58:48","guid":{"rendered":"http:\/\/www.ka-net.org\/blog\/?p=1226"},"modified":"2014-03-13T15:57:55","modified_gmt":"2014-03-13T06:57:55","slug":"google-tts%e3%81%a7%e6%96%87%e5%ad%97%e5%88%97%e3%82%92%e8%aa%ad%e3%81%bf%e4%b8%8a%e3%81%92%e3%82%8b%e3%83%9e%e3%82%af%e3%83%ad","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=1226","title":{"rendered":"Google TTS\u3067\u6587\u5b57\u5217\u3092\u8aad\u307f\u4e0a\u3052\u308b\u30de\u30af\u30ed"},"content":{"rendered":"<p><strong>2012\/02\/09 \u8ffd\u8a18\uff1a<\/strong><\/p>\n<p>\u95a2\u9023\u8a18\u4e8b<\/p>\n<p><strong>\u30fb<\/strong><a href=\"\/\/www.ka-net.org\/blog\/?p=1232\" title=\"Google\u7ffb\u8a33\u306e\u8a00\u8a9e\u81ea\u52d5\u691c\u51fa\u6a5f\u80fd\u3092\u8ffd\u3046\" target=\"_blank\">Google\u7ffb\u8a33\u306e\u8a00\u8a9e\u81ea\u52d5\u691c\u51fa\u6a5f\u80fd\u3092\u8ffd\u3046<\/a><br \/>\n<strong>\u30fb<\/strong><a href=\"\/\/www.ka-net.org\/blog\/?p=1242\" title=\"Google TTS\u3067\u6587\u5b57\u5217\u3092\u8aad\u307f\u4e0a\u3052\u308b\u30de\u30af\u30ed(\u8a00\u8a9e\u81ea\u52d5\u691c\u51fa\u5bfe\u5fdc\u7248)\" target=\"_blank\">Google TTS\u3067\u6587\u5b57\u5217\u3092\u8aad\u307f\u4e0a\u3052\u308b\u30de\u30af\u30ed(\u8a00\u8a9e\u81ea\u52d5\u691c\u51fa\u5bfe\u5fdc\u7248)<\/a><\/p>\n<p>\u3082\u5408\u308f\u305b\u3066\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u5916\u56fd\u8a9e\u306e\u7ffb\u8a33\u306b\u5f79\u7acb\u3064\u30b5\u30fc\u30d3\u30b9\u3001<a href=\"http:\/\/translate.google.com\/\" title=\"Google\u7ffb\u8a33\" target=\"_blank\">Google\u7ffb\u8a33<\/a>\u306b\u306f\u97f3\u58f0\u3092\u518d\u751f\u3059\u308b\u6a5f\u80fd\u304c\u5099\u308f\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u3053\u306e\u6a5f\u80fd\u3092\u5229\u7528\u3057\u305f\u3001\u6587\u5b57\u5217\u3092\u8aad\u307f\u4e0a\u3052\u308b\u30de\u30af\u30ed\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #ff0000; font-weight: bold;\">\u203b \u4e0b\u8a18\u30de\u30af\u30ed\u306f64\u30d3\u30c3\u30c8\u7248Office\u74b0\u5883\u3092\u8003\u616e\u3057\u3066\u3044\u307e\u305b\u3093\u3002<\/span><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Option Explicit\r\n\r\nPrivate Declare Function mciSendString Lib &quot;winmm&quot; Alias &quot;mciSendStringA&quot; ( _\r\n        ByVal lpstrCommand As String, _\r\n        ByVal lpstrReturnString As String, _\r\n        ByVal uReturnLength As Long, _\r\n        ByVal hwndCallback As Long) As Long\r\nPrivate Declare Function URLDownloadToFile Lib &quot;urlmon&quot; Alias &quot;URLDownloadToFileA&quot; ( _\r\n        ByVal pCaller As Long, _\r\n        ByVal szURL As String, _\r\n        ByVal szFileName As String, _\r\n        ByVal dwReserved As Long, _\r\n        ByVal lpfnCB As Long) As Long\r\n\r\nPublic Sub Sample()\r\n  TTSGoogle &quot;\u3053\u3093\u306b\u3061\u306f&quot;\r\n  TTSGoogle &quot;Hello&quot;, &quot;en&quot;\r\nEnd Sub\r\n\r\nPrivate Sub TTSGoogle(ByVal txt As String, Optional ByVal lng As String = &quot;ja&quot;)\r\n'Google TTS\u3092\u5229\u7528\u3057\u3066\u97f3\u58f0\u518d\u751f\r\n  Dim TTSFilePath As String\r\n  Dim tmp As String\r\n  Dim ret As Long\r\n  \r\n  '**********************************************************\r\n  '\u25a0 \u5bfe\u5fdc\u3059\u308b\u8a00\u8a9e(\u5f15\u6570lng) http:\/\/translate.google.com\/ \u3088\u308a\r\n  '   \u30a2\u30a4\u30b9\u30e9\u30f3\u30c9\u8a9e:is\r\n  '   \u30a2\u30d5\u30ea\u30ab\u30fc\u30f3\u30b9\u8a9e:af\r\n  '   \u30a2\u30e9\u30d3\u30a2\u8a9e:ar\r\n  '   \u30a2\u30eb\u30d0\u30cb\u30a2\u8a9e:sq\r\n  '   \u30a2\u30eb\u30e1\u30cb\u30a2\u8a9e:hy\r\n  '   \u30a4\u30bf\u30ea\u30a2\u8a9e:it\r\n  '   \u30a4\u30f3\u30c9\u30cd\u30b7\u30a2\u8a9e:id\r\n  '   \u30a6\u30a7\u30fc\u30eb\u30ba\u8a9e:cy\r\n  '   \u30aa\u30e9\u30f3\u30c0\u8a9e:nl\r\n  '   \u30ab\u30bf\u30ed\u30cb\u30a2\u8a9e:ca\r\n  '   \u30ae\u30ea\u30b7\u30e3\u8a9e:el\r\n  '   \u30af\u30ec\u30aa\u30fc\u30eb\u8a9e(\u30cf\u30a4\u30c1):ht\r\n  '   \u30af\u30ed\u30a2\u30c1\u30a2\u8a9e:hr\r\n  '   \u30b9\u30a6\u30a7\u30fc\u30c7\u30f3\u8a9e:sv\r\n  '   \u30b9\u30da\u30a4\u30f3\u8a9e:es\r\n  '   \u30b9\u30ed\u30d0\u30ad\u30a2\u8a9e:sk\r\n  '   \u30b9\u30ef\u30d2\u30ea\u8a9e:sw\r\n  '   \u30bb\u30eb\u30d3\u30a2\u8a9e:sr\r\n  '   \u30bf\u30a4\u8a9e:th\r\n  '   \u30bf\u30df\u30eb\u8a9e:ta\r\n  '   \u30c1\u30a7\u30b3\u8a9e:cs\r\n  '   \u30c7\u30f3\u30de\u30fc\u30af\u8a9e:da\r\n  '   \u30c9\u30a4\u30c4\u8a9e:de\r\n  '   \u30c8\u30eb\u30b3\u8a9e:tr\r\n  '   \u30ce\u30eb\u30a6\u30a7\u30fc\u8a9e:no\r\n  '   \u30cf\u30f3\u30ac\u30ea\u30fc\u8a9e:hu\r\n  '   \u30d2\u30f3\u30c7\u30a3\u30fc\u8a9e:hi\r\n  '   \u30d5\u30a3\u30f3\u30e9\u30f3\u30c9\u8a9e:fi\r\n  '   \u30d5\u30e9\u30f3\u30b9\u8a9e:fr\r\n  '   \u30d9\u30c8\u30ca\u30e0\u8a9e:vi\r\n  '   \u30dd\u30fc\u30e9\u30f3\u30c9\u8a9e:pl\r\n  '   \u30dd\u30eb\u30c8\u30ac\u30eb\u8a9e:pt\r\n  '   \u30de\u30b1\u30c9\u30cb\u30a2\u8a9e:mk\r\n  '   \u30e9\u30c6\u30f3\u8a9e:la\r\n  '   \u30e9\u30c8\u30d3\u30a2\u8a9e:lv\r\n  '   \u30eb\u30fc\u30de\u30cb\u30a2\u8a9e:ro\r\n  '   \u30ed\u30b7\u30a2\u8a9e:ru\r\n  '   \u82f1\u8a9e:en\r\n  '   \u97d3\u56fd\u8a9e:ko\r\n  '   \u4e2d\u56fd\u8a9e:zh-CN\r\n  '   \u65e5\u672c\u8a9e:ja\r\n  '**********************************************************\r\n  \r\n  '\u6587\u5b57\u5217\u78ba\u8a8d\r\n  tmp = Replace(txt, &quot;\u3000&quot;, &quot;&quot;)\r\n  tmp = Replace(tmp, &quot; &quot;, &quot;&quot;)\r\n  tmp = Replace(tmp, vbCrLf, &quot;&quot;)\r\n  tmp = Replace(tmp, vbCr, &quot;&quot;)\r\n  tmp = Replace(tmp, vbLf, &quot;&quot;)\r\n  If Len(tmp) &lt; 1 Then\r\n    MsgBox &quot;\u97f3\u58f0\u51fa\u529b\u3059\u308b\u6587\u5b57\u5217\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot; &amp; vbCrLf &amp; &quot;\u51e6\u7406\u3092\u4e2d\u6b62\u3057\u307e\u3059\u3002&quot;, vbCritical + vbSystemModal\r\n    Exit Sub\r\n  End If\r\n  If Len(txt) &gt; 100 Then\r\n    MsgBox &quot;\u6587\u5b57\u6570\u304c\u591a\u3059\u304e\u307e\u3059\u3002&quot; &amp; vbCrLf &amp; &quot;\u51e6\u7406\u3092\u4e2d\u6b62\u3057\u307e\u3059\u3002&quot;, vbCritical + vbSystemModal\r\n    Exit Sub\r\n  End If\r\n    \r\n  '\u97f3\u58f0\u30d5\u30a1\u30a4\u30eb\u306e\u4fdd\u5b58\r\n  With CreateObject(&quot;Scripting.FileSystemObject&quot;)\r\n    TTSFilePath = .GetSpecialFolder(2) &amp; Application.PathSeparator &amp; &quot;tts.mp3&quot;\r\n    If .FileExists(TTSFilePath) Then Kill TTSFilePath '\u30d5\u30a1\u30a4\u30eb\u3092\u4e8b\u524d\u306b\u524a\u9664\r\n    ret = URLDownloadToFile(0&amp;, &quot;http:\/\/translate.google.com\/translate_tts?tl=&quot; &amp; lng &amp; &quot;&amp;q=&quot; &amp; EncodeURL(txt), TTSFilePath, 0&amp;, 0&amp;)\r\n    If ret &lt;&gt; 0&amp; Then\r\n      MsgBox &quot;\u97f3\u58f0\u30d5\u30a1\u30a4\u30eb\u304c\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002&quot; &amp; vbCrLf &amp; &quot;\u51e6\u7406\u3092\u4e2d\u6b62\u3057\u307e\u3059\u3002&quot;, vbCritical + vbSystemModal\r\n      Exit Sub\r\n    End If\r\n    If .FileExists(TTSFilePath) = False Then\r\n      MsgBox &quot;\u97f3\u58f0\u30d5\u30a1\u30a4\u30eb\u304c\u4fdd\u5b58\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002&quot; &amp; vbCrLf &amp; &quot;\u51e6\u7406\u3092\u4e2d\u6b62\u3057\u307e\u3059\u3002&quot;, vbCritical + vbSystemModal\r\n      Exit Sub\r\n    End If\r\n  End With\r\n  \r\n  '\u97f3\u58f0\u30d5\u30a1\u30a4\u30eb\u306e\u518d\u751f\u30fb\u524a\u9664\r\n  mciSendString &quot;Open &quot; &amp; Chr(34) &amp; TTSFilePath &amp; Chr(34), &quot;&quot;, 0&amp;, 0&amp;\r\n  mciSendString &quot;Play &quot; &amp; Chr(34) &amp; TTSFilePath &amp; Chr(34) &amp; &quot; wait&quot;, &quot;&quot;, 0&amp;, 0&amp;\r\n  mciSendString &quot;Close &quot; &amp; Chr(34) &amp; TTSFilePath &amp; Chr(34), &quot;&quot;, 0&amp;, 0&amp;\r\n  Kill TTSFilePath\r\nEnd Sub\r\n\r\nPrivate Function EncodeURL(ByVal sWord As String) As String\r\n  With CreateObject(&quot;ScriptControl&quot;)\r\n    .Language = &quot;JScript&quot;\r\n    EncodeURL = .CodeObject.encodeURIComponent(sWord)\r\n  End With\r\nEnd Function<\/pre>\n<p>\u5f53\u30de\u30af\u30ed\u306fGoogle\u7ffb\u8a33\u306e\u6a5f\u80fd\u306b\u3088\u3063\u3066\u4f5c\u6210\u3055\u308c\u305fMP3\u30d5\u30a1\u30a4\u30eb\u3092mciSendString\u95a2\u6570\u3067\u518d\u751f\u3059\u308b\u4ed5\u7d44\u307f\u3092\u53d6\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u305f\u3060\u3001\u3053\u306e\u30b5\u30fc\u30d3\u30b9\u81ea\u4f53\u304c\u516c\u5f0f\u306e\u3082\u306e\u3067\u306f\u306a\u304f\u3001\u4eca\u5f8c\u5f53\u30de\u30af\u30ed\u3092\u5229\u7528\u3067\u304d\u306a\u304f\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u305d\u306e\u70b9\u306f\u3054\u6ce8\u610f\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"2012\/02\/09 \u8ffd\u8a18\uff1a \u95a2\u9023\u8a18\u4e8b \u30fbGoogle\u7ffb\u8a33\u306e\u8a00\u8a9e\u81ea\u52d5\u691c\u51fa\u6a5f\u80fd\u3092\u8ffd\u3046 \u30fbGoogle TTS\u3067\u6587\u5b57\u5217\u3092\u8aad\u307f\u4e0a\u3052\u308b\u30de\u30af\u30ed(\u8a00\u8a9e\u81ea\u52d5\u691c\u51fa\u5bfe\u5fdc\u7248) \u3082\u5408\u308f\u305b\u3066\u3054\u89a7\u304f\u3060\u3055\u3044\u3002 \u5916\u56fd\u8a9e\u306e\u7ffb\u8a33\u306b\u5f79\u7acb\u3064\u30b5\u30fc\u30d3\u30b9\u3001Goog [&hellip;]","protected":false},"author":1,"featured_media":7111,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,48,49,126,50],"tags":[35,47,8,11],"class_list":["post-1226","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office","category-excel-office","category-word-office","category-google","category-translate","tag-35","tag-google","tag-vba","tag-office-2"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Excel.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-jM","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1226"}],"version-history":[{"count":8,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1226\/revisions"}],"predecessor-version":[{"id":1281,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1226\/revisions\/1281"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7111"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}