Skip to main content

CLI tool for converting articles to podcasts

Project description

articast

PyPI Changelog Tests License

CLI tool for converting articles to podcasts using AI Text-to-Speech APIs. I have added ElevenLabs basic functionanlity, but it's very simple, and I still use OpenAI more for it's cheapness.

Requirements

You need to have ffmpeg installed before running this CLI tool.

brew install ffmpeg

Since JS based articles can't be rendered with requests we're using playwright and chromium web driver to tackle that:

pip install playwright
playwright install chromium

Usage

Install articast with:

pipx install articast
articast --help
Usage: python -m articast [OPTIONS]

Options:
  --url TEXT                      URL of the article to be fetched.
  --vendor [openai|elevenlabs]    Choose vendor to use to convert text to
                                  audio.
  --file-url-list FILE            Path to a file with URLs placed on every new
                                  line.
  --file-text FILE                Path to a file with text to be sent over to
                                  AI vendor. This is currently a workaround of
                                  Cloudflare blocking.
  --directory DIRECTORY           Directory where the output audio file will
                                  be saved. The filename will be derived from
                                  the article title.
  --model TEXT                    The model to be used for text-to-speech
                                  conversion.
  --voice TEXT                    OpenIA voices: alloy, echo, fable, onyx,
                                  nova, shimmer; ElevenLabs voices: Sarah.
  --strip INTEGER RANGE           By what number of chars to strip the text to
                                  send to OpenAI.  [5<=x<=2000]
  --audio-format [mp3|opus|aac|flac|pcm]
                                  The audio format for the output file.
                                  Default is mp3.
  --help                          Show this message and exit.
export OPENAI_API_KEY="your-api-key"
articast \
    --url 'https://blog.kubetools.io/kopylot-an-ai-powered-kubernetes-assistant-for-devops-developers'

ElevenLabs:

export ELEVEN_API_KEY="your-api-key"
articast \
  --url 'https://incident.io/blog/psychological-safety-in-incident-management' \
  --vendor elevenlabs \
  --directory ~/Downloads/Podcasts

Development

If you're using Nix you can start running the tool by entering:

nix develop
export OPENAI_API_KEY="your-api-key"
python \
    -m articast \
    --model tts-1-hd \
    --voice nova \
    --directory . \
    --url 'https://blog.kubetools.io/kopylot-an-ai-powered-kubernetes-assistant-for-devops-developers'

Lint

I currently use these commands manually, maybe I will add some automation later on:

autoflake --in-place --remove-all-unused-imports --expand-star-imports -r .

Testing

If you used nix develop all necessary dependencies should have already been installed, so you can just run:

pytest

TODO

  • Bypass Cloudflare block
  • Minimize costs on tests
  • Add ability to render images to text and send over to text to speech as well
  • Shorten filename created
  • Shorten article title printed to console
  • Send to device right away
  • Replace print with logger
  • Remove redundant warnings in pytest
  • Make sure pytest shows quota errors

Manual configurations

  • OPENAI_API_KEY secret was added to repository secrets
  • ELEVEN_API_KEY secret was added to repository secrets
  • PYPI_TOKEN was added to release environment secrets

Inspired by

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

articast-0.1.25.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

articast-0.1.25-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file articast-0.1.25.tar.gz.

File metadata

  • Download URL: articast-0.1.25.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for articast-0.1.25.tar.gz
Algorithm Hash digest
SHA256 76756f0aa33b2d2b1ba9ba314b0edbaaba7bac8cd2e3fb759419cac076b74651
MD5 d21d93f07e997263098f5625deb27cf1
BLAKE2b-256 1e32c333380fb2dd114a6a1de1142d3e4531684f2d12b2dd7bd32e4accc815cb

See more details on using hashes here.

File details

Details for the file articast-0.1.25-py3-none-any.whl.

File metadata

  • Download URL: articast-0.1.25-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for articast-0.1.25-py3-none-any.whl
Algorithm Hash digest
SHA256 21b79199e657da4e00b92602ba52a9986114ed91890e367928423c90e706cd43
MD5 e41855fadee753baaf48307dbe0be08f
BLAKE2b-256 0c09fe663ed07498906ee21ac23c975ccf9a0824a8a9999cfc29cd554f70390e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page