Skip to main content

bard is a text to speech tool based on existing open-source models (local install) and APIs to install on your desktop

Project description

pypi

Bard

Bard is a text to speech client that integrates on the desktop

Install

Install libraries or system-specific dependencies:

sudo apt-get install portaudio19-dev xclip #  portaudio19-dev becomes portaudio with Homebrew
sudo apt install libcairo-dev libgirepository1.0-dev gir1.2-appindicator3-0.1  # Ubuntu ONLY (not needed on MacOS)
pip install PyGObject # Ubuntu ONLY (not needed on MacOS)

Install the main app with all its optional dependencies:

pip install bard-cli[all]

GNOME

On GNOME desktop you can subsequently run:

bard-install [...] --openai-api-key $OPENAI_API_KEY

to produce a .desktop file for GNOME's quick-launch (the [...] indicates any argument that bard takes)

Usage

In a terminal:

bard

which defaults to:

bard --backend openaiapi --voice allow --model tts-1

(this assumes the environment variable OPENAI_API_KEY is defined)

An icon should show up almost immediately in the system tray, with options to copy the content of the clipboard (the last thing you copy-pasted) and send that to the AI model for reading aloud.

You can also do a one-off reading by indicating the source content with one of the following:

bard --text "Hello world, how are you today"
bard --clipboard
bard --url "example.com" # also accepts file://
bard --html-file /path/to/downloaded.html # access a page with paywal, download it, feed it to bard
bard --pdf-file /path/to/document.pdf  # careful if you pay for it... (the full thing will be transcribed even if you listen to a small bit of it)
bard --audio-file /path/to/audio.mp3 # no actual request, only useful for testing the audio player

The above command will still launch the system tray icon, and so provide access to the audio player's (basic) controls. If you wish to just read aloud without the icon tray app, you may add the --no-tray parameter.

The clipboard parsing capabilities are elaborate enough so that it can detect an URL, a file path or common HTML markup. If a file path is detected, the extension is checked for .html-ish and .pdf, and the data is extracted accordingly. Here we make good use of the most useful work on readability. In particular, this allows relatively easy reading out of webpages behind paywals, by right-clicking on "View Page Source" (or download the html file if the source doesn't contain the text), select all text, copy and just proceed with bards' "Process Copied Text" or --clipboard options.
For other articles not protected by a paywall, copying the URL should suffice.

You can resume the previous recording (the audio won't play right away in this case, but you can use the reader):

bard --resume

You can ask also ask the app to removed your (local) traces:

bard --clean-cache-on-exit

Fine-tuning

bard --chunk-size 500  # that's the default

sets the maximum length (in characters) of a request. That means about 30 seconds of speech. The program will split up the text in chunks (according to the punctuation) and download them sequentially. The reading will start with the first chunk, that's why it is convenient to keep it small. You can set that smaller or up to the maximum allowed by the openai API (4096).

Player

The player was devised in conversation with Mistral's Le Chat and Open AI's Chat GPT, and my own experience with pystray on scribe. It works.

I'm open for suggestion for other, platform-independent integrations to the OS.

Android

I was able to install bard on Android via the excellent Termux emulator. Not everything works: the tray system app does not work, the clipboard option does not work. However I could obtain a decent workflow via

bard --no-tray --clipboard-text "$(termux-clipboard-get)"

Formatted text is not copied, and Android 's apps dont let you download the the html like on Desktop. So for paywalled articles I end up opening them in Firefox, acessing the Reading mode (excellent), select all text and running the above command.

Roadmap

Include more backends including local ones.

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

bard_cli-0.9.3.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

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

bard_cli-0.9.3-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file bard_cli-0.9.3.tar.gz.

File metadata

  • Download URL: bard_cli-0.9.3.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for bard_cli-0.9.3.tar.gz
Algorithm Hash digest
SHA256 db2ba25d5508d7ba5496be5bf9efa27a0112ec79981ed311eb856e685e71e15a
MD5 4cd9124314011f6c597fe8df918f4720
BLAKE2b-256 159b11d7dec072dc49923a13d36afb0b6884321dfe4d139934036b96989a24b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for bard_cli-0.9.3.tar.gz:

Publisher: pypi.yml on perrette/bard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bard_cli-0.9.3-py3-none-any.whl.

File metadata

  • Download URL: bard_cli-0.9.3-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for bard_cli-0.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3c231d0fc26439868a9e15a4e8eae9d8b9a569f91527e36ed125246a29d13c49
MD5 8cbf70af6ea308be7a9eb824503360ce
BLAKE2b-256 c3279f8c912e18b1f4bd0ff8983c3f9e0d74e49a36810d52698fc4d6125497d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for bard_cli-0.9.3-py3-none-any.whl:

Publisher: pypi.yml on perrette/bard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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