Git Product home page Git Product logo

Comments (4)

blaisewf avatar blaisewf commented on August 30, 2024

Show me the code/client you are using to make an API request.

from rvc_cli.

ART1FICE avatar ART1FICE commented on August 30, 2024

its a unity app (below) I'm fairly confident in the framework working for other POST requests i have used... - Also i did experiment with the header and got a different error so i don't think its the header... but not sure. - is there anyway to check if the above JSON works for you?

      string url = $"http://127.0.0.1:5000/infer";

    using (var postRequest = UnityWebRequest.PostWwwForm(url, "POST"))
    {
        byte[] bodyRaw = System.Text.Encoding.UTF8.GetBytes(json);
        postRequest.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw);
        postRequest.SetRequestHeader("Content-Type", "application/json");
        

        yield return postRequest.SendWebRequest();

        if (postRequest.result != UnityWebRequest.Result.Success)
        {
            Debug.Log(" POST REQUEST FAILED: " + postRequest.error);
        }  
         else { Debug.Log("SUCCESS"); }

}

and making the json:

    string VAL_f0up_key = "2";
    string VAL_filter_radius = "5";
    string VAL_index_rate = "0.1";
    string VAL_hop_length = "25";
    string VAL_f0method = "dio";

    string VAL_InputPath = "D:\\Projects\\VoiceChangerAI\\TestFile\\testa.wav";
    string VAL_OutputPath = "D:\\Projects\\VoiceChangerAI\\TestFile\\output_API.wav";
    string VAL_PthFile = "C:\\Users\\KCLEE\\Documents\\GitHub\\models\\LenvalBrown.pth";
    string VAL_indexPath = "C:\\Users\\KCLEE\\Documents\\GitHub\\models\\LenvalBrown.index";

    string VAL_SplitAudio = "false";
    string VAL_AutoTune = "false";


string json =
     $@"{{
         ""f0up_key"": ""{VAL_f0up_key}"",
         ""filter_radius"": ""{VAL_filter_radius}"",
         ""index_rate"": ""{VAL_index_rate}"",
         ""hop_length"": ""{VAL_hop_length}"",
         ""f0method"": ""{VAL_f0method}"",
         ""input_path"": ""{VAL_InputPath}"",
         ""output_path"": ""{VAL_OutputPath}"",
         ""pth_path"": ""{VAL_PthFile}"",
         ""index_path"": ""{VAL_indexPath}"",
         ""split_audio"": ""{VAL_SplitAudio}"",
         ""f0autotune"": ""{VAL_AutoTune}""
        }}";

from rvc_cli.

ART1FICE avatar ART1FICE commented on August 30, 2024

hmmm i think there is something wrong with my json... - but when i try it in a python script - i get a "200" success... but that reads as error and doesn't actually create the file - which is progress considering all i ever got was "bad request" from the C# app... though unsure exactly what is wrong with the python POST request.

here is the code i was using for that...

                import requests
                import json
                import time
                
                url = "http://127.0.0.1:5000/infer"
                
                payload = json.dumps({
                "f0up_key": "2",
                "filter_radius": "5",
                "index_rate": "0.1",
                "hop_length": "25",
                "f0method": "dio",
                "input_path": "D:\\Projects\\VoiceChangerAI\\TestFile\\testa.wav",
                "output_path": "D:\\Projects\\VoiceChangerAI\\TestFile\\output_API.wav",
                "pth_path": "C:\\Users\\KCLEE\\Documents\\GitHub\\models\\LenvalBrown.pth",
                "index_path": "C:\\Users\\KCLEE\\Documents\\GitHub\\models\\LenvalBrown.index",
                "split_audio": "false",
                "f0autotune": "false"
                })
                headers = {
                  'Content-Type': 'application/json'
                }
                
                start_time = time.time()  # Start the timer
                
                response = requests.request("POST", url, headers=headers, data=payload)
                
                end_time = time.time()  # Stop the timer
                
                if response.status_code == 200:
                    print("success:", response.text)
                    print("Time taken:", end_time - start_time, "seconds")
                else:
                    print("Error:", response.text)

### output:

success: {"error":"Traceback (most recent call last):\n File "C:\Users\KCLEE\Documents\GitHub\RVC_CLI\rvc\infer\infer.py", line 252, in \n get_vc(model_path, 0)\n File "C:\Users\KCLEE\Documents\GitHub\RVC_CLI\rvc\infer\infer.py", line 195, in get_vc\n cpt = torch.load(person, map_location="cpu")\n File "C:\Users\KCLEE\Documents\GitHub\RVC_CLI\env\lib\site-packages\torch\serialization.py", line 986, in load\n with _open_file_like(f, 'rb') as opened_file:\n File "C:\Users\KCLEE\Documents\GitHub\RVC_CLI\env\lib\site-packages\torch\serialization.py", line 435, in _open_file_like\n return _open_file(name_or_buffer, mode)\n File "C:\Users\KCLEE\Documents\GitHub\RVC_CLI\env\lib\site-packages\torch\serialization.py", line 416, in init\n super().init(open(name, mode))\nFileNotFoundError: [Errno 2] No such file or directory: 'None'\n","output":""}

Time taken: 5.614147424697876 seconds

from rvc_cli.

blaisewf avatar blaisewf commented on August 30, 2024

I have published a new API system, you can check it out if you want - I'm not sure how it works, let me know if it doesn't work well and feel free to create a PR to improve it. You should use the same parameters you would use with the CLI.

At http://localhost:8000/docs you can see the documentation

from rvc_cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.