llama-index-readers-assemblyai


Namellama-index-readers-assemblyai JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
Summaryllama-index readers assemblyai integration
upload_time2024-08-22 05:47:17
maintainerpatrickloeber
docs_urlNone
authorYour Name
requires_python<4.0,>=3.8.1
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # AssemblyAI Audio Transcript Loader

```bash
pip install llama-index-readers-assemblyai
```

The AssemblyAI Audio Transcript Loader allows to transcribe audio files with the [AssemblyAI API](https://www.assemblyai.com/) and loads the transcribed text into documents.

To use it, you should have the `assemblyai` python package installed, and the environment variable `ASSEMBLYAI_API_KEY` set with your API key. Alternatively, the API key can also be passed as an argument.

More info about AssemblyAI:

- [Website](https://www.assemblyai.com/)
- [Get a Free API key](https://www.assemblyai.com/dashboard/signup)
- [AssemblyAI API Docs](https://www.assemblyai.com/docs)

## Usage

The `AssemblyAIAudioTranscriptReader` needs at least the `file_path` argument. Audio files can be specified as an URL or a local file path.

```python
from llama_index.readers.assemblyai import AssemblyAIAudioTranscriptReader

audio_file = "https://storage.googleapis.com/aai-docs-samples/nbc.mp3"
# or a local file path: audio_file = "./nbc.mp3"

reader = AssemblyAIAudioTranscriptReader(file_path=audio_file)

docs = reader.load_data()
```

Note: Calling `reader.load_data()` blocks until the transcription is finished.

The transcribed text is available in the `text`:

```python
docs[0].text
# "Load time, a new president and new congressional makeup. Same old ..."
```

The `metadata` contains the full JSON response with more meta information:

```python
docs[0].metadata
# {'language_code': <LanguageCode.en_us: 'en_us'>,
#  'audio_url': 'https://storage.googleapis.com/aai-docs-samples/nbc.mp3',
#  'punctuate': True,
#  'format_text': True,
#   ...
# }
```

## Transcript Formats

You can specify the `transcript_format` argument for different formats.

Depending on the format, one or more documents are returned. These are the different `TranscriptFormat` options:

- `TEXT`: One document with the transcription text
- `SENTENCES`: Multiple documents, splits the transcription by each sentence
- `PARAGRAPHS`: Multiple documents, splits the transcription by each paragraph
- `SUBTITLES_SRT`: One document with the transcript exported in SRT subtitles format
- `SUBTITLES_VTT`: One document with the transcript exported in VTT subtitles format

```python
from llama_index.readers.assemblyai import TranscriptFormat

reader = AssemblyAIAudioTranscripReader(
    file_path="./your_file.mp3",
    transcript_format=TranscriptFormat.SENTENCES,
)

docs = reader.load_data()
```

# Transcription Config

You can also specify the `config` argument to use different audio intelligence models.

Visit the [AssemblyAI API Documentation](https://www.assemblyai.com/docs) to get an overview of all available models!

```python
import assemblyai as aai

config = aai.TranscriptionConfig(
    speaker_labels=True, auto_chapters=True, entity_detection=True
)

reader = AssemblyAIAudioTranscriptReader(
    file_path="./your_file.mp3", config=config
)
```

## Pass the API Key as argument

Next to setting the API key as environment variable `ASSEMBLYAI_API_KEY`, it is also possible to pass it as argument.

```python
reader = AssemblyAIAudioTranscriptReader(
    file_path="./your_file.mp3", api_key="YOUR_KEY"
)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "llama-index-readers-assemblyai",
    "maintainer": "patrickloeber",
    "docs_url": null,
    "requires_python": "<4.0,>=3.8.1",
    "maintainer_email": null,
    "keywords": null,
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/9f/97/55dd123a44171c6a2639c515da5a9a366cfba3895dfd8c04cef1f50bb3e2/llama_index_readers_assemblyai-0.2.0.tar.gz",
    "platform": null,
    "description": "# AssemblyAI Audio Transcript Loader\n\n```bash\npip install llama-index-readers-assemblyai\n```\n\nThe AssemblyAI Audio Transcript Loader allows to transcribe audio files with the [AssemblyAI API](https://www.assemblyai.com/) and loads the transcribed text into documents.\n\nTo use it, you should have the `assemblyai` python package installed, and the environment variable `ASSEMBLYAI_API_KEY` set with your API key. Alternatively, the API key can also be passed as an argument.\n\nMore info about AssemblyAI:\n\n- [Website](https://www.assemblyai.com/)\n- [Get a Free API key](https://www.assemblyai.com/dashboard/signup)\n- [AssemblyAI API Docs](https://www.assemblyai.com/docs)\n\n## Usage\n\nThe `AssemblyAIAudioTranscriptReader` needs at least the `file_path` argument. Audio files can be specified as an URL or a local file path.\n\n```python\nfrom llama_index.readers.assemblyai import AssemblyAIAudioTranscriptReader\n\naudio_file = \"https://storage.googleapis.com/aai-docs-samples/nbc.mp3\"\n# or a local file path: audio_file = \"./nbc.mp3\"\n\nreader = AssemblyAIAudioTranscriptReader(file_path=audio_file)\n\ndocs = reader.load_data()\n```\n\nNote: Calling `reader.load_data()` blocks until the transcription is finished.\n\nThe transcribed text is available in the `text`:\n\n```python\ndocs[0].text\n# \"Load time, a new president and new congressional makeup. Same old ...\"\n```\n\nThe `metadata` contains the full JSON response with more meta information:\n\n```python\ndocs[0].metadata\n# {'language_code': <LanguageCode.en_us: 'en_us'>,\n#  'audio_url': 'https://storage.googleapis.com/aai-docs-samples/nbc.mp3',\n#  'punctuate': True,\n#  'format_text': True,\n#   ...\n# }\n```\n\n## Transcript Formats\n\nYou can specify the `transcript_format` argument for different formats.\n\nDepending on the format, one or more documents are returned. These are the different `TranscriptFormat` options:\n\n- `TEXT`: One document with the transcription text\n- `SENTENCES`: Multiple documents, splits the transcription by each sentence\n- `PARAGRAPHS`: Multiple documents, splits the transcription by each paragraph\n- `SUBTITLES_SRT`: One document with the transcript exported in SRT subtitles format\n- `SUBTITLES_VTT`: One document with the transcript exported in VTT subtitles format\n\n```python\nfrom llama_index.readers.assemblyai import TranscriptFormat\n\nreader = AssemblyAIAudioTranscripReader(\n    file_path=\"./your_file.mp3\",\n    transcript_format=TranscriptFormat.SENTENCES,\n)\n\ndocs = reader.load_data()\n```\n\n# Transcription Config\n\nYou can also specify the `config` argument to use different audio intelligence models.\n\nVisit the [AssemblyAI API Documentation](https://www.assemblyai.com/docs) to get an overview of all available models!\n\n```python\nimport assemblyai as aai\n\nconfig = aai.TranscriptionConfig(\n    speaker_labels=True, auto_chapters=True, entity_detection=True\n)\n\nreader = AssemblyAIAudioTranscriptReader(\n    file_path=\"./your_file.mp3\", config=config\n)\n```\n\n## Pass the API Key as argument\n\nNext to setting the API key as environment variable `ASSEMBLYAI_API_KEY`, it is also possible to pass it as argument.\n\n```python\nreader = AssemblyAIAudioTranscriptReader(\n    file_path=\"./your_file.mp3\", api_key=\"YOUR_KEY\"\n)\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "llama-index readers assemblyai integration",
    "version": "0.2.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "49335aa0553e06a55144f8a75f4e08823167ca5b18eaeb043802ba4fda890655",
                "md5": "3cc67b16f62952454396b8aeb5566cd8",
                "sha256": "8b0878c273509c60a49a1ab3dbae90d48aa3bdefd441011b013658c47cb7aeb4"
            },
            "downloads": -1,
            "filename": "llama_index_readers_assemblyai-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3cc67b16f62952454396b8aeb5566cd8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8.1",
            "size": 4065,
            "upload_time": "2024-08-22T05:47:16",
            "upload_time_iso_8601": "2024-08-22T05:47:16.877364Z",
            "url": "https://files.pythonhosted.org/packages/49/33/5aa0553e06a55144f8a75f4e08823167ca5b18eaeb043802ba4fda890655/llama_index_readers_assemblyai-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9f9755dd123a44171c6a2639c515da5a9a366cfba3895dfd8c04cef1f50bb3e2",
                "md5": "11028e050c85bec5bdbe3fa04df31e63",
                "sha256": "7050753cb7d502d5ec3228203870eacb563dcc2b8778e893f4c08ddd00a13668"
            },
            "downloads": -1,
            "filename": "llama_index_readers_assemblyai-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "11028e050c85bec5bdbe3fa04df31e63",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8.1",
            "size": 3604,
            "upload_time": "2024-08-22T05:47:17",
            "upload_time_iso_8601": "2024-08-22T05:47:17.787398Z",
            "url": "https://files.pythonhosted.org/packages/9f/97/55dd123a44171c6a2639c515da5a9a366cfba3895dfd8c04cef1f50bb3e2/llama_index_readers_assemblyai-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-22 05:47:17",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-readers-assemblyai"
}
        
Elapsed time: 0.28420s