{"id":1242,"date":"2012-02-09T14:04:32","date_gmt":"2012-02-09T05:04:32","guid":{"rendered":"http:\/\/www.ka-net.org\/blog\/?p=1242"},"modified":"2014-03-13T16:00:28","modified_gmt":"2014-03-13T07:00:28","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%e8%a8%80%e8%aa%9e%e8%87%aa%e5%8b%95%e6%a4%9c%e5%87%ba%e5%af%be%e5%bf%9c","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=1242","title":{"rendered":"Google TTS\u3067\u6587\u5b57\u5217\u3092\u8aad\u307f\u4e0a\u3052\u308b\u30de\u30af\u30ed(\u8a00\u8a9e\u81ea\u52d5\u691c\u51fa\u5bfe\u5fdc\u7248)"},"content":{"rendered":"<p><span style=\"color: #ff0000; font-weight: bold;\">2012\/2\/15 \u8ffd\u8a18\uff1a<\/span><br \/>\n\u4e0b\u8a18\u30de\u30af\u30ed\u3092Excel 2007\/2010\u306b\u5bfe\u5fdc\u3057\u305f\u30a2\u30c9\u30a4\u30f3\u30d5\u30a1\u30a4\u30eb\u306b\u3057\u307e\u3057\u305f\u3002<br \/>\n\u30d5\u30a1\u30a4\u30eb\u306f\u300c<a href=\"\/\/www.ka-net.org\/blog\/?p=1259\" title=\"Google TTS\u3067\u6587\u5b57\u5217\u3092\u8aad\u307f\u4e0a\u3052\u308bExcel\u30a2\u30c9\u30a4\u30f3\" target=\"_blank\">Google TTS\u3067\u6587\u5b57\u5217\u3092\u8aad\u307f\u4e0a\u3052\u308bExcel\u30a2\u30c9\u30a4\u30f3<\/a>\u300d\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"\/\/www.ka-net.org\/blog\/?p=1226\" title=\"Google TTS\u3067\u6587\u5b57\u5217\u3092\u8aad\u307f\u4e0a\u3052\u308b\u30de\u30af\u30ed\" target=\"_blank\">\u524d\u3005\u56de\u306e\u8a18\u4e8b<\/a>\u3067Google\u7ffb\u8a33\u306e\u97f3\u58f0\u518d\u751f\u6a5f\u80fd\u3092\u5229\u7528\u3057\u305f\u6587\u5b57\u5217\u306e\u8aad\u307f\u4e0a\u3052\u30de\u30af\u30ed\u3092\u7d39\u4ecb\u3057\u3001<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\">\u524d\u56de\u306e\u8a18\u4e8b<\/a>\u3067\u8a00\u8a9e\u3092\u81ea\u52d5\u691c\u51fa\u3059\u308b\u4ed5\u7d44\u307f\u306b\u3064\u3044\u3066\u89e6\u308c\u307e\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u306f\u300c<a href=\"\/\/www.ka-net.org\/blog\/?p=1226\" title=\"Google TTS\u3067\u6587\u5b57\u5217\u3092\u8aad\u307f\u4e0a\u3052\u308b\u30de\u30af\u30ed\" target=\"_blank\">Google TTS\u3067\u6587\u5b57\u5217\u3092\u8aad\u307f\u4e0a\u3052\u308b\u30de\u30af\u30ed<\/a>\u300d\u3092\u6539\u826f\u3057\u3066\u8a00\u8a9e\u306e\u81ea\u52d5\u691c\u51fa\u306b\u5bfe\u5fdc\u3055\u305b\u3066\u307f\u305f\u3044\u3068\u601d\u3044\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\n  TTSGoogle Selection.Text, &quot;auto&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  '   \u81ea\u52d5\u691c\u51fa:auto\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  '\u8a00\u8a9e\u81ea\u52d5\u691c\u51fa\u5bfe\u5fdc\r\n  Select Case LCase$(lng)\r\n    Case &quot;auto&quot;\r\n      lng = DetectLanguageG(txt)\r\n      'Debug.Print lng\r\n      If Len(lng) &lt; 1 Then\r\n        MsgBox &quot;\u81ea\u52d5\u691c\u51fa\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002&quot; &amp; vbCrLf &amp; &quot;\u8a00\u8a9e\u3092\u300c\u65e5\u672c\u8a9e\u300d\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002&quot;, vbInformation + vbSystemModal\r\n        lng = &quot;ja&quot;\r\n      End If\r\n  End Select\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 DetectLanguageG(ByVal txt As String) As String\r\n'\u8a00\u8a9e\u81ea\u52d5\u691c\u51fa\r\n  Dim ret As String\r\n  Dim js As String\r\n  \r\n  ret = &quot;&quot;: js = &quot;&quot; '\u521d\u671f\u5316\r\n  On Error Resume Next\r\n  With CreateObject(&quot;MSXML2.XMLHTTP&quot;)\r\n    .Open &quot;GET&quot;, &quot;http:\/\/translate.google.com\/translate_a\/t?client=0&amp;sl=auto&amp;text=&quot; &amp; EncodeURL(txt), False\r\n    .Send\r\n    If .Status = 200 Then js = .responseText\r\n  End With\r\n  On Error GoTo 0\r\n  If Len(js) &gt; 0 Then\r\n    js = &quot;(&quot; &amp; js &amp; &quot;)&quot;\r\n    With CreateObject(&quot;ScriptControl&quot;)\r\n      .Language = &quot;JScript&quot;\r\n      ret = .CodeObject.eval(js).src\r\n    End With\r\n  End If\r\n  DetectLanguageG = ret\r\nEnd Function\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>\u4e0a\u8a18\u30de\u30af\u30ed\u3067\u306f\u5f15\u6570lng\u306b\u300c<span style=\"color: #ff0000; font-weight: bold;\">auto<\/span>\u300d\u3092\u6307\u5b9a\u3059\u308b\u3068\u3001\u8a00\u8a9e\u3092\u81ea\u52d5\u7684\u306b\u691c\u51fa\u3057\u3066\u305d\u306e\u8a00\u8a9e\u306b\u5408\u3063\u305f\u97f3\u58f0\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<br \/>\n(\u8a00\u8a9e\u304c\u691c\u51fa\u3067\u304d\u306a\u304b\u3063\u305f\u5834\u5408\u306b\u306f\u65e5\u672c\u8a9e\u304c\u8a2d\u5b9a\u3055\u308c\u307e\u3059\u3002)<br \/>\n\u6700\u521d\u306e\u30de\u30af\u30ed\u306b\u6bd4\u3079\u3066\u3001\u3053\u308c\u3067\u5927\u5206\u4fbf\u5229\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"2012\/2\/15 \u8ffd\u8a18\uff1a \u4e0b\u8a18\u30de\u30af\u30ed\u3092Excel 2007\/2010\u306b\u5bfe\u5fdc\u3057\u305f\u30a2\u30c9\u30a4\u30f3\u30d5\u30a1\u30a4\u30eb\u306b\u3057\u307e\u3057\u305f\u3002 \u30d5\u30a1\u30a4\u30eb\u306f\u300cGoogle TTS\u3067\u6587\u5b57\u5217\u3092\u8aad\u307f\u4e0a\u3052\u308bExcel\u30a2\u30c9\u30a4\u30f3\u300d\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002  [&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":[8,11,35,47],"class_list":["post-1242","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office","category-excel-office","category-word-office","category-google","category-translate","tag-vba","tag-office-2","tag-35","tag-google"],"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-k2","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1242","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=1242"}],"version-history":[{"count":7,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1242\/revisions"}],"predecessor-version":[{"id":1279,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1242\/revisions\/1279"}],"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=1242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}