{"id":472,"date":"2010-11-30T15:23:27","date_gmt":"2010-11-30T18:23:27","guid":{"rendered":"http:\/\/leandroascierto.com\/blog\/?p=472"},"modified":"2011-08-27T08:13:37","modified_gmt":"2011-08-27T11:13:37","slug":"472","status":"publish","type":"post","link":"https:\/\/leandroascierto.com\/blog\/472\/","title":{"rendered":"API Google Speak"},"content":{"rendered":"<p style=\"text-align: justify;\">Esta funci\u00f3n sirve para utilizar el API Speak de Google, con la cual podemos llevar un texto a voz de m\u00e1quina, esta api s\u00f3lo se limita a cien caracteres, y por supuesto necesitamos de internet para que funcione.<br \/>\nEl primer par\u00e1metro es el texto que queremos escuchar, el segundo el idioma o mejor dicho la pronunciaci\u00f3n, en el caso de espa\u00f1ol es \u00abes\u00bb para otros por ejemplo:<\/p>\n<p style=\"text-align: justify;\">Alem\u00e1n: de<br \/>\nDan\u00e9s: da<br \/>\nEspa\u00f1ol: es<br \/>\nFinlandia: fi<br \/>\nFranc\u00e9s: fr<br \/>\nIngl\u00e9s: en<br \/>\nItaliano: it<br \/>\nNeerland\u00e9s: nl<br \/>\nPolaco: pl<br \/>\nPortugu\u00e9s: pt<br \/>\nSueco: sv<\/p>\n<p style=\"text-align: justify;\">y el tercer par\u00e1metro es para llamar a DoEvents si es que lo deseamos.<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nOption Explicit\r\n'-----------------------------------------------------------------------------------------------------\r\n'Autor: Leandro Ascierto\r\n'Web: www.leandroascierto.com.ar\r\n'Abreviaturas\r\n'de, da, es, fi, fr, en, it, nl, pl, pt, sv&quot;\r\n'Alem\u00e1n , Dan\u00e9s, Espa\u00f1ol, Finlandia, Franc\u00e9s, Ingl\u00e9s, Italiano, Neerland\u00e9s, Polaco, Portugu\u00e9s, Sueco\r\n'----------------------------------------------------------------------------------------------------\r\nPrivate Declare Function mciSendString Lib &quot;winmm.dll&quot; Alias &quot;mciSendStringA&quot; (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long\r\nPrivate Declare Function URLDownloadToFile Lib &quot;urlmon&quot; Alias &quot;URLDownloadToFileA&quot; (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long\r\n\r\nPublic Function GoogleSpeak(ByVal sText As String, Optional ByVal Language As String = &quot;es&quot;, Optional ByVal bDoevents As Boolean) As Boolean\r\n    On Error Resume Next\r\n    Dim sTempPath As String, ml As String\r\n    Dim FileLength As Long\r\n\r\n    sText = Replace(sText, vbCrLf, &quot; &quot;)\r\n\r\n    If Len(sText) &gt; 100 Then Exit Function\r\n\r\n    sTempPath = Environ(&quot;Temp&quot;) &amp; &quot;\\TempMP3.MP3&quot;\r\n\r\n    If URLDownloadToFile(0&amp;, &quot;http:\/\/translate.google.com\/translate_tts?tl=&quot; &amp; Language &amp; &quot;&amp;q=&quot; &amp; sText, sTempPath, 0&amp;, 0&amp;) = 0 Then\r\n\r\n        If mciSendString(&quot;open &quot; &amp; Chr$(34) &amp; sTempPath &amp; Chr$(34) &amp; &quot; type MpegVideo&quot; &amp; &quot; alias myfile&quot;, 0&amp;, 0&amp;, 0&amp;) = 0 Then\r\n\r\n            ml = String(30, 0)\r\n            Call mciSendString(&quot;status myfile length &quot;, ml, 30, 0&amp;)\r\n            FileLength = Val(ml)\r\n            If FileLength Then\r\n                If mciSendString(&quot;play myFile&quot;, 0&amp;, 0&amp;, 0&amp;) = 0 Then\r\n                    Do While mciSendString(&quot;status myfile position &quot;, ml, 30, 0&amp;) = 0\r\n                        If Val(ml) = FileLength Then GoogleSpeak = True: Exit Do\r\n                        If bDoevents Then DoEvents\r\n                    Loop\r\n                End If\r\n            End If\r\n            Call mciSendString(&quot;close myfile&quot;, 0&amp;, 0&amp;, 0&amp;)\r\n\r\n        End If\r\n\r\n        Kill sTempPath\r\n    End If\r\n\r\nEnd Function\r\n\r\nPrivate Sub Command1_Click()\r\n   Debug.Print GoogleSpeak(&quot;Antes era sexo droga y rock and roll, ahora es paja mate y chamame&quot;, &quot;es&quot;, True)\r\nEnd Sub\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Esta funci\u00f3n sirve para utilizar el API Speak de Google, con la cual podemos llevar un texto a voz de m\u00e1quina, esta api s\u00f3lo se limita a cien caracteres, y por supuesto necesitamos de internet para que funcione. El primer par\u00e1metro es el texto que queremos escuchar, el segundo el idioma o mejor dicho la <a href='https:\/\/leandroascierto.com\/blog\/472\/' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[64],"class_list":["post-472","post","type-post","status-publish","format-standard","hentry","category-funciones","tag-google","category-42-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/posts\/472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/comments?post=472"}],"version-history":[{"count":3,"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/posts\/472\/revisions"}],"predecessor-version":[{"id":496,"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/posts\/472\/revisions\/496"}],"wp:attachment":[{"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/media?parent=472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/categories?post=472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/leandroascierto.com\/blog\/wp-json\/wp\/v2\/tags?post=472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}