topcast


Nametopcast JSON
Version 0.1.7 PyPI version JSON
download
home_pagehttps://github.com/gormlabenz/topcast
SummaryA Python package for Topcast
upload_time2023-04-27 21:25:32
maintainer
docs_urlNone
authorGorm Labenz
requires_python>=3.7
licenseMIT
keywords topcast tts text-to-speech gcp google openai elevenlabs
VCS
bugtrack_url
requirements elevenlabs openai protobuf pydantic pydub gTTS
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Topcast: Turn Text into Podcasts with TTS and ChatGPT

Topcast is a Python package that allows you to transform text into a podcast using Text-to-Speech (TTS) and language models. With Topcast, you can provide a text, and the package will create a podcast with an introduction, interview, conclusion, sound effects, and more. Topcast supports various TTS providers and language models.
## Example
Generated using ChatGPT themes: Introduction with the ElevenLabs TTS Provider, Interview with the GCP TTS Provider and Summary also with the ElevenLabs TTS Provider.



https://user-images.githubusercontent.com/53308156/234994155-2921b28a-9caa-46fc-9608-5ef01881713e.mp4


## Example Implementation

```python
from topcast import Topcaster, set_openai_api_key
from topcast.chatgpt_themes import Introduction

set_openai_api_key("XXX-XXX-XXX-XXX-XXX")

topcast = Topcaster()

topcast.add_chapter(audio_layers=[{ "audio" : "sounds/jingle.wav" }])
topcast.add_chapter(
    audio_layers=[
        {
            "audio": {
                "content": "Topcast is a Python package that allows you to transform text into a podcast using Text-to-Speech (TTS) and language models. With Topcast, you can provide a text, and the package will create a podcast with an introduction, interview, conclusion, sound effects, and more. Topcast supports various TTS providers and language models.",
                "theme": Introduction,
            },
        },
    ],
    crossfade=2400,
)

topcast.generate()
topcast.export("podcast.wav", format="wav")


```

## Installation
Install the package using pip:

```bash
pip install topcast
```

## Usage

1. Import the necessary modules and set the API keys:

```python
from topcast import (
    set_elevenlab_api_key,
    set_google_credentials,
    set_openai_api_key,
    Topcaster,
)

from topcast.tts_providers import GCP
from topcast.chatgpt_themes import Summary

set_elevenlab_api_key("XXX-XXX-XXX") # if you want to use elvenlabs for tts
set_google_credentials("gcp-keyfile.json") # if you want google cloud platform for tts
set_openai_api_key("XXX-XXX-XXX") # if you want to use a ChatGPT theme
```

2. Create a Topcaster object and add chapters with the desired podcast structure:

```python
topcast = Topcaster()

topcast.add_chapter(
    audio_layers=[
        {
            "audio": "sounds/jingle.wav", # use a audio file
            "sets_length": True,
        }
    ]
)
topcast.add_chapter(
    audio_layers=[
        {
            "audio": {
                "content": "Portugal...", 
                "tts_provider": GCP, # use google cloud platform for tts
                "theme": Summary, # generate a summary of the text using ChatGPT
            },
            "sets_length": True, # this audio_layer sets the length of the chapter, only one audio_layer can set the length per chapter
            "fade_in": 1200, # fade in 1200 ms
            "fade_out": 1200, # fade out 1200 ms
        },
        {"audio": "sounds/background.mp3", "sets_length": False, "volume": 0.5}, # overlay audio
    ],
    crossfade=2400, # crossfade last chapter
)

```

3. Generate and export the podcast:

```python
topcast.generate()
topcast.export("podcast.wav", format="wav")
```
This will create a podcast using the given chapters and save it as a WAV file named podcast_output.wav.
## ChatGPT Themes
ChatGPT Themes allow you to transform your text into various structures by leveraging ChatGPT, a large language model. With the available themes, you can transform your text into an interview, introduction, summary, or conclusion. You can also choose to leave the text as it is by using the NoneTheme, which is the default theme.

The available ChatGPT Themes are:

- Interview
- Introduction
- Summary
- Conclusion
- NoneTheme (default)
### Usage
To use a specific ChatGPT theme, first import the desired theme:
```python
from topcast.chatgpt_themes import Interview, Introduction, Summary, Conclusion
```
Then, set your OpenAI API key using the set_openai_api_key function:
```python
from topcast import set_openai_api_key

set_openai_api_key("your-openai-api-key")

```
Finally, set the `theme` property in the audio layer of the desired chapter:

```python
{
    "audio": {
        "content": "Text content...",
        "theme": Introduction,  # Replace with the desired theme
    },
}

```
To keep the original text without any transformation, set NoneTheme or don't set `theme` at all


```python
from topcast.chatgpt_themes import NoneTheme

{
    "audio": {
        "content": "Text content...",
        "theme": NoneTheme,  # Keeps the text as it is
    },
}
```
## TTS Providers
Topcast allows you to use various Text-to-Speech (TTS) providers to convert your text into speech. The currently implemented TTS providers are:
- GCP (Google Cloud Platform) - Requires a Google Cloud Platform account
- Elevenlabs - Requires an Elevenlabs account
- GTTS (Google Translate) - No account required (default)
### Comparison
- **Elevenlabs**: Offers the best voices but is expensive and has API limits.
- **GCP (Google Cloud Platform)**: Relatively cheap but requires a Google Cloud Platform account with the Text-to-Speech API enabled.
- **GTTS (Google Translate)**: Free and does not require an account, but the voice quality is not as good as the other options.
### Usage
First, import the desired TTS provider:
```python
from topcast.tts_providers import GCP, Elevenlabs, GTTS

```
Next, set the API key or credentials for the provider, if required:
```python
from topcast import set_elevenlab_api_key, set_google_credentials

set_elevenlab_api_key("your-elevenlabs-api-key")
set_google_credentials("path-to-gcp-keyfile.json")
```
Finally, specify the tts_provider property in the audio layer of the desired chapter:
```python
{
    "audio": {
        "content": "Text content...",
        "tts_provider": GCP,  # Replace with the desired TTS provider
    },
}

```

For example, to create a chapter using the GCP TTS provider:
```python
topcast.add_chapter(
    audio_layers=[
        {
            "audio": {
                "content": "Text content...",
                "tts_provider": GCP,
                "theme": Summary,
            },
            "sets_length": True,
            "fade_in": 1200,
            "fade_out": 1200,
        },
    ],
    crossfade=2400,
)

```
To use the default GTTS provider, you can simply omit the tts_provider property:

```python
{
    "audio": {
        "content": "Text content...",
    },
}
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gormlabenz/topcast",
    "name": "topcast",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "topcast tts text-to-speech gcp google openai elevenlabs",
    "author": "Gorm Labenz",
    "author_email": "gorm@labenz.io",
    "download_url": "https://files.pythonhosted.org/packages/65/45/eb8cfef905782f8b7092ecf575d0c4422769819daeee2bea57be88a0b4cd/topcast-0.1.7.tar.gz",
    "platform": null,
    "description": "# Topcast: Turn Text into Podcasts with TTS and ChatGPT\n\nTopcast is a Python package that allows you to transform text into a podcast using Text-to-Speech (TTS) and language models. With Topcast, you can provide a text, and the package will create a podcast with an introduction, interview, conclusion, sound effects, and more. Topcast supports various TTS providers and language models.\n## Example\nGenerated using ChatGPT themes: Introduction with the ElevenLabs TTS Provider, Interview with the GCP TTS Provider and Summary also with the ElevenLabs TTS Provider.\n\n\n\nhttps://user-images.githubusercontent.com/53308156/234994155-2921b28a-9caa-46fc-9608-5ef01881713e.mp4\n\n\n## Example Implementation\n\n```python\nfrom topcast import Topcaster, set_openai_api_key\nfrom topcast.chatgpt_themes import Introduction\n\nset_openai_api_key(\"XXX-XXX-XXX-XXX-XXX\")\n\ntopcast = Topcaster()\n\ntopcast.add_chapter(audio_layers=[{ \"audio\" : \"sounds/jingle.wav\" }])\ntopcast.add_chapter(\n    audio_layers=[\n        {\n            \"audio\": {\n                \"content\": \"Topcast is a Python package that allows you to transform text into a podcast using Text-to-Speech (TTS) and language models. With Topcast, you can provide a text, and the package will create a podcast with an introduction, interview, conclusion, sound effects, and more. Topcast supports various TTS providers and language models.\",\n                \"theme\": Introduction,\n            },\n        },\n    ],\n    crossfade=2400,\n)\n\ntopcast.generate()\ntopcast.export(\"podcast.wav\", format=\"wav\")\n\n\n```\n\n## Installation\nInstall the package using pip:\n\n```bash\npip install topcast\n```\n\n## Usage\n\n1. Import the necessary modules and set the API keys:\n\n```python\nfrom topcast import (\n    set_elevenlab_api_key,\n    set_google_credentials,\n    set_openai_api_key,\n    Topcaster,\n)\n\nfrom topcast.tts_providers import GCP\nfrom topcast.chatgpt_themes import Summary\n\nset_elevenlab_api_key(\"XXX-XXX-XXX\") # if you want to use elvenlabs for tts\nset_google_credentials(\"gcp-keyfile.json\") # if you want google cloud platform for tts\nset_openai_api_key(\"XXX-XXX-XXX\") # if you want to use a ChatGPT theme\n```\n\n2. Create a Topcaster object and add chapters with the desired podcast structure:\n\n```python\ntopcast = Topcaster()\n\ntopcast.add_chapter(\n    audio_layers=[\n        {\n            \"audio\": \"sounds/jingle.wav\", # use a audio file\n            \"sets_length\": True,\n        }\n    ]\n)\ntopcast.add_chapter(\n    audio_layers=[\n        {\n            \"audio\": {\n                \"content\": \"Portugal...\", \n                \"tts_provider\": GCP, # use google cloud platform for tts\n                \"theme\": Summary, # generate a summary of the text using ChatGPT\n            },\n            \"sets_length\": True, # this audio_layer sets the length of the chapter, only one audio_layer can set the length per chapter\n            \"fade_in\": 1200, # fade in 1200 ms\n            \"fade_out\": 1200, # fade out 1200 ms\n        },\n        {\"audio\": \"sounds/background.mp3\", \"sets_length\": False, \"volume\": 0.5}, # overlay audio\n    ],\n    crossfade=2400, # crossfade last chapter\n)\n\n```\n\n3. Generate and export the podcast:\n\n```python\ntopcast.generate()\ntopcast.export(\"podcast.wav\", format=\"wav\")\n```\nThis will create a podcast using the given chapters and save it as a WAV file named podcast_output.wav.\n## ChatGPT Themes\nChatGPT Themes allow you to transform your text into various structures by leveraging ChatGPT, a large language model. With the available themes, you can transform your text into an interview, introduction, summary, or conclusion. You can also choose to leave the text as it is by using the NoneTheme, which is the default theme.\n\nThe available ChatGPT Themes are:\n\n- Interview\n- Introduction\n- Summary\n- Conclusion\n- NoneTheme (default)\n### Usage\nTo use a specific ChatGPT theme, first import the desired theme:\n```python\nfrom topcast.chatgpt_themes import Interview, Introduction, Summary, Conclusion\n```\nThen, set your OpenAI API key using the set_openai_api_key function:\n```python\nfrom topcast import set_openai_api_key\n\nset_openai_api_key(\"your-openai-api-key\")\n\n```\nFinally, set the `theme` property in the audio layer of the desired chapter:\n\n```python\n{\n    \"audio\": {\n        \"content\": \"Text content...\",\n        \"theme\": Introduction,  # Replace with the desired theme\n    },\n}\n\n```\nTo keep the original text without any transformation, set NoneTheme or don't set `theme` at all\n\n\n```python\nfrom topcast.chatgpt_themes import NoneTheme\n\n{\n    \"audio\": {\n        \"content\": \"Text content...\",\n        \"theme\": NoneTheme,  # Keeps the text as it is\n    },\n}\n```\n## TTS Providers\nTopcast allows you to use various Text-to-Speech (TTS) providers to convert your text into speech. The currently implemented TTS providers are:\n- GCP (Google Cloud Platform) - Requires a Google Cloud Platform account\n- Elevenlabs - Requires an Elevenlabs account\n- GTTS (Google Translate) - No account required (default)\n### Comparison\n- **Elevenlabs**: Offers the best voices but is expensive and has API limits.\n- **GCP (Google Cloud Platform)**: Relatively cheap but requires a Google Cloud Platform account with the Text-to-Speech API enabled.\n- **GTTS (Google Translate)**: Free and does not require an account, but the voice quality is not as good as the other options.\n### Usage\nFirst, import the desired TTS provider:\n```python\nfrom topcast.tts_providers import GCP, Elevenlabs, GTTS\n\n```\nNext, set the API key or credentials for the provider, if required:\n```python\nfrom topcast import set_elevenlab_api_key, set_google_credentials\n\nset_elevenlab_api_key(\"your-elevenlabs-api-key\")\nset_google_credentials(\"path-to-gcp-keyfile.json\")\n```\nFinally, specify the tts_provider property in the audio layer of the desired chapter:\n```python\n{\n    \"audio\": {\n        \"content\": \"Text content...\",\n        \"tts_provider\": GCP,  # Replace with the desired TTS provider\n    },\n}\n\n```\n\nFor example, to create a chapter using the GCP TTS provider:\n```python\ntopcast.add_chapter(\n    audio_layers=[\n        {\n            \"audio\": {\n                \"content\": \"Text content...\",\n                \"tts_provider\": GCP,\n                \"theme\": Summary,\n            },\n            \"sets_length\": True,\n            \"fade_in\": 1200,\n            \"fade_out\": 1200,\n        },\n    ],\n    crossfade=2400,\n)\n\n```\nTo use the default GTTS provider, you can simply omit the tts_provider property:\n\n```python\n{\n    \"audio\": {\n        \"content\": \"Text content...\",\n    },\n}\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python package for Topcast",
    "version": "0.1.7",
    "split_keywords": [
        "topcast",
        "tts",
        "text-to-speech",
        "gcp",
        "google",
        "openai",
        "elevenlabs"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6e3be919b12826d3a736c5cdb8f632300e62871614344b7cbbee46d1173f3af6",
                "md5": "75da294b30bc1ee51e51ce59bf599b8d",
                "sha256": "2ef15cd55293072321fe3066404bbb8a92a25220200fbdde88801a7d79738d1e"
            },
            "downloads": -1,
            "filename": "topcast-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "75da294b30bc1ee51e51ce59bf599b8d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 19134,
            "upload_time": "2023-04-27T21:25:30",
            "upload_time_iso_8601": "2023-04-27T21:25:30.970384Z",
            "url": "https://files.pythonhosted.org/packages/6e/3b/e919b12826d3a736c5cdb8f632300e62871614344b7cbbee46d1173f3af6/topcast-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6545eb8cfef905782f8b7092ecf575d0c4422769819daeee2bea57be88a0b4cd",
                "md5": "bc1177e2bb904e033f9362dedac87d7c",
                "sha256": "5c8f99e1bfb7c2ffa590e4e1983ee72bbd96046d476814651ab82bf259354016"
            },
            "downloads": -1,
            "filename": "topcast-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "bc1177e2bb904e033f9362dedac87d7c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 14766,
            "upload_time": "2023-04-27T21:25:32",
            "upload_time_iso_8601": "2023-04-27T21:25:32.830369Z",
            "url": "https://files.pythonhosted.org/packages/65/45/eb8cfef905782f8b7092ecf575d0c4422769819daeee2bea57be88a0b4cd/topcast-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-27 21:25:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "gormlabenz",
    "github_project": "topcast",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "elevenlabs",
            "specs": [
                [
                    "==",
                    "0.2.5"
                ]
            ]
        },
        {
            "name": "openai",
            "specs": [
                [
                    "==",
                    "0.27.4"
                ]
            ]
        },
        {
            "name": "protobuf",
            "specs": [
                [
                    "==",
                    "4.22.3"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    "==",
                    "1.8.2"
                ]
            ]
        },
        {
            "name": "pydub",
            "specs": [
                [
                    "==",
                    "0.24.1"
                ]
            ]
        },
        {
            "name": "gTTS",
            "specs": [
                [
                    "==",
                    "2.3.1"
                ]
            ]
        }
    ],
    "lcname": "topcast"
}
        
Elapsed time: 0.06008s