Версия AutoIt: v3.3.12.0
Доброго времени суток, есть кусок кода
косяк здесь:
прошу помощи...
Доброго времени суток, есть кусок кода
Код:
#include <winhttp.au3>
#include <FileConstants.au3>
Global Const $API_KEY = 'AIzaSyC_PbBzaatunhlSW_ily_W61UK9phx9EaQ'
Global Const $USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36'
main()
Exit
Func main()
local $file_path2 = @ScriptDir & 'out.flac'
local $file_path = fileopen ($file_path2)
Local $request_response = speech_api_file_recognize($file_path)
MsgBox(0, 'Ответ', $request_response,1)
ConsoleWriteError ("otvet " & $request_response )
EndFunc
Func speech_api_file_recognize($file_path, $use_ssl = False)
Local Const $UTF8 = 1
Local $h = FileOpen($file_path, $FO_READ + $FO_BINARY)
Local $file_content = FileRead($h)
FileClose($h)
Local $hOpen = _WinHttpOpen($USER_AGENT)
Local $hConnect, $request_response
Local $path = '/speech-api/v2/recognize?output=json&lang=ru-ru&key=' & $API_KEY
Local $headers = 'Content-Type: audio/x-flac; rate=44100;' & @CRLF
If $use_ssl Then
$hConnect = _WinHttpConnect($hOpen, 'www.google.com', $INTERNET_DEFAULT_HTTPS_PORT)
$request_response = _WinHttpSimpleSSLRequest($hConnect, 'POST', $path, Default, $file_content, $headers, False, $UTF8)
Else
$hConnect = _WinHttpConnect($hOpen, 'www.google.com')
$request_response = _WinHttpSimpleRequest($hConnect, 'POST', $path, Default, $file_content, $headers, False, $UTF8)
EndIf
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
Return $request_response
EndFunc ;==>speech_api_recognize
косяк здесь:
Код:
Func main()
local $file_path2 = @ScriptDir & 'out.flac'
local $file_path = fileopen ($file_path2)
Local $request_response = speech_api_file_recognize($file_path)
MsgBox(0, 'Ответ', $request_response,1)
ConsoleWriteError ("otvet " & $request_response )
EndFunc
прошу помощи...