Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api request #122

Open
ankelkoss opened this issue Nov 7, 2024 · 1 comment
Open

Api request #122

ankelkoss opened this issue Nov 7, 2024 · 1 comment

Comments

@ankelkoss
Copy link

Hello everyone! Does anyone have a working API request method for uploading, translating and downloading videos? The thing is that JS or Python is not my native programming language, I had some difficulties with implementing this. Thanks in advance!

@ankelkoss
Copy link
Author

ankelkoss commented Nov 8, 2024

I get an error in response to a request, what am I doing wrong?

python

from gradio_client import Client
from gradio_client import Client, handle_file

client = Client("http://127.0.0.1/")

video_file = handle_file('Welcome.mp4')

result = client.predict(
     data_type="SUBMIT VIDEO",
  
     api_name="/swap_visibility"
)
print(result)

result = client.predict(
    [video_file], 
    "Hello!!",
    "Hello!!",
    "hf -censorship-",
    True,
    "large-v3",
    32,
    "float16",
    "English (en)",
    "Russian (ru)",
    1,
    1,
    "ru_speaker_2-Male BARK",
    "True",
    "Adjusting volumes and mixing audio",
    1.9,
    False,
    0.25,
    1.8,
    "srt",
    False,
    False,
    "Hello!!",
    False,
    False,
    True,
    15,
    "pyannote_2.1",
    "google_translator_batch",
    "video (mp4)",
    False,
    False,
    3,
    False,
    True,
    "openvoice_v2",
    True,
    "sentence",
    "",
    False,
    False,
    True,
    False,
    1,
    True,
    #api_name="/batch_multilingual_media_conversion"
    fn_index=20
)

print(result)

powershell

Loaded as API: http://127.0.0.1/ ✔
({'visible': True, 'value': None, '__type__': 'update'}, {'visible': False, 'value': '', '__type__': 'update'}, {'visible': False, 'value': '', '__type__': 'update'})
Traceback (most recent call last):
  File "C:\Users\shytov\Desktop\SoniTranslate\SoniTranslate4.py", line 15, in <module>
    result = client.predict(
             ^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\gradio_client\client.py", line 476, in predict
    ).result()
      ^^^^^^^^
  File "C:\Python312\Lib\site-packages\gradio_client\client.py", line 1513, in result
    return super().result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\concurrent\futures\_base.py", line 456, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\concurrent\futures\_base.py", line 401, in __get_result
    raise self._exception
  File "C:\Python312\Lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\gradio_client\client.py", line 1132, in _inner
    predictions = _predict(*data)
                  ^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\gradio_client\client.py", line 1249, in _predict
    raise AppError(
gradio_client.exceptions.AppError: The upstream Gradio app has raised an exception: gradio.data_classes.FileData() argument after ** must be a mapping, not bool

docker log

2024-11-08 12:32:58 Traceback (most recent call last):
2024-11-08 12:32:58   File "/usr/local/lib/python3.10/site-packages/gradio/queueing.py", line 528, in process_events
2024-11-08 12:32:58     response = await route_utils.call_process_api(
2024-11-08 12:32:58   File "/usr/local/lib/python3.10/site-packages/gradio/route_utils.py", line 270, in call_process_api
2024-11-08 12:32:58     output = await app.get_blocks().process_api(
2024-11-08 12:32:58   File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1904, in process_api
2024-11-08 12:32:58     inputs = await self.preprocess_data(
2024-11-08 12:32:58   File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1627, in preprocess_data
2024-11-08 12:32:58     inputs_cached = block.data_model(**inputs_cached)  # type: ignore
2024-11-08 12:32:58 TypeError: gradio.data_classes.FileData() argument after ** must be a mapping, not bool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant