aiola


Nameaiola JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryThe official Python SDK for aiOla API - Speech-to-Text and Text-to-Speech
upload_time2025-07-16 16:48:15
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License Copyright (c) 2025 Aiola Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords aiola audio microphone speech speech-to-text stt text-to-speech tts
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # aiOla Python SDK

The official Python SDK for the [aiOla](https://aiola.com) API, designed to work seamlessly in both synchronous and asynchronous environments.

## Installation

### Basic Installation

```bash
pip install aiola
# or
uv add aiola
```

### With Microphone Support

For microphone streaming functionality, install with the mic extra:

```bash
pip install 'aiola[mic]'
# or
uv add 'aiola[mic]'
```

## Usage

### Authentication

The aiOla SDK uses a **two-step authentication process**:

1. **Generate Access Token**: Use your API key to create a temporary access token, save it for later use
2. **Create Client**: Use the access token to instantiate the client

#### Step 1: Generate Access Token

```python
from aiola import AiolaClient

result = AiolaClient.grant_token(
    api_key='your-api-key'
)

access_token = result['accessToken'] 
session_id = result['sessionId']
```

#### Step 2: Create Client

```python
client = AiolaClient(
    access_token=access_token
)
```

#### Complete Example

```python
import os
from aiola import AiolaClient

def example():
    try:
        # Step 1: Generate access token
        result = AiolaClient.grant_token(
            api_key=os.getenv('AIOLA_API_KEY')
        )
        
        # Step 2: Create client
        client = AiolaClient(
            access_token=result['accessToken']
        )
        
        # Step 3: Use client for API calls
        with open('path/to/your/audio.wav', 'rb') as audio_file:
            transcript = client.stt.transcribe_file(
                file=audio_file,
                language='en'
            )
        
        print('Transcript:', transcript)
        
    except Exception as error:
        print('Error:', error)
```

#### Session Management

**Close Session:**
```python
# Terminates the session
result = AiolaClient.close_session(access_token)
print(f"Session closed at: {result['deletedAt']}")
```

#### Custom base URL (enterprises)

```python
result = AiolaClient.grant_token(
    api_key='your-api-key',
    auth_base_url='https://mycompany.auth.aiola.ai'
)

client = AiolaClient(
    access_token=result['accessToken'],
    base_url='https://mycompany.api.aiola.ai'
)
```

### Speech-to-Text – transcribe file

```python
import os
from aiola import AiolaClient

def transcribe_file():
    try:
        # Step 1: Generate access token
        result = AiolaClient.grant_token(
            api_key=os.getenv('AIOLA_API_KEY')
        )
        
        # Step 2: Create client
        client = AiolaClient(
            access_token=result['accessToken']
        )
        
        # Step 3: Transcribe file
        with open('path/to/your/audio.wav', 'rb') as audio_file:
            transcript = client.stt.transcribe_file(
                file=audio_file,
                language="en"
            )

        print(transcript)
    except Exception as error:
        print('Error transcribing file:', error)
```

### Speech-to-Text – live streaming

```python
import os
import time
from aiola import AiolaClient, MicrophoneStream # pip install 'aiola[mic]'
from aiola.types import LiveEvents


def live_streaming():
    try:
        result = AiolaClient.grant_token(
            api_key=os.getenv("AIOLA_API_KEY") or "YOUR_API_KEY"
        )
        client = AiolaClient(access_token=result["accessToken"])
        connection = client.stt.stream(lang_code="en")

        @connection.on(LiveEvents.Transcript)
        def on_transcript(data):
            print("Transcript:", data.get("transcript", data))

        @connection.on(LiveEvents.Connect)
        def on_connect():
            print("Connected to streaming service")

        @connection.on(LiveEvents.Disconnect)
        def on_disconnect():
            print("Disconnected from streaming service")

        @connection.on(LiveEvents.Error)
        def on_error(error):
            print("Streaming error:", error)

        connection.connect()

        with MicrophoneStream(channels=1, samplerate=16000, blocksize=4096) as mic:
            mic.stream_to(connection)
            # Keep the main thread alive
            while True:
                time.sleep(0.1)

    except KeyboardInterrupt:
        print("Keyboard interrupt")
    except Exception as error:
        print("Error:", error)
    finally:
        connection.disconnect()
```

### Text-to-Speech

```python
import os
from aiola import AiolaClient

def create_file():
    try:
        result = AiolaClient.grant_token(
            api_key=os.getenv('AIOLA_API_KEY')
        )

        client = AiolaClient(
            access_token=result['accessToken']
        )
        
        audio = client.tts.synthesize(
            text='Hello, how can I help you today?',
            voice='jess',
            language='en'
        )

        with open('./audio.wav', 'wb') as f:
            for chunk in audio:
                f.write(chunk)
        
        print('Audio file created successfully')
    except Exception as error:
        print('Error creating audio file:', error)

create_file()
```

### Text-to-Speech – streaming

```python
import os
from aiola import AiolaClient

def stream_tts():
    try:
        result = AiolaClient.grant_token(
            api_key=os.getenv('AIOLA_API_KEY')
        )
        
        client = AiolaClient(
            access_token=result['accessToken']
        )
        
        stream = client.tts.stream(
            text='Hello, how can I help you today?',
            voice='jess',
            language='en'
        )

        audio_chunks = []
        for chunk in stream:
            audio_chunks.append(chunk)
        
        print('Audio chunks received:', len(audio_chunks))
    except Exception as error:
        print('Error streaming TTS:', error)
```

## Async Client

For asynchronous operations, use the `AsyncAiolaClient`:

### Async Speech-to-Text – file transcription

```python
import asyncio
import os
from aiola import AsyncAiolaClient

async def transcribe_file():
    try:
        result = await AsyncAiolaClient.grant_token(
            api_key=os.getenv('AIOLA_API_KEY')
        )
        
        client = AsyncAiolaClient(
            access_token=result['accessToken']
        )
        
        with open('path/to/your/audio.wav', 'rb') as audio_file:
            transcript = await client.stt.transcribe_file(
                file=audio_file,
                language="en"
            )

        print(transcript)
    except Exception as error:
        print('Error transcribing file:', error)

if __name__ == "__main__":
    asyncio.run(transcribe_file())
```

### Async Text-to-Speech

```python
import asyncio
import os
from aiola import AsyncAiolaClient

async def create_audio_file():
    try:
        result = await AsyncAiolaClient.grant_token(
            api_key=os.getenv('AIOLA_API_KEY')
        )
        
        client = AsyncAiolaClient(
            access_token=result['accessToken']
        )
        
        audio = client.tts.synthesize(
            text='Hello, how can I help you today?',
            voice='jess',
            language='en'
        )

        with open('./audio.wav', 'wb') as f:
            async for chunk in audio:
                f.write(chunk)
        
        print('Audio file created successfully')
    except Exception as error:
        print('Error creating audio file:', error)

if __name__ == "__main__":
    asyncio.run(create_audio_file())
```

### Async Text-to-Speech – streaming

```python
import asyncio
import os
from aiola import AsyncAiolaClient

async def stream_tts():
    try:
        result = await AsyncAiolaClient.grant_token(
            api_key=os.getenv('AIOLA_API_KEY')
        )
        
        client = AsyncAiolaClient(
            access_token=result['accessToken']
        )
        
        stream = client.tts.stream(
            text='Hello, how can I help you today?',
            voice='jess',
            language='en'
        )

        audio_chunks = []
        async for chunk in stream:
            audio_chunks.append(chunk)
        
        print('Audio chunks received:', len(audio_chunks))
    except Exception as error:
        print('Error streaming TTS:', error)

if __name__ == "__main__":
    asyncio.run(stream_tts())
```

## Requirements

- Python 3.10+
- For microphone streaming functionality: Install with `pip install 'aiola[mic]'`

## Examples

The SDK includes several example scripts in the `examples/` directory.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "aiola",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "aiOla <support@aiola.ai>",
    "keywords": "aiola, audio, microphone, speech, speech-to-text, stt, text-to-speech, tts",
    "author": null,
    "author_email": "aiOla <support@aiola.ai>",
    "download_url": "https://files.pythonhosted.org/packages/b6/5b/23099e8aaa2df9303e49ac5de145934548cac9526cbf196cfabbad027801/aiola-0.1.1.tar.gz",
    "platform": null,
    "description": "# aiOla Python SDK\n\nThe official Python SDK for the [aiOla](https://aiola.com) API, designed to work seamlessly in both synchronous and asynchronous environments.\n\n## Installation\n\n### Basic Installation\n\n```bash\npip install aiola\n# or\nuv add aiola\n```\n\n### With Microphone Support\n\nFor microphone streaming functionality, install with the mic extra:\n\n```bash\npip install 'aiola[mic]'\n# or\nuv add 'aiola[mic]'\n```\n\n## Usage\n\n### Authentication\n\nThe aiOla SDK uses a **two-step authentication process**:\n\n1. **Generate Access Token**: Use your API key to create a temporary access token, save it for later use\n2. **Create Client**: Use the access token to instantiate the client\n\n#### Step 1: Generate Access Token\n\n```python\nfrom aiola import AiolaClient\n\nresult = AiolaClient.grant_token(\n    api_key='your-api-key'\n)\n\naccess_token = result['accessToken'] \nsession_id = result['sessionId']\n```\n\n#### Step 2: Create Client\n\n```python\nclient = AiolaClient(\n    access_token=access_token\n)\n```\n\n#### Complete Example\n\n```python\nimport os\nfrom aiola import AiolaClient\n\ndef example():\n    try:\n        # Step 1: Generate access token\n        result = AiolaClient.grant_token(\n            api_key=os.getenv('AIOLA_API_KEY')\n        )\n        \n        # Step 2: Create client\n        client = AiolaClient(\n            access_token=result['accessToken']\n        )\n        \n        # Step 3: Use client for API calls\n        with open('path/to/your/audio.wav', 'rb') as audio_file:\n            transcript = client.stt.transcribe_file(\n                file=audio_file,\n                language='en'\n            )\n        \n        print('Transcript:', transcript)\n        \n    except Exception as error:\n        print('Error:', error)\n```\n\n#### Session Management\n\n**Close Session:**\n```python\n# Terminates the session\nresult = AiolaClient.close_session(access_token)\nprint(f\"Session closed at: {result['deletedAt']}\")\n```\n\n#### Custom base URL (enterprises)\n\n```python\nresult = AiolaClient.grant_token(\n    api_key='your-api-key',\n    auth_base_url='https://mycompany.auth.aiola.ai'\n)\n\nclient = AiolaClient(\n    access_token=result['accessToken'],\n    base_url='https://mycompany.api.aiola.ai'\n)\n```\n\n### Speech-to-Text \u2013 transcribe file\n\n```python\nimport os\nfrom aiola import AiolaClient\n\ndef transcribe_file():\n    try:\n        # Step 1: Generate access token\n        result = AiolaClient.grant_token(\n            api_key=os.getenv('AIOLA_API_KEY')\n        )\n        \n        # Step 2: Create client\n        client = AiolaClient(\n            access_token=result['accessToken']\n        )\n        \n        # Step 3: Transcribe file\n        with open('path/to/your/audio.wav', 'rb') as audio_file:\n            transcript = client.stt.transcribe_file(\n                file=audio_file,\n                language=\"en\"\n            )\n\n        print(transcript)\n    except Exception as error:\n        print('Error transcribing file:', error)\n```\n\n### Speech-to-Text \u2013 live streaming\n\n```python\nimport os\nimport time\nfrom aiola import AiolaClient, MicrophoneStream # pip install 'aiola[mic]'\nfrom aiola.types import LiveEvents\n\n\ndef live_streaming():\n    try:\n        result = AiolaClient.grant_token(\n            api_key=os.getenv(\"AIOLA_API_KEY\") or \"YOUR_API_KEY\"\n        )\n        client = AiolaClient(access_token=result[\"accessToken\"])\n        connection = client.stt.stream(lang_code=\"en\")\n\n        @connection.on(LiveEvents.Transcript)\n        def on_transcript(data):\n            print(\"Transcript:\", data.get(\"transcript\", data))\n\n        @connection.on(LiveEvents.Connect)\n        def on_connect():\n            print(\"Connected to streaming service\")\n\n        @connection.on(LiveEvents.Disconnect)\n        def on_disconnect():\n            print(\"Disconnected from streaming service\")\n\n        @connection.on(LiveEvents.Error)\n        def on_error(error):\n            print(\"Streaming error:\", error)\n\n        connection.connect()\n\n        with MicrophoneStream(channels=1, samplerate=16000, blocksize=4096) as mic:\n            mic.stream_to(connection)\n            # Keep the main thread alive\n            while True:\n                time.sleep(0.1)\n\n    except KeyboardInterrupt:\n        print(\"Keyboard interrupt\")\n    except Exception as error:\n        print(\"Error:\", error)\n    finally:\n        connection.disconnect()\n```\n\n### Text-to-Speech\n\n```python\nimport os\nfrom aiola import AiolaClient\n\ndef create_file():\n    try:\n        result = AiolaClient.grant_token(\n            api_key=os.getenv('AIOLA_API_KEY')\n        )\n\n        client = AiolaClient(\n            access_token=result['accessToken']\n        )\n        \n        audio = client.tts.synthesize(\n            text='Hello, how can I help you today?',\n            voice='jess',\n            language='en'\n        )\n\n        with open('./audio.wav', 'wb') as f:\n            for chunk in audio:\n                f.write(chunk)\n        \n        print('Audio file created successfully')\n    except Exception as error:\n        print('Error creating audio file:', error)\n\ncreate_file()\n```\n\n### Text-to-Speech \u2013 streaming\n\n```python\nimport os\nfrom aiola import AiolaClient\n\ndef stream_tts():\n    try:\n        result = AiolaClient.grant_token(\n            api_key=os.getenv('AIOLA_API_KEY')\n        )\n        \n        client = AiolaClient(\n            access_token=result['accessToken']\n        )\n        \n        stream = client.tts.stream(\n            text='Hello, how can I help you today?',\n            voice='jess',\n            language='en'\n        )\n\n        audio_chunks = []\n        for chunk in stream:\n            audio_chunks.append(chunk)\n        \n        print('Audio chunks received:', len(audio_chunks))\n    except Exception as error:\n        print('Error streaming TTS:', error)\n```\n\n## Async Client\n\nFor asynchronous operations, use the `AsyncAiolaClient`:\n\n### Async Speech-to-Text \u2013 file transcription\n\n```python\nimport asyncio\nimport os\nfrom aiola import AsyncAiolaClient\n\nasync def transcribe_file():\n    try:\n        result = await AsyncAiolaClient.grant_token(\n            api_key=os.getenv('AIOLA_API_KEY')\n        )\n        \n        client = AsyncAiolaClient(\n            access_token=result['accessToken']\n        )\n        \n        with open('path/to/your/audio.wav', 'rb') as audio_file:\n            transcript = await client.stt.transcribe_file(\n                file=audio_file,\n                language=\"en\"\n            )\n\n        print(transcript)\n    except Exception as error:\n        print('Error transcribing file:', error)\n\nif __name__ == \"__main__\":\n    asyncio.run(transcribe_file())\n```\n\n### Async Text-to-Speech\n\n```python\nimport asyncio\nimport os\nfrom aiola import AsyncAiolaClient\n\nasync def create_audio_file():\n    try:\n        result = await AsyncAiolaClient.grant_token(\n            api_key=os.getenv('AIOLA_API_KEY')\n        )\n        \n        client = AsyncAiolaClient(\n            access_token=result['accessToken']\n        )\n        \n        audio = client.tts.synthesize(\n            text='Hello, how can I help you today?',\n            voice='jess',\n            language='en'\n        )\n\n        with open('./audio.wav', 'wb') as f:\n            async for chunk in audio:\n                f.write(chunk)\n        \n        print('Audio file created successfully')\n    except Exception as error:\n        print('Error creating audio file:', error)\n\nif __name__ == \"__main__\":\n    asyncio.run(create_audio_file())\n```\n\n### Async Text-to-Speech \u2013 streaming\n\n```python\nimport asyncio\nimport os\nfrom aiola import AsyncAiolaClient\n\nasync def stream_tts():\n    try:\n        result = await AsyncAiolaClient.grant_token(\n            api_key=os.getenv('AIOLA_API_KEY')\n        )\n        \n        client = AsyncAiolaClient(\n            access_token=result['accessToken']\n        )\n        \n        stream = client.tts.stream(\n            text='Hello, how can I help you today?',\n            voice='jess',\n            language='en'\n        )\n\n        audio_chunks = []\n        async for chunk in stream:\n            audio_chunks.append(chunk)\n        \n        print('Audio chunks received:', len(audio_chunks))\n    except Exception as error:\n        print('Error streaming TTS:', error)\n\nif __name__ == \"__main__\":\n    asyncio.run(stream_tts())\n```\n\n## Requirements\n\n- Python 3.10+\n- For microphone streaming functionality: Install with `pip install 'aiola[mic]'`\n\n## Examples\n\nThe SDK includes several example scripts in the `examples/` directory.",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2025 Aiola  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "The official Python SDK for aiOla API - Speech-to-Text and Text-to-Speech",
    "version": "0.1.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/aiola-lab/aiola-python-sdk/issues",
        "Homepage": "https://aiola.ai",
        "Repository": "https://github.com/aiola-lab/aiola-python-sdk"
    },
    "split_keywords": [
        "aiola",
        " audio",
        " microphone",
        " speech",
        " speech-to-text",
        " stt",
        " text-to-speech",
        " tts"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "db660493f1e47380375b3f7be919b1ea7dffff7f916f27e2ec6b036e9f0ef797",
                "md5": "0b814426a689786b9e20d706dbbfc334",
                "sha256": "314c72d1eef12f91e00ca358211a1e04a3563182596251dbd7e428b39beaf9bc"
            },
            "downloads": -1,
            "filename": "aiola-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0b814426a689786b9e20d706dbbfc334",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 21085,
            "upload_time": "2025-07-16T16:48:14",
            "upload_time_iso_8601": "2025-07-16T16:48:14.103221Z",
            "url": "https://files.pythonhosted.org/packages/db/66/0493f1e47380375b3f7be919b1ea7dffff7f916f27e2ec6b036e9f0ef797/aiola-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b65b23099e8aaa2df9303e49ac5de145934548cac9526cbf196cfabbad027801",
                "md5": "1929346210a8c074796fec1bac062bf7",
                "sha256": "03826c13563e17c2d4b8f5368ca87cc05f099416aea560f7e651a22753564091"
            },
            "downloads": -1,
            "filename": "aiola-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1929346210a8c074796fec1bac062bf7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 17061,
            "upload_time": "2025-07-16T16:48:15",
            "upload_time_iso_8601": "2025-07-16T16:48:15.172594Z",
            "url": "https://files.pythonhosted.org/packages/b6/5b/23099e8aaa2df9303e49ac5de145934548cac9526cbf196cfabbad027801/aiola-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-16 16:48:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aiola-lab",
    "github_project": "aiola-python-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "aiola"
}
        
Elapsed time: 1.77814s