Lenylvt commited on
Commit
6ac5943
β€’
1 Parent(s): 1005544

Create Powerful/VideoSubtitleCreation.md

Browse files
docs/Powerful/VideoSubtitleCreation.md ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # API Documentation for `Lenylvt/VideoSubtitleCreation-API`
2
+ 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.
3
+
4
+ ## API Endpoints
5
+
6
+ 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).
7
+
8
+ ### Common Step 1: Installation
9
+
10
+ Before using the API, install the required client library.
11
+
12
+ **For Python:**
13
+
14
+ ```python
15
+ pip install gradio_client
16
+ ```
17
+
18
+ **For JavaScript:**
19
+
20
+ ```bash
21
+ npm i -D @gradio/client
22
+ ```
23
+
24
+ ### API Endpoint: /transcribe_and_add_subtitles
25
+
26
+ #### Python Usage
27
+
28
+ ```python
29
+ from gradio_client import Client
30
+
31
+ client = Client("Lenylvt/VideoSubtitleCreation-API")
32
+ result = client.predict(
33
+ {"video": "https://github.com/gradio-app/gradio/raw/main/demo/video_component/files/world.mp4", "subtitles": None},
34
+ "tiny",
35
+ api_name="/transcribe_and_add_subtitles"
36
+ )
37
+ print(result)
38
+ ```
39
+
40
+ **Return Type(s):**
41
+
42
+ - 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.
43
+
44
+ #### JavaScript Usage
45
+
46
+ ```javascript
47
+ import { client } from "@gradio/client";
48
+
49
+ const response_0 = await fetch("[object Object]");
50
+ const exampleVideo = await response_0.blob();
51
+
52
+ const app = await client("Lenylvt/VideoSubtitleCreation-API");
53
+ const result = await app.predict("/transcribe_and_add_subtitles", [
54
+ exampleVideo,
55
+ "tiny"
56
+ ]);
57
+
58
+ console.log(result.data);
59
+ ```
60
+
61
+ **Return Type(s):**
62
+
63
+ - `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.
64
+
65
+ ### API Endpoint: /translate_subtitles_and_add_to_video
66
+
67
+ #### Python Usage
68
+
69
+ ```python
70
+ from gradio_client import Client
71
+
72
+ client = Client("Lenylvt/VideoSubtitleCreation-API")
73
+ result = client.predict(
74
+ {"video": "https://github.com/gradio-app/gradio/raw/main/demo/video_component/files/world.mp4", "subtitles": None},
75
+ "aa",
76
+ "aa",
77
+ "tiny",
78
+ api_name="/translate_subtitles_and_add_to_video"
79
+ )
80
+ print(result)
81
+ ```
82
+
83
+ **Return Type(s):**
84
+
85
+ - A dictionary similar to the first endpoint, including processed video and subtitle file paths.
86
+
87
+ #### JavaScript Usage
88
+
89
+ ```javascript
90
+ import { client } from "@gradio/client";
91
+
92
+ const response_0 = await fetch("[object Object]");
93
+ const exampleVideo = await response_0.blob();
94
+
95
+ const app = await client("Lenylvt/VideoSubtitleCreation-API");
96
+ const result = await app.predict("/translate_subtitles_and_add_to_video", [
97
+ exampleVideo,
98
+ "aa",
99
+ "aa",
100
+ "tiny"
101
+ ]);
102
+
103
+ console.log(result.data);
104
+ ```
105
+
106
+ **Return Type(s):**
107
+
108
+ - `undefined` values for both 'Processed Video' and 'Subtitles File (.srt)' components, due to a potential issue in the mock code snippet.