Offline version of playphrase.me

    Hello! I wrote a small script that searches for a given phrase for all subtitles in a folder (and in all subfolders) and shows the corresponding video file from this place. If there were several matches, a playlist will be created, which you can navigate either using "Enter" or "Shift + <" and "Shift +>".



    Usage example:


    playphrase.exe -i <media_dir> <phrase> 

    Before the first launch (or when adding new video files with subtitles) it is necessary to generate txt files using the existing srt subtitles that will be used during the search:

    playphrase.exe -i <media_dir> _init_

    Additional keys:


    -e, --ending - automatically go to the next clip (a kind of offline version of the playphase.me service)
    -r, --randomize - moves the clips
    -p, --padding PADDING - is added to the beginning and end of each clip (default is 0.0 seconds)
    -o, --output FILENAME - saves the search results to the file
    -d, --demo - just displays the number of matches without opening the video player
    -ph, --phrases [GAP_BETWEEN_PHRASES] - the show will start not from the found subtitle line, but slightly earlier (if possible from the beginning of the phrase). If desired, the value GAP_BETWEEN_PHRASES can be set after the --phrases key (1.75 by default). All subtitles, the distance between which is no more than GAP_BETWEEN_PHRASES, will be combined into one phrase.
    -l, --limit LIMIT - limit the maximum phrase length (by default 30 seconds)



    Page of the program

    For the script to work, it is necessary that the file name with subtitles coincide with the name of the video file.

    When searching, you can use regular expressions.

    If None appears in the console, then most likely an error in the search phrase. Perhaps you need to screen some specials. backslashes (\).

    There is a ready-made Windows binary on the download page (playphrase.zip archive).

    To simplify the introduction of new phrases, you can use the file videogrep.bat (under Windows) or videogrep.sh (under Linux), after having edited it and changed the path to the folder with video files and subtitles in a text editor. To exit, you can type quit, exit or q, x.



    If desired, the script can be used with audiobooks, but you will need to pre-generate subtitles for each audio file. To do this, you can use the program aeneas (or online version ), intended primarily for creating EPUB 3 Audio-eBooks . For semi-automatic splitting of a book’s text into chapters, you can use, for example, the console utility csplit , and for further splitting into shorter fragments of the Pragmatic Segmenter .

    In short, the sequence is approximately the following (it is assumed that the audiobook is divided into chapters):

    1. Split the text of the book into chapters using csplit. Command example:

      csplit "Last Mortal Bond, The - Brian Staveley.txt" /^[0-9]+$/ {*}

      csplit "The Lion, the Witch and the Wardrobe.txt" -f "Chapter" -b "_%02d.txt""/^Chapter \w+$/" {*}
    2. Split the text of each chapter with the Pragmatic Segmenter. For partial automation, you can use the script text-segmenter.rb (compiling responses to Stack Overflow).
    3. Generate subtitles for each audio file using aeneas. Command example:

      python -m aeneas.tools.execute_task audio.mp3 text.txt "task_language=eng|os_task_file_format=srt|is_text_type=plain" subtitles.srt

    The result will be something like this:


    In general, maybe someone will be useful.

    Also popular now: