Surya Posted July 2, 2018 Posted July 2, 2018 Hi everyone its been loooong since I posted here I have been trying to convert this curl executable parameters into autoit using the winhttp com object; curl -F data_file=@my_audio_file.mp3 -F model=en-US "https://api.speechmatics.com/v1.0/user/41049/jobs/?auth_token=MmQ5MTk4jdsgjhgghstOGU5YS00OWFhLWghdgjshgdhbshj017###" any ideas guys PS: I am excited to post here after a looong time No matter whatever the challenge maybe control on the outcome its on you its always have been. MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)
Surya Posted July 15, 2018 Author Posted July 15, 2018 Can I upvote this? No matter whatever the challenge maybe control on the outcome its on you its always have been. MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)
TheXman Posted July 15, 2018 Posted July 15, 2018 (edited) On 7/2/2018 at 11:20 AM, Surya said: I have been trying to convert this curl executable parameters into autoit using the winhttp com object Where is your attempt so that we can see where you are having a problem and give you some advice or guidance? Edited July 15, 2018 by TheXman Removed part about bumping post. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Surya Posted July 16, 2018 Author Posted July 16, 2018 hi @TheXman I am very poor in winhttp handling this is were I have reached ,I don't know wether it is right or not Local $sServerURL = "https://api.speechmatics.com/v1.0/user/41049/jobs/?auth_token=MmQ5MTk4ZjQtOGU5YS00OWFhLWI3YzUtOWZkMDYwZWI3Zjg0" Local $boundary = "--------Boundary" Local $Postdata = "--" & $boundary & @CRLF & _ "Content-Disposition: form-data; model=en-US; data_file=" & '"' & filename($filepath) & '"' & @CRLF & _ "Content-Type: data_file" & @CRLF & @CRLF & _ Binary(FileRead($filepath)) & @CRLF & _ "--" & $boundary & "--" & @CRLF Local $oHTTP = ObjCreate('winhttp.winhttprequest.5.1') $oHTTP.Open("POST", $sServerURL, False) $oHTTP.SetRequestHeader("Content-Type", "multipart/form-data; " & "boundary=" & $boundary) $oHTTP.Send("model=en-US; data_file=" &Binary(FileRead($filepath)));$Postdata) $hotlink = $oHTTP.ResponseText No matter whatever the challenge maybe control on the outcome its on you its always have been. MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)
TheXman Posted July 16, 2018 Posted July 16, 2018 Here is a good example of one way to do a POST that uploads a file: It uses winhttp.au3. You can find a link the latest version of winhttp.au3 using the link below. The zip file includes documentation that explains the winhttp.au3 functions and has several examples. Assuming that you are calling the Speechmatic API correctly, this should get you closer to your goal. If you run into an obstacles implementing the API using the example above, post back and we'll see if we can help you get past it. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Danyfirex Posted July 17, 2018 Posted July 17, 2018 (edited) Hello Using WinHttp UDF you could do this: #include "WinHTTP.au3" Global Const $sFileToUpload = "C:\Users\User\Desktop\WinHttp\test.mp3" ;<- Set correct file location here Global Const $sAddress = "https://api.speechmatics.com/v1.0/user/41049/jobs/?auth_token=MmQ5MTk4jdsgjhgghstOGU5YS00OWFhLWghdgjshgdhbshj017###" ;<- Set correct host here Local $sForm = _ '<form action="' & $sAddress & '" method="post" enctype="multipart/form-data">' & _ ' <input type="file" name="data_file" />' & _ ' <input type="submit" name="model" value="en-US">' & _ '</form>' ; Initialize and get session handle $hOpen = _WinHttpOpen() $hForm = $sForm ; Fill form on this page $sRead = _WinHttpSimpleFormFill($hForm, $hOpen, Default, "name:data_file", $sFileToUpload) ; Close connection handle _WinHttpCloseHandle($hForm) ; Close session handle _WinHttpCloseHandle($hOpen) ; See what's returned (in default browser or whatever) If $sRead Then ConsoleWrite($sRead & @CRLF) EndIf Saludos Edited December 30, 2019 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Surya Posted July 18, 2018 Author Posted July 18, 2018 (edited) THNQUU @Danyfirex it worked Can I use the winhttp object to do the same instead of the udf Hola amigos Edited July 18, 2018 by Surya No matter whatever the challenge maybe control on the outcome its on you its always have been. MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)
TheXman Posted July 18, 2018 Posted July 18, 2018 (edited) . Edited July 18, 2018 by TheXman Removed content of my reply because it didn't add anyhting to the topic.. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Surya Posted July 29, 2018 Author Posted July 29, 2018 voila everyone this is where I am I am unable to using winhttp it shows this { "code": 400, "error": "Missing data_file" } test.wav this is the code expandcollapse popup$filepath = FileOpenDialog("Select",@ScriptDir,"All (*.*)") $filepah = FileOpen($filepath,16) $output = AnonFilesUpload($filepath) ConsoleWrite(filename($filepath) & @CRLF) ConsoleWrite($output & @CRLF) Func AnonFilesUpload($filepath) $sServerURL = "https://api.speechmatics.com/v1.0/user/41049/jobs/?auth_token=MmQ5MTk4ZjQtOGU5YS00OWFhLWI3YzUtOMDYwZWI4Zjg0" $boundary = "------------WinHttpBoundaryLine_96747.69683" ;"--" &$boundary &@CRLF & _ ; "Content-Disposition: form-data; name=" &'"model"; ' &' value="en-US"' &@CRLF & _ ;"Content-Type: submit" &@CRLF & _ $Postdata = "--" & $boundary & @CRLF & _ "Content-Disposition: form-data; name=" &'"' &"data_file" &'"' &"; filename=" &'"' &filename($filepath) &'"' &@CRLF & _ "Content-Type: audio/x-wav" & @CRLF & @CRLF & _ BinaryToString(FileRead($filepah)) & @CRLF &@CRLF & _ "--" & $boundary &@CRLF & _ 'Content-Disposition: form-data; name="model"' &@CRLF &@CRLF & _ 'en-US' &@CRLF & _ "--" & $boundary & "--" &@CRLF MsgBox(Default,Default,$Postdata) $oHTTP = ObjCreate('winhttp.winhttprequest.5.1') $oHTTP.Open("POST", $sServerURL, False) $oHTTP.SetRequestHeader("Content-Type", "multipart/form-data; " & "boundary=" & $boundary) $oHTTP.SetRequestHeader("Accept","application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,*/*;q=0.5") $oHTTP.SetRequestHeader("Accept","utf-8;q=0.7") $oHTTP.Send($Postdata) $oHTTP.WaitForResponse() $hotlink = $oHTTP.ResponseText ConsoleWrite($hotlink) $hotlink = StringRegExpReplace(StringMid($hotlink, StringInStr($hotlink, "https")), '[/"}]', "") Return $hotlink EndFunc Func filename($filepath) Local $file = StringSplit($filepath, "\") Return $file[(UBound($file) - 1)] EndFunc I took the code from here and tried to modify it but it wont work,Can anyone please help me where I am wrong No matter whatever the challenge maybe control on the outcome its on you its always have been. MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)
Surya Posted August 18, 2018 Author Posted August 18, 2018 I made it till here what am I missing again expandcollapse popup$filepath = FileOpenDialog("Select",@ScriptDir,"All (*.*)") $filepah = FileOpen($filepath) $output = AnonFilesUpload($filepath) ConsoleWrite(filename($filepath) & @CRLF) ConsoleWrite($output & @CRLF) Func AnonFilesUpload($filepath) $sServerURL = "https://api.speechmatics.com/v1.0/user/41049/jobs/?auth_token=MmQ5MTk4ZjQtOGU5YS00OWFhUtOWZkMDYwZWI4Zjg0" $boundary = "------------WinHttpBoundaryLine_96747.69683" ;"--" &$boundary &@CRLF & _ ; "Content-Disposition: form-data; name=" &'"model"; ' &' value="en-US"' &@CRLF & _ ;"Content-Type: submit" &@CRLF & _ $Postdata = '--' & $boundary & @CRLF & _ 'Content-Disposition: form-data; name="model"' &@CRLF &@CRLF & _ 'en-US' &@CRLF & _ '--' & $boundary &@CRLF & _ 'Content-Disposition: form-data; name="data_file"; filename=' &'"' &filename($filepath) &'"' &@CRLF & _ 'Content-Type: audio/x-wav' & @CRLF & @CRLF & _ FileRead($filepah) & @CRLF & _ '--' & $boundary & '--' MsgBox(Default,Default,$Postdata) $oHTTP = ObjCreate('winhttp.winhttprequest.5.1') $oHTTP.Open("POST", $sServerURL, False) $oHTTP.SetRequestHeader("Content-Type", "multipart/form-data; boundary=" & $boundary) $oHTTP.SetRequestHeader("Accept","application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,*/*;q=0.5") $oHTTP.SetRequestHeader("Accept","utf-8;q=0.7") $oHTTP.SetRequestHeader('Content-Length',StringLen($Postdata)) $oHTTP.Send($Postdata) $oHTTP.WaitForResponse() $hotlink = $oHTTP.ResponseText ConsoleWrite($hotlink) $hotlink = StringRegExpReplace(StringMid($hotlink, StringInStr($hotlink, "https")), '[/"}]', "") Return $hotlink EndFunc Func filename($filepath) Local $file = StringSplit($filepath, "\") Return $file[(UBound($file) - 1)] EndFunc can someone help me.. while exexuting this i get this --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop { "code": 403, "error": "Job rejected due to invalid audio" } tmp.wav +>08:33:04 AutoIt3.exe ended.rc:0 +>08:33:04 AutoIt3Wrapper Finished. >Exit code: 0 Time: 21.53 No matter whatever the challenge maybe control on the outcome its on you its always have been. MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)
Surya Posted August 19, 2018 Author Posted August 19, 2018 (edited) Is there somewherw where i can learn this, anyone here hello,i tired googling and couldnt find anything all i could find was documentation of winhttp Edited August 19, 2018 by Surya No matter whatever the challenge maybe control on the outcome its on you its always have been. MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)
Danyfirex Posted August 19, 2018 Posted August 19, 2018 Does this work? $filepath=@ScriptDir & "\test.mp3" $sServerURL = "https://api.speechmatics.com/v1.0/user/41049/jobs/?auth_token=MmQ5MTk4ZjQtOGU5YS00OWFhUtOWZkMDYwZWI4Zjg0" $boundary = "------WinHttpBoundaryLine_96747.69683" ;"--" &$boundary &@CRLF & _ ; "Content-Disposition: form-data; name=" &'"model"; ' &' value="en-US"' &@CRLF & _ ;"Content-Type: submit" &@CRLF & _ $Postdata = $boundary & @CRLF & _ 'Content-Disposition: form-data; name="data_file"; filename="' & filename($filepath) & '"' & @CRLF & _ 'Content-Type: audio/mpeg' & @CRLF & @CRLF & _ FileRead($filepath) & @CRLF & _ $boundary & @CRLF & _ 'Content-Disposition: form-data; name="model"' & @CRLF & @CRLF & _ 'en-US' & @CRLF & _ $boundary & "--" & @CRLF ;~ ConsoleWrite($Postdata & @CRLF) ;~ Exit $oHTTP = ObjCreate('winhttp.winhttprequest.5.1') $oHTTP.Open("POST", $sServerURL, False) $oHTTP.SetRequestHeader("Content-Type", 'multipart/form-data; boundary=----WinHttpBoundaryLine_51560.17967') $oHTTP.SetRequestHeader("Accept", "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,*/*;q=0.5") $oHTTP.SetRequestHeader("Accept-Charset", "utf-8;q=0.7") $oHTTP.SetRequestHeader('Content-Length', StringLen($Postdata)) $oHTTP.Send($Postdata) $oHTTP.WaitForResponse() $hotlink = $oHTTP.ResponseText ConsoleWrite($hotlink) Func filename($filepath) Local $file = StringSplit($filepath, "\") Return $file[(UBound($file) - 1)] EndFunc Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Surya Posted August 19, 2018 Author Posted August 19, 2018 (edited) @Danyfirex it didn't work but the winhttp udf thing worked well,why doesn't the code work are we making any mistake or is it that my winhttp versions are not correct I copy pasted ur code screenshots attatched Edited August 19, 2018 by Surya No matter whatever the challenge maybe control on the outcome its on you its always have been. MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)
Danyfirex Posted August 19, 2018 Posted August 19, 2018 Hello. Here you have. $filepath=@ScriptDir & "\zero.wav" $sServerURL = "https://api.speechmatics.com/v1.0/user/41049/jobs/?auth_token=MmQ5MTk4ZjQtOGU5YS00OWFhLWI3YzUtOWZkMDYwZWI4Zjg0" $boundary = "------WinHttpBoundaryLine_96747.69683" $Postdata = $boundary & @CRLF & _ 'Content-Disposition: form-data; name="data_file"; filename="' & filename($filepath) & '"' & @CRLF & _ 'Content-Type: application/octet-stream' & @CRLF & @CRLF & _ BinaryToString(FileRead($filepath)) & @CRLF & _ $boundary & @CRLF & _ 'Content-Disposition: form-data; name="model"' & @CRLF & @CRLF & _ 'en-US' & @CRLF & _ $boundary & "--" & @CRLF $oHTTP = ObjCreate('winhttp.winhttprequest.5.1') $oHTTP.Open("POST", $sServerURL, False) $oHTTP.SetRequestHeader("User-Agent", 'Mozilla/5.0 (Windows NT 10.0; WOW64) WinHttp/1.6.3.9 (WinHTTP/5.1) like Gecko') $oHTTP.SetRequestHeader("Content-Type", 'multipart/form-data; boundary=----WinHttpBoundaryLine_96747.69683') $oHTTP.SetRequestHeader("Accept", "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,*/*;q=0.5") $oHTTP.SetRequestHeader("Accept-Charset", "utf-8;q=0.7") $oHTTP.SetRequestHeader('Content-Length', StringLen($Postdata)) $oHTTP.Send(Binary($Postdata)) $oHTTP.WaitForResponse() $hotlink = $oHTTP.ResponseText ConsoleWrite($hotlink) Func filename($filepath) Local $file = StringSplit($filepath, "\") Return $file[(UBound($file) - 1)] EndFunc Saludos Surya 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Surya Posted August 19, 2018 Author Posted August 19, 2018 @Danyfirex Can I Cry It workedddddddddddddd,Thank youuuuuu No matter whatever the challenge maybe control on the outcome its on you its always have been. MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now