PlayPhrase: search and play phrases from movies and audiobooks

All about language programs, courses, websites and other learning resources
kelciour
White Belt
Posts: 17
Joined: Wed Feb 01, 2017 11:39 pm
Languages: Russian (N), English (self-study)
x 32

PlayPhrase: search and play phrases from movies and audiobooks

Postby kelciour » Mon Aug 28, 2017 10:01 pm

Hi! I wrote a small application a little while ago. It's kind of similar to Kindle's global search option (Search My Items) but only for movies with subtitles. All you need is a folder with video files in it and .srt subtitles nearby with the same name. It supports sub-folders. It's been inspired by Videogrep: Automatic Supercuts with Python and PlayPhrase.me (it probably had been shut down permanently).

Here's the link - https://github.com/kelciour/playphrase

Here's demonstration of how program works:



10 x

User avatar
emk
Brown Belt
Posts: 1403
Joined: Sat Jul 18, 2015 12:07 pm
Location: Vermont, USA
Languages: English (N), French (B2+)
Badly neglected "just for fun" languages: Middle Egyptian, Spanish.
Language Log: viewtopic.php?f=15&t=723
x 4843
Contact:

Re: PlayPhrase: search and play phrases from movies and audiobooks

Postby emk » Mon Aug 28, 2017 10:51 pm

Thank you! This looks like a really useful tool for people who have video with *.srt files! I especially like the fact that it runs over entire directory hierarchies? Does it support either wildcards or regular expressions?

(I've been very slowly working on a library to automatically parse VobSub subtitles, and somebody I hope to add automatic OCR to generate *.srt files without human intervention. But it's going to take a while!)
0 x

kelciour
White Belt
Posts: 17
Joined: Wed Feb 01, 2017 11:39 pm
Languages: Russian (N), English (self-study)
x 32

Re: PlayPhrase: search and play phrases from movies and audiobooks

Postby kelciour » Tue Aug 29, 2017 1:00 pm

emk wrote:I especially like the fact that it runs over entire directory hierarchies? Does it support either wildcards or regular expressions?
Yes, it scans 'media_dir' recursively. Actually, it's a very simple script. It uses the program 'grep' under the hood to do all the search (line #155) and it supports wildcards and regular expressions. I only join subtitles into 'sentences' and generate .txt files with format like that ("Pete's Dragon (1977).txt"):

Code: Select all

(00:35:05,740, 00:35:07,742)   Who's Elliott?
(00:35:07,825, 00:35:10,828)   - My dragon. - Dragon?
(00:35:10,912, 00:35:14,165)   So you're the boy with the dragon.

After that 'grep' do the search and I only open up mpv video player and add search results as a playlist. That's all :) .
4 x

siwars
Posts: 4
Joined: Thu Aug 24, 2017 7:41 pm
Languages: Spanish(N) English (Beginner)
x 3

Re: PlayPhrase: search and play phrases from movies and audiobooks

Postby siwars » Sun Sep 03, 2017 10:45 pm

Do you have support for windows 7 x64 :?:
0 x

kelciour
White Belt
Posts: 17
Joined: Wed Feb 01, 2017 11:39 pm
Languages: Russian (N), English (self-study)
x 32

Re: PlayPhrase: search and play phrases from movies and audiobooks

Postby kelciour » Mon Sep 04, 2017 7:00 am

siwars wrote:Do you have support for windows 7 x64 :?:
Yes. Download 'playphrase-win32.zip' file from the Releases page. After that edit 'videogrep.bat' file by updating 'media_dir' path and double-click on it.
0 x

spanglish
White Belt
Posts: 18
Joined: Wed Sep 06, 2017 11:58 pm
Languages: Spanish(N) English(beginner)
x 9

Re: PlayPhrase: search and play phrases from movies and audiobooks

Postby spanglish » Thu Sep 07, 2017 12:21 am

kelciour wrote:
siwars wrote:Do you have support for windows 7 x64 :?:
Yes. Download 'playphrase-win32.zip' file from the Releases page. After that edit 'videogrep.bat' file by updating 'media_dir' path and double-click on it.


videogrep.bat

Hello, I have edited it that way on windows

Code: Select all

@echo off
setlocal EnableDelayedExpansion

set media_dir="C:\Users\user\Videos\videos"

for /L %%n in (1,0,1) do (
    set /p phrase="Phrase: "
   
    if /I "!phrase!"=="q" call :stop
    if /I "!phrase!"=="x" call :stop
    if /I "!phrase!"=="quit" call :stop
    if /I "!phrase!"=="exit" call :stop

    playphrase.exe --input %media_dir% "!phrase!"
)

:stop
call :__stop 2>nul

:__stop
() creates a syntax error, quits the batch



the result is

Code: Select all

Phrase: la gallina se ha escapado
WARNING: number of '.srt' and '.txt' files doesn't match. Maybe you need to use
'videogrep <media_dir> _init_'.
'la gallina se ha escapado' is not found in 'C:\Users\user\Videos\videos'



.srt

Code: Select all


2
00:01:52,554 --> 00:01:56,357
¡Eh, la gallina se ha escapado!
¡Atrápala, hombre!

3
00:01:59,997 --> 00:02:02,300
¡Vamos, vamos!






What video format do you recommend using and in what form do you use subtitles?
Last edited by spanglish on Fri Sep 08, 2017 12:10 am, edited 1 time in total.
0 x

kelciour
White Belt
Posts: 17
Joined: Wed Feb 01, 2017 11:39 pm
Languages: Russian (N), English (self-study)
x 32

Re: PlayPhrase: search and play phrases from movies and audiobooks

Postby kelciour » Thu Sep 07, 2017 11:44 am

spanglish
If you see the warning "number of '.srt' and '.txt' files doesn't match" enter _init_ at first and only after that "la gallina se ha escapado". It will look like this:

Code: Select all

Phrase: _init_

J:\English Movies\Catch Me If You Can (2002).srt
J:\English Movies\Robin Hood (1973).srt
J:\English Movies\Pete's Dragon (1977).srt
...

Phrase: la gallina se ha escapado

If you don't see this warning you don't need to enter _init_:

Code: Select all

Phrase: la gallina se ha escapado

spanglish wrote:What video format do you recommend using and in what form do you use subtitles?
PlayPhrase supports only 'srt' subtitles.
PlayPhrase supports only 'mp4', 'avi', 'mkv' video files but I can update source code if it won't be enough.
1 x

spanglish
White Belt
Posts: 18
Joined: Wed Sep 06, 2017 11:58 pm
Languages: Spanish(N) English(beginner)
x 9

Re: PlayPhrase: search and play phrases from movies and audiobooks

Postby spanglish » Fri Oct 13, 2017 9:27 pm

Is it possible in the future that I have support for android?

and can be compatible with frequent word lists in ankidriod
0 x

kelciour
White Belt
Posts: 17
Joined: Wed Feb 01, 2017 11:39 pm
Languages: Russian (N), English (self-study)
x 32

Re: PlayPhrase: search and play phrases from movies and audiobooks

Postby kelciour » Fri Oct 13, 2017 9:59 pm

No, it's not possible.
0 x

kelciour
White Belt
Posts: 17
Joined: Wed Feb 01, 2017 11:39 pm
Languages: Russian (N), English (self-study)
x 32

Re: PlayPhrase: search and play phrases from movies and audiobooks

Postby kelciour » Tue Nov 07, 2017 8:01 pm

I've updated the script and recorded demo to show how to set it up and run on Windows.



Changes:

- Now it supports multiline search, for example, "I've been staring at.*?I can lead with pride.*?How far I'll go".
- Added option to extract search results as video or audio fragments:

  • By using command-line options:

    Code: Select all

    -a, --audio - export as audio
    -v, --video - export as video
    -s, --video-sub - export as video with subtitles

  • Or by using cut.lua script for mpv videoplayer to set the start time and the end time while watching the video and export it as audio, video or video with subtitles.

    By default the hotkeys are:

    Code: Select all

    w - set the start time
    e - set the end time
    z - export as audio
    x - export as video
    c - export as video with subtitles

    Standard mpv hotkeys:

    Code: Select all

    LEFT and RIGHT - Seek backward/forward 5 seconds. Shift+arrow does a 1 second exact seek.
    UP and DOWN - Seek forward/backward 1 minute. Shift+arrow does a 5 second exact seek.
    Ctrl+LEFT and Ctrl+RIGHT - Seek to the previous/next subtitle. Subject to some restrictions and might not always work; see ...
    . - Step forward. Pressing once will pause, every consecutive press will play one frame and then go into pause mode again.
    . - Step backward. Pressing once will pause, every consecutive press will play one frame in reverse and then go into pause mode again.

    More: https://mpv.io/manual/master/#keyboard-control
  • The cut.lua script had been included in playphrase-win32.zip archive (utils/mpv/scripts) or it can be downloaded via this link.
  • To get it working you either can add the path to the folder that contains ffmpeg.exe (that can be found inside playphrase-win32.zip or downloaded from https://ffmpeg.zeranoe.com) in your PATH environment variable or edit cut.lua and update the line #3 by using the absolute path to ffmpeg.exe instead of [[ffmpeg]], for example, [[C:\Programs\playphrase\utils\ffmpeg\ffmpeg.exe]].
  • By default encoding preset is 'ultrafast'. By editing cut.lua file it can be changed, for example, to 'medium'. With these changes it'll took more time to export video fragments, but the result file size will be much smaller (~2 times less).
Here's example files (Moana (2016)) that had been generated by cut.lua script (link).
1 x


Return to “Language Programs and Resources”

Who is online

Users browsing this forum: No registered users and 1 guest