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: Nicole.
  --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'

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
  • PYPI_TOKEN was added to release environment secrets
  • Elevenlabs test do not require api key for small size requests

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.24.tar.gz (10.7 kB view hashes)

Uploaded Source

Built Distribution

articast-0.1.24-py3-none-any.whl (10.0 kB view hashes)

Uploaded Python 3

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