~naglis/lytte

Audiobook reading system

5278c7d Add features table to README

~naglis pushed to ~naglis/lytte git

15 hours ago

b927315 Fix clippy warnings

~naglis pushed to ~naglis/lytte git

19 hours ago

builds.sr.ht status

#lytte

Basic audiobook reading system for Raspberry Pi, based on MPD.

#Features

  • Remember last playback position / volume
  • Seek back when continuing playback
  • Chapter navigation

#Usage

lytte /path/to/config.toml /path/to/publication/

#Packages

A Debian package for Raspberry Pi 1 is available on individual release pages.

#Playback control

lytte can be controlled via MPD client-to-client messages on the lytte channel. A message that contains a supported lytte action will be executed.

#Supported actions

#toggle_play_pause

Similar to MPD pause command, but will seek back when resuming playback.

The seek back amount depends on the configured seek back levels ([seek_back_levels] section in the configuration file).

lytte will also clamp to the nearest past chapter if such exists within the seek back duration.

#navigate <target>

Navigate to the <target> in the publication. <target> is a navigation target expression, e.g. +#1 to go to the next chapter.

#store_position

Store current playback position.

#store_volume

Store current playback volume.

#stop

Stop playback (MPD queue is cleared).

#quit

Exit lytte. Stores playback position and clears MPD queue.

#Configuration

lytte uses TOML for its configuration.

#Example configuration

# Path to lytte SQLite database file.
store_path =  "/var/lib/lytte/store"

[playback]
# Path to MPD Unix domain socket.
mpd_socket_path = "/run/mpd/socket"

# Default volume for new publications (which have no stored status).
# The value should be an integer between 1 and 100 (inclusive).
default_volume = 50

# Pause playback on startup. If set to false, lytte can be used as a zero button
# audiobook player.
start_paused = true

# The max number of attempts to reconnect to MPD when the idle event handler
# connection is lost (e.g. when MPD is restarted). If reconnecting in this
# number of attempts fails, lytte will exit with an error. Setting it to zero
# will disable reconnection attempts.
reconnect_attempts = 10

[navigation]
# When navigating backwards using the `chapter_or_audio_resource` target, use
# this as the duration since the beginning of the current chapter during which to
# allow navigating to the previous chapter (instead of going to the beginning of
# the current chapter).
chapter_merge_threshold = "2s 500ms"

# Maps duration since last playback to the duration to seek backwards when
# playback is resumed. The ~1s seek back after a small duration can be used as a
# workaround for https://github.com/MusicPlayerDaemon/MPD/issues/1136.
[navigation.seek_back_levels]
"250ms" = "1s"
"5m" = "10s"
"30m" = "30s"
"2h" = "1m"
"24h" = "2m"

#How it works

Note: This section is very outdated.

When USB media is inserted, a udev rule triggers a systemd service that calls a script which mounts the USB disk and starts lytte. lytte checks for a audiobook.json file in the root mountpoint directory. If found, it will try to load the audiobook defined in it. If successful and MPD can play all the audio resources (based on the mimetypes and suffixes of the audio resources) of the publication, it will be loaded (MPD will be in paused state after loading).

Playback position (the index of the audio resource and the time position in the audio resource) and playback volume are stored in a SQLite database.

The playback position/volume is stored when:

  • the publication is loaded/unloaded;
  • the playback is paused/resumed;
  • after seeking forward/backward in the audio resource;
  • after navigating to the next/previous audio resource/chapter;
  • when playback progresses to the next audio resource;
  • when playback volume is changed.

When USB media with a publication that has existing playback status in the store is re-mounted (or when the reading system is restarted while USB media is plugged in), lytte will skip back 30 seconds in the audio resource that was played last. It will clamp at the beginning of the audio resource (it will not skip back to the previous audio resource). If the publication has a table of contents and there are chapters that start in the previous 30 seconds of the last played audio resource, then it will clamp at the beginning of furthermost chapter.

When the USB media is removed, playback is stopped and the publication is unloaded.

#Raspberry Pi Setup

#Reducing energy consumption

#Disable LEDs

Source

If you want to disable both LEDs permanently, add the following to /boot/config.txt:

# Disable the ACT LED.
dtparam=act_led_trigger=none
dtparam=act_led_activelow=off

# Disable the PWR LED.
dtparam=pwr_led_trigger=none
dtparam=pwr_led_activelow=off