Metadata-Version: 2.4
Name: 60db
Version: 1.0.8
Summary: Official 60db SDK for Python
Author: 60db
License: MIT
Keywords: 60db,tts,stt,voice,ai
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.28.0
Requires-Dist: typing-extensions>=4.0.0

# 60db

Official 60db SDK for Python

## Installation

```bash
pip install 60db
```

## Quick Start

```python
from sixtydb import SixtyDBClient


def fetch_and_display_voices(client: SixtyDBClient) -> str:
    """
    Fetch all available voices and print their details.

    Returns:
        str: Selected voice_id
    """
    try:
        response = client.get_voices()
    except Exception as exc:
        print("Error fetching voices:", exc)
        raise

    if not response.get("success"):
        raise Exception(response.get("message"))

    voices = response["data"]["built_in_voices"]

    if not voices:
        raise Exception("No voices available.")

    print("\nAvailable Voices:\n" + "-" * 40)

    for voice in voices:
        print(
            f"Name: {voice.get('name')} | "
            f"Voice ID: {voice.get('voice_id')} | "
            f"Language: {voice.get('language_name')} | "
            f"Gender: {voice.get('gender')}"
        )

    return voices[0]["voice_id"]


def generate_speech(client: SixtyDBClient, voice_id: str) -> None:
    """
    Generate speech and save to file.
    """
    try:
        audio = client.text_to_speech(
            text="Hello, world!",
            voice_id=voice_id,
            speed=1.0
        )

        with open("output.mp3", "wb") as file:
            file.write(audio)

        print("\nAudio saved to output.mp3")

    except Exception as exc:
        print("Error generating speech:", exc)
        raise


def main() -> None:
    try:
        client = SixtyDBClient("your-api-key")
    except Exception as exc:
        print("Error creating client:", exc)
        return

    try:
        voice_id = fetch_and_display_voices(client)
        generate_speech(client, voice_id)
    except Exception as exc:
        print("Operation failed:", exc)


if __name__ == "__main__":
    main()
```

---

## API Methods

### Text-to-Speech
- `text_to_speech(text, voice_id=None, **params)` – Convert text to speech

### Speech-to-Text
- `speech_to_text(audio_file, language=None)` – Transcribe audio
- `get_languages()` – Get supported languages

### Voices
- `get_voices()` – List all voices

---

## Example: Speech to Text

```python
from sixtydb import SixtyDBClient

client = SixtyDBClient("your-api-key")

try:
    with open("output.mp3", "rb") as file:
        result = client.speech_to_text(file, language="en")

    if result.get("success"):
        print("Transcription:", result["data"]["text"])
    else:
        print("STT Error:", result.get("message"))

except Exception as exc:
    print("Error during transcription:", exc)
```

---

## License

MIT
