Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/21/2022 in all areas

  1. Just curious, what's the reasoning behind not supporting Unicode in ConsoleWrite?
    1 point
  2. Melba23

    Default keyword

    pixelsearch, The wording you found in the Help file is quite specific: So if no particular role for Default is specified then the results of its use will be arbitrary and undefined. You need to be careful because a "default" setting (as mentioned in the StringReplace case) is NOT necessarily the same thing as using the Default keyword as a parameter. The first defines what will happen if no parameter is passed - the second is setting a specific value to the parameter, which in this case is not mentioned in the parameter definition and so gives unexpected results. Is that clear? M23
    1 point
  3. Declare the global variable for x, y, z, values.
    1 point
  4. ..I have no idea of what you're trying to get done BUT, Random(min,max,flag) , the flag is 0 or 1, not 15. And, welcome to the forum
    1 point
  5. Moved to the appropriate forum. Moderation Team
    1 point
  6. [NEW VERSION] - 21 May 22 Fixed: The _SelectItem function was not correctly clearing earlier selections when SingleSel style was used. And the selection made using the function was not reflected in the _GetLastSelItem function. New UDF in the first post. M23
    1 point
  7. jchd

    Make Net c# DLL and call

    Yes you can use the nuget package and restrict your C# to (more or less) C-compatible code, but still without #-style marshalling, overloading or recursion. At this point you'd rather just produce the DLL from plain C.
    1 point
  8. Hello. here is an example. You still need to download the Audio and maybe create some extra functions. #include <WinAPICom.au3> #include "Json\Json.au3" #include <Array.au3> Global Const $HTTP_STATUS_OK = 200 _TestFakeAPI() Func _TestFakeAPI() ;~ Local $aVoices = _FakeYouGetVoicesList() ;~ _ArrayDisplay($aVoices) ;~ Local $aVoicesCategories = _FakeYouGetVoicesCategoriesList() ;~ _ArrayDisplay($aVoicesCategories) ;~ Local $sInferenceJobToken = _FakeYouGenerateAudio("Hello World","TM:7wbtjphx8h8v") ;~ ConsoleWrite($sInferenceJobToken & @CRLF) ;~ Local $sJsonStatus=_FakeYouGetAudioStatus("JTINF:2mjzmgfph3g912cpp3rpnf9czm") ;~ ConsoleWrite($sJsonStatus & @CRLF) EndFunc ;==>_TestFakeAPI Func _FakeYouWaitForAudioComplete() EndFunc Func _FakeYouGetAudioStatus($sInferenceJobToken) Return __HttpGet("https://api.fakeyou.com/tts/job/" & $sInferenceJobToken) EndFunc Func _FakeYouGenerateAudio($sText,$sTSSModelToken, $sUUID = Default) If $sUUID = Default Then $sUUID = __GenerateUUID() ConsoleWrite($sUUID & @CRLF) Local $oJson=Null Json_Put($oJson, ".tts_model_token", $sTSSModelToken) Json_Put($oJson, ".uuid_idempotency_token", $sUUID) Json_Put($oJson, ".inference_text", $sText) Local $sJson=Json_Encode($oJson) ConsoleWrite($sJson & @CRLF) Local $sJsonReturn=__HttpPost("https://api.fakeyou.com/tts/inference",$sJson) ConsoleWrite($sJsonReturn & @CRLF) $oJson = Json_Decode($sJsonReturn) If $sJsonReturn = "" Or Not __FakeYou_IsSuccess($oJson) Then Return SetError(1, 0, "") Return Json_Get($oJson, '["inference_job_token"]') EndFunc ;==>_FakeYouGenerateAudio Func __GenerateUUID() Return StringLower(StringReplace(StringReplace(_WinAPI_CreateGUID(), "{", ""), "}", "")) EndFunc ;==>__GenerateUUID Func _FakeYouGetVoicesCategoriesList() Local $sJson = __HttpGet("https://api.fakeyou.com/category/list/tts") ;~ ConsoleWrite($sJson & @CRLF) Local $oJson = Json_Decode($sJson) If $sJson = "" Or Not __FakeYou_IsSuccess($oJson) Then Return SetError(1, 0, "") Local $aoJson = Json_Get($oJson, '["categories"]') If Not IsArray($aoJson) Then Return SetError(2, 0, "") Local $aVoicesCategories[UBound($aoJson)][12] Local $aMembers[] = ["category_token", "model_type", "maybe_super_category_token", "can_directly_have_models", "can_have_subcategories", _ "can_only_mods_apply", "name", "name_for_dropdown", "is_mod_approved", "created_at", _ "updated_at", "deleted_at"] For $i = 0 To UBound($aoJson) - 1 For $x = 0 To UBound($aMembers) - 1 $aVoicesCategories[$i][$x] = Json_Get($aoJson[$i], '["' & $aMembers[$x] & '"]') Next Next Return $aVoicesCategories EndFunc ;==>_FakeYouGetVoicesCategoriesList Func _FakeYouGetVoicesList() Local $sJson = __HttpGet("https://api.fakeyou.com/tts/list") ConsoleWrite($sJson & @CRLF) Local $oJson = Json_Decode($sJson) If $sJson = "" Or Not __FakeYou_IsSuccess($oJson) Then Return SetError(1, 0, "") Local $aoJson = Json_Get($oJson, '["models"]') If Not IsArray($aoJson) Then Return SetError(2, 0, "") Local $aVoices[UBound($aoJson)][15] Local $aMembers[] = ["model_token", "tts_model_type", "creator_user_token", "creator_username", "creator_display_name", _ "creator_gravatar_hash", "title", "ietf_language_tag", "ietf_primary_language_subtag", "is_front_page_featured", _ "is_twitch_featured", "maybe_suggested_unique_bot_command", "category_tokens", "created_at", "updated_at"] Local $sMemberValue = "" For $i = 0 To UBound($aoJson) - 1 For $x = 0 To UBound($aMembers) - 1 $sMemberValue = Json_Get($aoJson[$i], '["' & $aMembers[$x] & '"]') If $aMembers[$x] = "category_tokens" Then For $n = 0 To UBound($sMemberValue) - 1 $aVoices[$i][$x] &= Json_Get($sMemberValue, '[' & $n & ']') & (($n < UBound($sMemberValue) - 1) ? "|" : "") Next Else $aVoices[$i][$x] = $sMemberValue EndIf Next Next Return $aVoices EndFunc ;==>_FakeYouGetVoicesList Func __FakeYou_IsSuccess(ByRef $oJson) Return Json_ObjExists($oJson, 'success') EndFunc ;==>__FakeYou_IsSuccess Func __HttpGet($sURL, $sData = "") Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("GET", $sURL & "?" & $sData, False) If (@error) Then Return SetError(1, 0, 0) $oHTTP.SetRequestHeader("Content-Type", "application/json") $oHTTP.Send() If (@error) Then Return SetError(2, 0, 0) If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0) Return SetError(0, 0, $oHTTP.ResponseText) EndFunc ;==>__HttpGet Func __HttpPost($sURL, $sData = "") Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("POST", $sURL, False) If (@error) Then Return SetError(1, 0, 0) $oHTTP.SetRequestHeader("Content-Type", "application/json") $oHTTP.Send($sData) If (@error) Then Return SetError(2, 0, 0) If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0) Return SetError(0, 0, $oHTTP.ResponseText) EndFunc ;==>__HttpPost ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Saludos
    1 point
  9. Sorry you're right ! Hey guys stop using udfs, it's so gigantic !
    1 point
  10. Right, because it makes so much more sense to use a gigantic UDF for one API call.
    1 point
×
×
  • Create New...