Skip to main content

CLI tool for converting articles to podcasts

Project description

audio-reads

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 audio-reads with:

pipx install audio-reads
audio-reads --help                                                                                                                   
Usage: python -m audio_reads [OPTIONS]

Options:
  --url TEXT                      URL of the article to be fetched.
  --file-url-list FILE            Path to a file with URLs placed on every new
                                  line.
  --directory DIRECTORY           Directory where the output audio file will
                                  be saved. The filename will be derived from
                                  the article title.
  --audio-format [mp3|opus|aac|flac|pcm]
                                  The audio format for the output file.
                                  Default is mp3.
  --model [tts-1|tts-1-hd]        The model to be used for text-to-speech
                                  conversion.
  --voice [alloy|echo|fable|onyx|nova|shimmer]
                                  The voice to be used for the text-to-speech
                                  conversion. Voice options: alloy:   A
                                  balanced and neutral voice. echo:    A more
                                  dynamic and engaging voice. fable:   A
                                  narrative and storytelling voice. onyx:    A
                                  deep and resonant voice. nova:    A bright
                                  and energetic voice. shimmer: A soft and
                                  soothing voice. Experiment with different
                                  voices to find one that matches your desired
                                  tone and audience. The current voices are
                                  optimized for English.
  --strip INTEGER RANGE           By what number of chars to strip the text to
                                  send to OpenAI.  [5<=x<=2000]
  --help                          Show this message and exit.
export OPENAI_API_KEY="your-api-key"
audio-reads \
    --url 'https://blog.kubetools.io/kopylot-an-ai-powered-kubernetes-assistant-for-devops-developers'

ElevenLabs:

export ELEVEN_API_KEY="your-api-key"
audio-reads \
  --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 audio_reads \
    --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

audio_reads-0.1.21.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

audio_reads-0.1.21-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file audio_reads-0.1.21.tar.gz.

File metadata

  • Download URL: audio_reads-0.1.21.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for audio_reads-0.1.21.tar.gz
Algorithm Hash digest
SHA256 5cf48fb1fd324fd354807f80412e8596b5c5ec5a2ef0454d10202abcdfab1cfe
MD5 eed7904f7263ec6b39fa4bca2144556c
BLAKE2b-256 b87a29b161160d6fd80c1343b5c1fb1f801c55c2a78be5176402a16a8a692ff8

See more details on using hashes here.

File details

Details for the file audio_reads-0.1.21-py3-none-any.whl.

File metadata

File hashes

Hashes for audio_reads-0.1.21-py3-none-any.whl
Algorithm Hash digest
SHA256 f9b57172a6bb9b440a263d97f32e141dfec219f52a3120ded699a399880f14ed
MD5 6595e33b8961a537070c5755b781bfe4
BLAKE2b-256 e339de14611910d9be15682320d9ddb755fbd8265e6a32f96b4aa1ebd2af372e

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