# API Documentation for `Lenylvt/VideoSubtitleCreation-API` This documentation explains how to interact with the VideoSubtitleCreation API, which provides two main functionalities: transcribing and adding subtitles to videos, and translating subtitles before adding them to videos. It can be accessed using Python and JavaScript. ## API Endpoints The API provides two endpoints that can be accessed using the `gradio_client` Python library [docs](https://www.gradio.app/guides/getting-started-with-the-python-client) or the `@gradio/client` JavaScript package [docs](https://www.gradio.app/guides/getting-started-with-the-js-client). ### Common Step 1: Installation Before using the API, install the required client library. **For Python:** ```python pip install gradio_client ``` **For JavaScript:** ```bash npm i -D @gradio/client ``` ### API Endpoint: /transcribe_and_add_subtitles #### Python Usage ```python from gradio_client import Client client = Client("Lenylvt/VideoSubtitleCreation-API") result = client.predict( {"video": "https://github.com/gradio-app/gradio/raw/main/demo/video_component/files/world.mp4", "subtitles": None}, "tiny", api_name="/transcribe_and_add_subtitles" ) print(result) ``` **Return Type(s):** - A dictionary with keys `video` and `subtitles`, representing the output in 'Processed Video' Video component and the path to the 'Subtitles File (.srt)' File component, respectively. #### JavaScript Usage ```javascript import { client } from "@gradio/client"; const response_0 = await fetch("[object Object]"); const exampleVideo = await response_0.blob(); const app = await client("Lenylvt/VideoSubtitleCreation-API"); const result = await app.predict("/transcribe_and_add_subtitles", [ exampleVideo, "tiny" ]); console.log(result.data); ``` **Return Type(s):** - `undefined` values representing the output in both 'Processed Video' Video component and 'Subtitles File (.srt)' File component, due to a potential issue in the mock code snippet. ### API Endpoint: /translate_subtitles_and_add_to_video #### Python Usage ```python from gradio_client import Client client = Client("Lenylvt/VideoSubtitleCreation-API") result = client.predict( {"video": "https://github.com/gradio-app/gradio/raw/main/demo/video_component/files/world.mp4", "subtitles": None}, "aa", "aa", "tiny", api_name="/translate_subtitles_and_add_to_video" ) print(result) ``` **Return Type(s):** - A dictionary similar to the first endpoint, including processed video and subtitle file paths. #### JavaScript Usage ```javascript import { client } from "@gradio/client"; const response_0 = await fetch("[object Object]"); const exampleVideo = await response_0.blob(); const app = await client("Lenylvt/VideoSubtitleCreation-API"); const result = await app.predict("/translate_subtitles_and_add_to_video", [ exampleVideo, "aa", "aa", "tiny" ]); console.log(result.data); ``` **Return Type(s):** - `undefined` values for both 'Processed Video' and 'Subtitles File (.srt)' components, due to a potential issue in the mock code snippet.