https://github.com/abdouaziz/performance_test
https://github.com/abdouaziz/performance_test
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/abdouaziz/performance_test
- Owner: abdouaziz
- Created: 2025-02-18T11:18:13.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-02-18T11:26:57.000Z (3 months ago)
- Last Synced: 2025-02-18T12:30:48.410Z (3 months ago)
- Language: Python
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
# TTS Bulk Translator
## Overview
The `TTSBulkTranslator` is an asynchronous Python script that sends bulk requests to a Text-to-Speech (TTS) API for translation. It allows configuring batch sizes, rate limits, and the total number of requests to process efficiently while handling errors gracefully.## Features
- Sends multiple translation requests in batches.
- Implements a rate limit to prevent excessive API calls.
- Uses `asyncio` and `aiohttp` for efficient asynchronous requests.
- Tracks progress using `tqdm.asyncio`.
- Logs successful and failed requests to JSON files.## Installation
Ensure you have Python 3.7 or higher installed. Then, install the required dependencies:
```bash
pip install aiohttp tqdm
```## Usage
Run the script using:
```bash
python script.py
```## Configuration
The script allows customization of the following parameters:
- **`url`**: API endpoint for TTS translation.
- **`batch_size`**: Number of concurrent requests sent per batch.
- **`rate_limit`**: Maximum number of requests per second.
- **`total_requests`**: Total number of requests to be sent.Modify the `main()` function to adjust these settings:
```python
translator = TTSBulkTranslator(
url="https://devtts.lafricamobile.com/tts/translate",
batch_size=10, # Number of requests per batch
rate_limit=5, # Requests per second
total_requests=100 # Total number of requests to make
)
```## Expected Output
The script will display a progress bar while processing requests. Once completed, a summary report is printed:```
Starting bulk translation...
Translation Progress: 100%|█████████| 100/100 [00:20<00:00, 5.00 requests/s]Summary:
Total time: 20.00 seconds
Successful requests: 95
Failed requests: 5
```## Output Files
The script saves results as JSON files:- `successful_requests_.json`: Contains successful translations.
- `failed_requests_.json`: Logs failed requests with error details.## Error Handling
Errors are captured and logged in the `errors` list. The script retries within the batch execution, but persistent failures are recorded separately.