Skip to main content

narrately

Convert a web article, or any text, into a spoken mp3 file.

Installation

pip install narrately

Usage

From a web article URL

from narrately import article_to_audio

output_path = article_to_audio(
    "https://example.com/some-article",
    "article",
    lang="en",
)
print(f"Saved audio to {output_path}")

article_to_audio(url, audio_file_name, lang="en") downloads and extracts the article text from url (using newspaper3k), converts it to speech (using gtts), and saves it as {audio_file_name}.mp3. It returns the Path to the generated file.

From plain text

from narrately import text_to_audio

output_path = text_to_audio(
    "Hello, this text will become an mp3 file.",
    "greeting",
    lang="en",
)
print(f"Saved audio to {output_path}")

text_to_audio(text, audio_file_name, lang="en") skips the scraping step and converts text directly to speech, saving it as {audio_file_name}.mp3. It returns the Path to the generated file.

Shared arguments

audio_file_name can be a plain name (saved in the current directory) or a full path, e.g. "output/my_article" — either way, don't include the .mp3 extension, it's appended automatically.

lang is a two-letter language code (e.g. "en", "es", "fr") passed through to gtts.

Notes

  • Requires an internet connection: both article scraping and speech generation call external services.
  • Some sites block automated scraping or require a paid subscription (paywalls); in those cases article extraction may fail or return partial content.

License

MIT

Download files

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

Source Distribution

narrately-0.2.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

narrately-0.2.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file narrately-0.2.0.tar.gz.

File metadata

  • Download URL: narrately-0.2.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.13

File hashes

Hashes for narrately-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ee5cf00462386a8594696ae7f6754e3d8c959dd5e89dec2a177d5439349dae02
MD5 d5a74eeef716e8eece3010cfa3843aaa
BLAKE2b-256 61bc7fd38aea8c2d103f980e98fb3c989ef0310a394fff87fbc4afbff2799f79

See more details on using hashes here.

File details

Details for the file narrately-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: narrately-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.13

File hashes

Hashes for narrately-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ea3d8a7c7248ca6228cb23df6d7a4e147f2bd3b586f7f87e4a260b4e00a79f0
MD5 9781521c2f98fc9a524c588d510c15b6
BLAKE2b-256 9315b9be562138edadf17c8894bebc7cd6537f4923d05687f90b7d63284544cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page