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.1.1.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.1.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: narrately-0.1.1.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.1.1.tar.gz
Algorithm Hash digest
SHA256 0ce508efbbbf894169fc995051814b66c4f8a8b60a7a8641c43ba101a3c02a8d
MD5 4dc516fac8fd393314c2bf3111ff69a8
BLAKE2b-256 920b29e3c89e24122e51d3973863edd7f36b4fbd8123bc4eff66298c5b017c29

See more details on using hashes here.

File details

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

File metadata

  • Download URL: narrately-0.1.1-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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ea6befe16318b0932b71fdea75dfbcca14628182cff07fc3b47c1e5004ad584d
MD5 c187e48b94cdc7941ef05c3bcd96700b
BLAKE2b-256 f334ebdf92668a50b204d9ba0de14264c3e29ff3a2f37abf407278a20ec68ded

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