Всі знають митця Леся Подервʼянського. Хтось за його художню діяльність, інші за драматургію. Та найширше він відомий як письменник автор пʼєс із міцним слівцем та добіса влучним гумором. Якось я подумав що було б класно, для підняття настрою, у випадковий момент в навушниках чути випадкову цитату із пʼєс митця. Власне, цей скрипт створений для такої задачі. Він відтворює з певним інтервалом цитату з аудіо файла. Самі цитати знаходяться в директорії ./audio
, перекодовані з YouTube каналу "Подерв'янський — цитати".
Нижче трохи документації щоб краще розуміти що, як і до чого.
This script plays random audio files from a specified folder at regular intervals. It supports macOS, Windows 11, and Linux. The script logs the names of the played files to a log file.
The audio files used by this script are sourced from the YouTube channel "Подерв'янський — цитати". Please ensure you have downloaded the audio files into the specified folder.
- Python 3.x
afplay
(macOS)aplay
(Linux)powershell
(Windows)
By deafault script will play audio from ./audio
in current working dir
This behaviour can be customized using the following environment variables:
RANDOM_AUDIO_PLAYER_FOLDER
: The folder containing the audio files. If not set, the script defaults to using theaudio
folder located in the current working directory.RANDOM_AUDIO_PLAYER_INTERVAL
: The interval in seconds between playing files. If not set, the script defaults to 300 seconds (5 minutes).
EXAMPLE:
export RANDOM_AUDIO_PLAYER_FOLDER=~/YOUR_AUDIO_FOLDER
export RANDOM_AUDIO_PLAYER_INTERVAL=600
-
Clone the repository or download the script:
git clone [email protected]:eiger8/poderev-speaks.git cd poderev-speaks
-
Ensure the audio files are in the specified folder:
By default, the script looks for audio files in
./audio
. You can change this by modifying theRANDOM_AUDIO_PLAYER_FOLDER
variable in the script. -
Run the script:
python3 poderev-speaks.py
Execute the random_audio player in the background using the following bash command. To terminate the process, you must manually kill it by its PID, which is provided upon command execution.
nohup bash -c 'AUDIO_FOLDER=~/path/to-audio; LOG_FILE=~/played_files.log; while true; do file=$(gshuf -e "$AUDIO_FOLDER"/*.* -n 1); echo "$file" >> "$LOG_FILE"; afplay "$file"; sleep 300; done' > /dev/null 2>&1 &
Run the random_audio player in the current terminal session. To terminate the process, simply use CTRL+C.
AUDIO_FOLDER=~/path/to-audio; LOG_FILE=~/played_files.log; while true; do file=$(gshuf -e "$AUDIO_FOLDER"/*.* -n 1); echo "$file" >> "$LOG_FILE"; afplay "$file"; sleep 300; done
Please utilize this command if you wish to configure crontab. Be advised that this will disable the "played_files.log" functionality.
gshuf -e ~/path/to-audio/*.* -n 1 | tr '\n' '\0' | xargs -0 afplay