Spaces:
Sleeping
Sleeping
# API Documentation for `Lenylvt/Whisper-API` | |
This documentation outlines how to use the Whisper API through Python and JavaScript. | |
## API Endpoint | |
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). | |
## Python Usage | |
### Step 1: Installation | |
To begin, ensure the `gradio_client` library is installed. | |
```python | |
pip install gradio_client | |
``` | |
### Step 2: Making a Request | |
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. | |
**API Name**: `/predict` | |
```python | |
from gradio_client import Client | |
client = Client("Lenylvt/Whisper-API") | |
result = client.predict( | |
"https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav", # filepath in 'Upload Audio' Audio component | |
"base", # Model size in 'Model Size' Dropdown component (e.g., 'base', 'small', 'medium', 'large', 'large-v2', 'large-v3') | |
api_name="/predict" | |
) | |
print(result) | |
``` | |
**Return Type(s):** | |
- A `str` representing the output in the 'output' Textbox component. | |
## JavaScript Usage | |
### Step 1: Installation | |
For JavaScript usage, make sure the `@gradio/client` package is included in your project. | |
```bash | |
npm i -D @gradio/client | |
``` | |
### Step 2: Making a Request | |
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. | |
**API Name**: `/predict` | |
```javascript | |
import { client } from "@gradio/client"; | |
const response_0 = await fetch("https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav"); | |
const exampleAudio = await response_0.blob(); | |
const app = await client("Lenylvt/Whisper-API"); | |
const result = await app.predict("/predict", [ | |
exampleAudio, // blob in 'Upload Audio' Audio component | |
"base", // string in 'Model Size' Dropdown component | |
]); | |
console.log(result.data); | |
``` | |
**Return Type(s):** | |
- A `string` representing the output in the 'output' Textbox component. |