Package: transcribe-allign-textgrid
Transcribe Allign TextGridA small wrapper package aroundwhisper-timestamped. Create force-aligned transcription TextGrids from raw audio.InstallationRequirementsPython3.8topython3.11.Use the executablepython3.xon Unix, available in most package managers, orpy -3.xon Windows.This command line executable of will be referred to as[python-executable]for the rest of the instructionsInstall pip on old python versions with[python-executable] -m ensurepip --default-pipffmpegUsually preinstalled on Linux. For Windows see instructions for installation on thewhisper repositorygitUsually preinstalled on Linux. For Windows, visitthe git site.Needed for installation of whisper-timestamped, as it is not available on PyPINote that it needs to be available from the command line; git-bash might not work.Installing TorchTorch, on which Whisper is built, is quite a low-level library, meaning which version you'll need depends on your OS and type of GPU. On Mac and Windows, pip will by default install a non-accelerated CPU version of the library. If you are on Linux, it will presume you have a CUDA-capable (which is to say Nvidia branded) GPU. If you are on Windows and have an Nvidia GPU you can use, or are on Linux and either do not have a GPU or have an AMD GPU, you should check out the more detailed torch installation instructionshere.This should be donebeforeinstallingtranscribe_allign_textgridandwhisper_timestamped.InstallingOnce the requirements are satisfied, you can install whisper-timestamped and this package:Whisper-timestamped is not on Pypi, so a separategit+install is needed. (If you only want to use the package as a library instead of a cli, whisper-timestamped is not a dependency, and this manual install of it is not needed.)[python-executable]-mpipinstallgit+https://github.com/linto-ai/whisper-timestamped[python-executable]-mpipinstalltranscribe_allign_textgridRunning from the command lineOnce the application is installed, you can run it with:[python-executable]-mtranscribe_allign_textgrid[path]herepathis the path to the audio files.If a directory path is passed, all audio files in the directory will be transcribed, and force-aligned transcription TextGrids of the same name will be generated in this directory.If a file path is passed, a force-aligned transcription TextGrid will be generated into the same directory with the same name as the original file.If a glob is passed, the glob will be resolved and all matches will be processed as if the files were passed individuallyBy default, if a non-audio file is passed, an error is raised. To skip those instead, pass the--skipflag.Selecting a different modelBy default, this will run on the smallest, that is, least accurate and fastest, model,tiny. To run with another model, pass it as an argument:[python-executable]-mtranscribe_allign_textgrid[path]--model[model]The available models are:nameParametersRequired VRAMRelative speedtiny39 M~1 GB~32xbase74 M~1 GB~16xsmall244 M~2 GB~6xmedium769 M~5 GB~2xlarge1550 M~10 GB1xSpecifying what language to useBy default, the application will try to detect what language is used automatically. However, you can also specify this manually:[python-executable]-mtranscribe_allign_textgrid[path]--language[language]# Or also specifying what model to use:[python-executable]-mtranscribe_allign_textgrid[path]--model[model]--language[language]To see what languages are available, please see thetokenizer.pyfile in the Whisper source (Yes, the OpenAI team themselves recommends finding it this way, too.)Using as a libraryThe tool can also be used as a library. It exports one function:whisper_to_textgrid()Which takes in a transcription object (nested dictionary) fromwhisper-timestampedand returns a Textgrid object frompraatio. The typical Json output from whisper-timestamped works, too.This library part of the package does not depend on whisper-timestamped, to make it fully installable and usable as a requirement via pipy.OutputThe output TextGrids have four TextGridTiers:segments_textThe text in a given segment (Speaker's turn)segments_confidenceThe confidence the model has that this is the correct labeling and segmentation for the segmentwords_textThe text of a given wordwords_confidenceThe confidence the model has that this is the current labeling and segmentation for this word.If one of these tiers would have been empty per the output of whisper-timestamped, to satisfy Praat's error handling, a tier with an empty interval (0.0, 0.1) is generated.In praat, it will look a little like this:DevelopmentThe package is quite trivial, but, if you want to work on it, here are some instructionsStyleAll code is formatted with theBlackcode-formatter. As for casing, python standards are used except in cases where dependencies don't.I am dyslectic, and quite likely to make spelling errors in variables. If you find any, don't hesitate to send me a pull request!Running TestsAfter cloning the repository, moving into it, and installingpytestandpytest-covwith pip, run tests with:# Install the current version of the package locally to be able to test it.[python-executable]-mpipinstall-e.[python-executable]-mpytest--cov=transcribe_allign_textgridtests/