Skip to main content

pyxreader

pyxreader is a Python module that streamlines the process of reading and vocalizing the content of files using text-to-speech capabilities in a memory-efficient way. It provides a flexible and extensible architecture to support various file formats and allows for custom methods that the user can choose to extract text from various files.

Features

  • Read and vocalize the content of any file.
  • Easily configure reading speed, volume, and voice.
  • Support for custom dependency injection, enabling users to define their own text extraction logic for various file formats. The module comes with native support for PDFs.

Installation

pip install pyxreader

if you're on linux, for the speech capabilities you might also need to install:

sudo apt update && sudo apt install espeak ffmpeg libespeak1

Note: The text-to-speech capabilities are provided by pyttsx3. If you encounter any issues with speech not functioning on your system, make sure to consult the library for more information.

Configuration

The Reader class allows you to configure various settings:

  • speed: Reading speed in words per minute (default: 200).
  • volume: Volume level, a float between 0.0 and 1.0 (default: 1.0).
  • voice: The voice to use for reading (default: operating system).

Usage

Normal text file reader

from pyxreader import TextReader

# Speak the provided text
TextReader("Hey there!").say().execute()

# Save spoken text to an MP3 file
TextReader("Whatever it read").save("output.mp3").execute()

# Read and speak the content of a normal file line by line
TextReader().read_file("reader.py").execute()

Custom files (PDFs by default)

from pyxreader import AdaptableReader

# Read and vocalize the content of a PDF file with default settings
# Defaults to the base iterator PDFTextIterator.
AdaptableReader(filename="example.pdf").read()

This uses PDFTextIterator to parse PDFs and extract text per page

How it works

from pyxreader import PDFTextIterator


per_page = PDFTextIterator("any.pdf")
for line in per_page:
    print(line)

If the file you have is not a PDF like

AdaptableReader(filename="example.custom").read()

Then define your own custom file iterator

from pyxreader import AdaptableReader
from pyxreader.iterators import BaseIterator


class CustomIterator(BaseIterator):
    def __init__(self, file: str):
        super().__init__(file)
        # Additional initialization for your custom iterator

    def __iter__(self) -> "CustomIterator":
        """
        Method to initialize the custom iterator.
        """
        pass

    def __next__(self) -> str:
        """
        Method to extract the next item in the iteration.
        """
        # Implement the logic to extract the next item in the iteration for your custom iterator
        # This method should return a string
        pass


# Example using a custom iterator
AdaptableReader("example.custom").inject_iterator(CustomIterator).read()

Metadata

Release files for pyxreader 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyxreader 0.0.1
File Size Uploaded Provenance Actions
pyxreader-0.0.1.tar.gz 6.0 kB Without provenance Details for pyxreader-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyxreader 0.0.1
File Interpreter ABI Platform Actions
pyxreader-0.0.1-py3-none-any.whl Python 3 none any Details for pyxreader-0.0.1-py3-none-any.whl

Total release size: 12.8 kB

Release files / pyxreader-0.0.1.tar.gz

Download URL pyxreader-0.0.1.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7e5b50745263e5936e1d9061489f3dd44a52d53ec1f8c8d44806bcb00155f500
BLAKE2b-256 checksum
How to use checksums
6f8ade4e87ffeeafb0ab54a19b2bddb5c4f075711cdb447976b9c83be437dd30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pyxreader-0.0.1-py3-none-any.whl

Download URL pyxreader-0.0.1-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4900b8b3e1124d86e4772d5d796ae7618c7460cac6a18e3616efa14e7cf7816f
BLAKE2b-256 checksum
How to use checksums
dfec146c599bcee40252fe4f6fd2251b0c0eac77d526d2f65674bdf1433c0aa6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Security for pyxreader 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page