Spaces:
Sleeping
Sleeping
Create Whisper/API.md
Browse files- docs/Whisper/API.md +72 -0
docs/Whisper/API.md
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# API Documentation for `Lenylvt/Whisper-API`
|
2 |
+
This documentation outlines how to use the Whisper API through Python and JavaScript.
|
3 |
+
|
4 |
+
## API Endpoint
|
5 |
+
|
6 |
+
The API 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 |
+
## Python Usage
|
9 |
+
|
10 |
+
### Step 1: Installation
|
11 |
+
|
12 |
+
To begin, ensure the `gradio_client` library is installed.
|
13 |
+
|
14 |
+
```python
|
15 |
+
pip install gradio_client
|
16 |
+
```
|
17 |
+
|
18 |
+
### Step 2: Making a Request
|
19 |
+
|
20 |
+
Identify the API endpoint for the function you wish to utilize. Replace the placeholders in the following code snippet with your actual input data. If accessing a private Space, you may need to include your Hugging Face token.
|
21 |
+
|
22 |
+
**API Name**: `/predict`
|
23 |
+
|
24 |
+
```python
|
25 |
+
from gradio_client import Client
|
26 |
+
|
27 |
+
client = Client("Lenylvt/Whisper-API")
|
28 |
+
result = client.predict(
|
29 |
+
"https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav", # filepath in 'Upload Audio' Audio component
|
30 |
+
"base", # Model size in 'Model Size' Dropdown component (e.g., 'base', 'small', 'medium', 'large', 'large-v2', 'large-v3')
|
31 |
+
api_name="/predict"
|
32 |
+
)
|
33 |
+
print(result)
|
34 |
+
```
|
35 |
+
|
36 |
+
**Return Type(s):**
|
37 |
+
|
38 |
+
- A `str` representing the output in the 'output' Textbox component.
|
39 |
+
|
40 |
+
## JavaScript Usage
|
41 |
+
|
42 |
+
### Step 1: Installation
|
43 |
+
|
44 |
+
For JavaScript usage, make sure the `@gradio/client` package is included in your project.
|
45 |
+
|
46 |
+
```bash
|
47 |
+
npm i -D @gradio/client
|
48 |
+
```
|
49 |
+
|
50 |
+
### Step 2: Making a Request
|
51 |
+
|
52 |
+
Similar to Python, locate the API endpoint that fits your requirements. Replace the placeholder values with your own data. Include your Hugging Face token if you are accessing a private Space.
|
53 |
+
|
54 |
+
**API Name**: `/predict`
|
55 |
+
|
56 |
+
```javascript
|
57 |
+
import { client } from "@gradio/client";
|
58 |
+
const response_0 = await fetch("https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav");
|
59 |
+
const exampleAudio = await response_0.blob();
|
60 |
+
|
61 |
+
const app = await client("Lenylvt/Whisper-API");
|
62 |
+
const result = await app.predict("/predict", [
|
63 |
+
exampleAudio, // blob in 'Upload Audio' Audio component
|
64 |
+
"base", // string in 'Model Size' Dropdown component
|
65 |
+
]);
|
66 |
+
|
67 |
+
console.log(result.data);
|
68 |
+
```
|
69 |
+
|
70 |
+
**Return Type(s):**
|
71 |
+
|
72 |
+
- A `string` representing the output in the 'output' Textbox component.
|