Skip to content

valenbar/chapterize-audio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chapterize Audio

This script generates chapters for an audio file by detecting silence. The chapters are stored to a CUE file and a JSON file.

Prerequisites

  • Python
  • FFmpeg (Make sure it is installed and added to the system's PATH)

Installation

pip install -r requirements.txt

Usage

Example usage:

python chapterize.py -i <audio.mp3>  -t <dB threshold> -d <silence duration>

Options:

options:
  -h, --help            show this help message and exit
  -i INPUT_AUDIO, --input_audio INPUT_AUDIO
                        The input audio file
  -t THRESHOLD, --threshold THRESHOLD
                        The silence threshold in dB (default: -30)
  -d DURATION, --duration DURATION
                        The minimum silence duration in seconds (default: 2.5)
  -l LABEL, --label LABEL
                        The label to prefix the chapter nr. (default: Part)
  --transcribe, --no-transcribe
                        Enable transcribing of chapter entry (default: True)
  --language LANGUAGE   The language to use for transcribing (default: english)
  --transcript-duration TRANSCRIPT_DURATION
                        The duration of the audio to transcribe (default: 3)

Console Output:

$ python chapterize.py -i audio.mp3 -t -30 -d 2.5
Part duration: <chapter duration> Next part start: <chapter start time>, <transcribed chapter start>
...

File Output:

./audio.cue
./chapters.json

CUE file output:

FILE "audio.mp3" MP3
TRACK 1 AUDIO
    TITLE "Part 1"
    INDEX 01 00:00:00
TRACK 3 AUDIO
    TITLE "Part 3"
    INDEX 01 00:14:37
TRACK 4 AUDIO
    TITLE "Part 4"
    INDEX 01 01:56:36

JSON file output:

[
    {
        "id": "0",
        "title": "Part 1",
        "start": "00:00:00",
        "end": "00:14:37"
    },
    {
        "id": "1",
        "title": "Part 3",
        "start": "00:14:37",
        "end": "01:56:36"
    },
    {
        "id": "2",
        "title": "Part 4",
        "start": "01:56:36",
        "end": "02:00:00"
    }
]

Todo list

  • Option to fix timing of existing chapters
  • Option to overwrite chapters in audiobookshelfs metadata.json directly

Acknowledgements

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published