Metadata-Version: 2.4
Name: egrobots-sa-client
Version: 2.0.1
Summary: Python client for Egrobots Arabic Speech Analysis service
Author-email: Egrobots <moamen.moustafa@egrobots.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/Mox301/egrobots-audio-analysis-agent-demo
Project-URL: Documentation, https://github.com/Mox301/egrobots-audio-analysis-agent-demo/blob/main/backend_client/CLIENT_USAGE.md
Project-URL: Repository, https://github.com/Mox301/egrobots-audio-analysis-agent-demo
Project-URL: Issues, https://github.com/Mox301/egrobots-audio-analysis-agent-demo/issues
Keywords: arabic,audio,conversation,analysis,speech,nlp
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: requests>=2.28.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
Requires-Dist: build>=0.10; extra == "dev"
Requires-Dist: twine>=4.0; extra == "dev"

# Egrobots SA Client

Python client for Egrobots Arabic Speech Analysis service.

## Installation

```bash
pip install egrobots-sa-client
```

## Quick Start

```python
from egrobots_sa_client import EgrobotsSSAClient

client = EgrobotsSSAClient()

# Conversation analysis
result = client.analyze(
    audio="audio.mp3",
    enable_translation=False  # Set True for EN + AR
)
```

## Configuration

Create a `.env` file:

```env
BASE_URL=https://your-service.com
```

## Features

- **Conversation Analysis**: Analyze audio conversations with speaker diarization
- **Bilingual Support**: Get responses in both English and Arabic
- **Progress Tracking**: Monitor upload and processing progress
- **Retry Logic**: Automatic retries for failed requests

## Usage

### Basic Analysis

```python
from egrobots_sa_client import EgrobotsSSAClient

client = EgrobotsSSAClient()

# Analyze audio file
result = client.analyze(audio="audio.mp3")
print(result)
```

### With Bilingual Support

```python
result = client.analyze(
    audio="audio.mp3",
    enable_translation=True
)

# Check if bilingual
if client.is_bilingual_response(result):
    en_result = client.extract_language_version(result, 'EN')
    ar_result = client.extract_language_version(result, 'AR')
```

### Using Audio Bytes

```python
with open("audio.mp3", "rb") as f:
    audio_bytes = f.read()

result = client.analyze(
    audio=audio_bytes,
    file_name="audio.mp3"
)
```

### Progress Monitoring

```python
def progress_handler(event_type, data):
    print(f"[{event_type}] {data}")

result = client.analyze(
    audio="audio.mp3",
    progress_callback=progress_handler
)
```

## API Reference

### `analyze()`

Main method for conversation analysis.

**Parameters:**
- `audio` (str | bytes): Path to audio file or audio bytes
- `file_name` (str): Filename when using bytes (default: "audio.wav")
- `enable_translation` (bool): Enable EN + AR bilingual response (default: False)
- `progress_callback` (Callable): Progress handler function
- `max_retries` (int): Maximum retry attempts (default: 3)
- `retry_delay` (int): Delay between retries in seconds (default: 2)

**Returns:** Dict containing analysis results

### Helper Methods

- `is_bilingual_response(result)` - Check if response has EN/AR keys
- `extract_language_version(result, language)` - Extract 'EN' or 'AR' version

## Documentation

See [CLIENT_USAGE.md](https://github.com/Mox301/egrobots-audio-analysis-agent-demo/blob/main/backend_client/CLIENT_USAGE.md) for full documentation.

## License

MIT
