OmniSaleGmbH / lalalai

109 stars 10 forks source link

https://www.lalal.ai/api/help could use a clarification on the /split/ endpoint. #1

Open josephcatrambone-crucible opened 11 months ago

josephcatrambone-crucible commented 11 months ago

Low priority, as someone who burned a chunk of the afternoon fighting with '{"status": "error", "error": "Required argument \\"params\\" not found"}'.

The Python example uses urllib but even copy-pasting this example I had problems. It might be worth adding examples with aiohttp and requests to the fray somewhere. The working operation of requests.post(f"https://www.lalal.ai/api/split/", headers=headers, data={"params":json.dumps([params])}) can be tricky to find, even with the documentation available.

It might be nice also to accept something like requests.post(..., json=params) alongside the existing multi-part form data. It's a little friendlier on the dev side.

jingfelix commented 10 months ago

I also encounter with the same question. But I found that the kind of code works as well:

 url_for_split = URL_API + "split/"
    headers = {
        "Authorization": f"license {license}",
    }

    query_args = {'id': file_id, 'stem': stem, 'filter': filter_type, 'splitter': splitter}

    async with httpx.AsyncClient() as client:
        res = await client.post(url_for_split, data=query_args, headers=headers)
        json_data = res.json()

        if json_data["status"] == "error":
            raise RuntimeError(json_data["error"])

I received 200 but with no completed results:

{
    'status': 'success',
    'name': 'test__.mp3',
    'size': 54720,
    'duration': 1,
    'stem': 'vocals',
    'splitter': 'phoenix',
    'preview': None,
    'split': None,
    'player': None,
    'task': {
        'id': [
            'e9a76189-b404-4da3-ba0d-10844d5fae4c',
            '6bfae800-c93e-4115-bb4a-3c078900ad33',
            '65d57d53-a7a6-474a-afdd-f559b3b8bd68',
            '731a8bea-7eaa-465e-a15e-c11b837eaab0'
        ],
        'state': 'success',
        'progress': 0,
        'split_id': '65d57d53-a7a6-474a-afdd-f559b3b8bd68'
    }
}