Skip to content

01. Usage

Jeff Zohrab edited this page Jun 9, 2022 · 6 revisions

Starting

Start it from the command line:

In top-level dir, after installing all dependencies:

source .venv/bin/activate
python main.py
deactivate

or (tested on Mac):

./pact.sh

Using

Open an mp3 file and a .txt translation file, and start making bookmarks.

Here's a quick demo:

A quick demo

Note that this video is slightly out-of-date. I'm using Pact myself and so continually make backwards-compatible changes to it to improve it; however, the basic ideas are still the same.

Transcriptions

Pact does a first-pass transcription of clips using Vosk. It's surprisingly good! Well, sometimes it's hilariously bad, but hey, that's software.

If a transcription file has been set with Menu > File > Open transcription, Pact tries to find the best match for the first pass. If it does, it updates the transcription to include any sentence beginnings and endings.

For example, if the first pass returned "tengo un perro y un gato", and the transcription file contained "Un hombre me dijo, 'Tengo un perro, y un gato,' pero no entiendo porque me lo dijo.", the transcription would be:

[Un hombre me dijo,] 'Tengo un perro, y un gato,' [pero no entiendo porque me lo dijo.]

If Pact couldn't find a good match, the transcription is left as-is, and the text box turns yellow. You might want to try to find your sentence in the transcription manually.

Lookups

You can click on a word in the transcription box and click "Lookup" to get its definition.

The actual lookup code that does the lookup is configured in the config.ini file, in the [Pact]/LookupModule.

Online lookups using thefreedictionary.com

Pact has a few primitive monolingual dictionary lookups available, e.g. in pact/plugins/lookup/spanish/es_thefreedictionary. These make calls to thefreedictionary.com site. These would be configured as so:

LookupModule = pact.plugins.lookup.spanish.es_thefreedictionary

Offline lookups (Mac)

A separate project, https://github.com/jzohrab/pact_osx_dict, provides a Pact plugin wrapper around the built-in Mac system directory. This can be installed in myplugins (see that project's README for installation and configuration notes).

Saving

Menu > File > Save session saves the currently loaded files (mp3 and transcription) and any defined bookmarks to disk. Then later, you can reload that session with Menu > File > Open session and continue.

This is useful when you're working with longer podcasts etc.

The session file (.pact) is just json, so if needed you can open the file in an editor and update it, e.g. if the mp3 or transcription files have moved or been renamed.

Studying multiple languages

Create different config files for your different languages, and then start Pact with a PACTCONFIG environment variable.

For example, in a 'configs' folder, you might have the following files:

german.ini:

[Pact]
LookupModule = pact.plugins.lookup.german.de_thefreedictionary
VoskModel = model/vosk-model-small-de-0.15

[Anki]
Deck = German
... [snip] ...

spanish.ini:

[Pact]
LookupModule = pact.plugins.lookup.spanish.es_thefreedictionary
VoskModel = model/spanish

[Anki]
Deck = Spanish
... [snip] ...

Then, to select which config you want, e.g.:

PACTCONFIG=configs/german.ini ./pact.sh

GUI Hotkeys

Main window

  • <Command-p>: Play/pause

  • <Right>: Advance slider 100 ms

  • <Left>: Move slider back 100 ms

  • <Command-Right>: Advance slider 1000 ms

  • <Command-Left>: Move slider back 1000 ms

  • <m>: Add bookmark

  • <u>: Update selected bookmark to slider position

  • <d>: Delete selected bookmark

  • <Up>: Select previous bookmark

  • <Down>: Select next bookmark

  • <Return>: Popup clip window for selected bookmark

Clip editor popup

  • <Command-p>: Play/pause full clip

  • <Command-r>: Reset the slider to 0

  • <Command-Right>: Advance slider to next sentence in the audio

  • <Command-Left>: Move slider back to previous sentence in the audio

  • <Right>: Advance slider 100 ms

  • <Left>: Move slider back 100 ms

  • <Shift-Right>: Advance slider 1000 ms

  • <Shift-Left>: Move slider back 1000 ms

  • <Command-s>: Set the clip start

  • <Command-e>: Set the clip end

  • <Command-Shift-s>: Move slider to clip start

  • <Command-Shift-e>: Move slider to clip end

  • <Command-l>: Play clip between start and end

  • <Command-t>: Transcribe clip

  • <Command-u>: Lookup selected word using lookup plugin

  • <Command-x>: Export clip and transcription to Anki

  • <Command-k>: OK. Close (and save) clip

Clone this wiki locally