Autosub - Command-line utility for auto-generating subtitles for any video file

Related tags

CLI Tools autosub
Overview

Autosub

Auto-generated subtitles for any video

Autosub is a utility for automatic speech recognition and subtitle generation. It takes a video or an audio file as input, performs voice activity detection to find speech regions, makes parallel requests to Google Web Speech API to generate transcriptions for those regions, (optionally) translates them to a different language, and finally saves the resulting subtitles to disk. It supports a variety of input and output languages (to see which, run the utility with the argument --list-languages) and can currently produce subtitles in either the SRT format or simple JSON.

Installation

  1. Install ffmpeg.
  2. Run pip install autosub.

Usage

$ autosub -h
usage: autosub [-h] [-C CONCURRENCY] [-o OUTPUT] [-F FORMAT] [-S SRC_LANGUAGE]
               [-D DST_LANGUAGE] [-K API_KEY] [--list-formats]
               [--list-languages]
               [source_path]

positional arguments:
  source_path           Path to the video or audio file to subtitle

optional arguments:
  -h, --help            show this help message and exit
  -C CONCURRENCY, --concurrency CONCURRENCY
                        Number of concurrent API requests to make
  -o OUTPUT, --output OUTPUT
                        Output path for subtitles (by default, subtitles are
                        saved in the same directory and name as the source
                        path)
  -F FORMAT, --format FORMAT
                        Destination subtitle format
  -S SRC_LANGUAGE, --src-language SRC_LANGUAGE
                        Language spoken in source file
  -D DST_LANGUAGE, --dst-language DST_LANGUAGE
                        Desired language for the subtitles
  -K API_KEY, --api-key API_KEY
                        The Google Translate API key to be used. (Required for
                        subtitle translation)
  --list-formats        List all available subtitle formats
  --list-languages      List all available source/destination languages

License

MIT

Comments
  • PicklingError

    PicklingError

    Thanks for this amazing tool .. I try it on with fr as a source and destination language without any issue. but with the very same video

    autosub -F srt -S fr-FR -D en 'fun-sd(0).mp4'

    Converting speech regions to FLAC files: 100% |###########################################| Time: 0:00:07 Performing speech recognition: 100% |#####################################################| Time: 0:02:35 Traceback (most recent call last): | | ETA: --:--:-- File "/usr/local/bin/autosub", line 257, in sys.exit(main()) File "/usr/local/bin/autosub", line 224, in main for i, transcript in enumerate(pool.imap(translator, transcripts)): File "/usr/lib/python2.7/multiprocessing/pool.py", line 659, in next raise value multiprocessing.pool.MaybeEncodingError: Error sending result: 'HTTPError()'. Reason: 'PicklingError("Can't pickle <type 'cStringIO.StringO'>: attribute lookup cStringIO.StringO failed",)'

    opened by ddavout 8
  • googleapiclient.errors occur, what is the problem?

    googleapiclient.errors occur, what is the problem?

    I have install autosub,when I run a demo using google api key you provided in code ,I got a error like this, how did it happen? hustclf@ubuntu:~/.local/bin$ ./autosub -o /home/hustclf/ -F srt -S zu -D en -K AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw /home/hustclf/Desktop/zulu.vdat Converting speech regions to FLAC files: 100% |###################################| Time: 0:00:08 Performing speech recognition: 100% |#############################################| Time: 0:00:38 Exception in thread Thread-3:8% |#### | ETA: 0:00:00 Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/usr/lib/python2.7/multiprocessing/pool.py", line 389, in _handle_results task = get() File "/home/hustclf/.local/lib/python2.7/site-packages/oauth2client/util.py", line 137, in positional_wrapper return wrapped(*args, **kwargs) TypeError: ('__init__() takes at least 3 arguments (1 given)', <class 'googleapiclient.errors.HttpError'>, ())

    opened by hustclf 7
  • Exception: Dependency not found: ffmpeg

    Exception: Dependency not found: ffmpeg

    There are some problems happened when I ran the command. I actually added the path of ffmpeg into the PATH and the command "ffmpeg -version" can return a correct result.

    (Subgen) D:\SystemFiles\Videos>autosub 01.mp4 ffmpeg: Executable not found on machine. Traceback (most recent call last): File "F:\Anaconda3\envs\Subgen\Scripts\autosub-script.py", line 11, in load_entry_point('autosub==0.3.13', 'console_scripts', 'autosub')() File "F:\Anaconda3\envs\Subgen\lib\site-packages\autosub-0.3.13-py3.6.egg\autosub_init_.py", line 257, in main File "F:\Anaconda3\envs\Subgen\lib\site-packages\autosub-0.3.13-py3.6.egg\autosub_init_.py", line 275, in generate_subtitles File "F:\Anaconda3\envs\Subgen\lib\site-packages\autosub-0.3.13-py3.6.egg\autosub_init_.py", line 148, in extract_audio Exception: Dependency not found: ffmpeg

    and ffmpeg:

    (Subgen) D:\SystemFiles\Documents\Toys>ffmpeg -version ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 7.3.0 (GCC)

    Environment: Windows10 1709 Anaconda3 Python 3.6.5

    opened by Asuka109 6
  • How to use it on windows?

    How to use it on windows?

    I have install ffmpeg and autosub on my computer, it's windows 10, but I can't figure out how to use it. Can anyone tell me that, please? Much thanks.

    opened by tarvos21 5
  • Change translation from Goslate to Google Translate API

    Change translation from Goslate to Google Translate API

    Reason:

    • Goslate is abandoned, new translation mechanism needed

    New features:

    • translation using Google Translate API
    • added parameter to specify Google Translate API key, (-K API_KEY or --api-key API_KEY)
    • Reformatted autosub file to comply with PEP8
    • EDIT: Source / destination language codes updated according to Google's docs and simplified the parameter from --list-(src|dst)-languages to --list-languages

    Fixes:

    • #12
    opened by RNabel 5
  • SyntaxError: invalid syntax

    SyntaxError: invalid syntax

    # autosub -h
      File "/usr/local/bin/autosub", line 136
        print "The given file does not exist: {0}".format(filename)
                                                 ^
    SyntaxError: invalid syntax
    root@ubuntu:~# autosub -h
      File "/usr/local/bin/autosub", line 136
        print "The given file does not exist: {0}".format(filename)
                                                 ^
    SyntaxError: invalid syntax
    
    opened by liyuhang1997 4
  • Extract logic into a function to make it usable as a library

    Extract logic into a function to make it usable as a library

    I wanted to be able to call use autosub from another project without going through the command line via subprocess.call or similar. So I created a new function generate_subtitles and put the logic from the main method there. Functionality is unchanged, but it is now possible to do the following:

    from autosub import generate_subtitles
    new_subtitle_file_path = generate_subtitles(source_path, output, api_key=some_api_key)
    

    I also updated the code to be compatible with python 2 and 3, though it does introduce six as a dependency.

    opened by MattFisher 4
  • Performing speech recognition is not running

    Performing speech recognition is not running

    I code the autosub -S en -D en ... and it shows the Converting speech regions to FLAC files with 100% quickly, but when showing the Performing speech recognition it just stops at this and not running with always 0% unless I canceling transcription :(

    opened by jeremygoccc 3
  • [Solved, ffmpeg was not installed]  OSError: [Errno 2] No such file or directory

    [Solved, ffmpeg was not installed] OSError: [Errno 2] No such file or directory

    I get this error:

    autosub -F srt -S en-US -D en file.mp4

     Traceback (most recent call last):
     File "/usr/local/bin/autosub", line 257, in <module>
     sys.exit(main())
     File "/usr/local/bin/autosub", line 193, in main
     audio_filename, audio_rate = extract_audio(args.source_path)
     File "/usr/local/bin/autosub", line 103, in extract_audio
     subprocess.check_output(command)
     File "/usr/lib/python2.7/subprocess.py", line 566, in check_output
     process = Popen(stdout=PIPE, *popenargs, **kwargs)
     File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
     errread, errwrite)
     File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
     raise child_exception
     OSError: [Errno 2] No such file or directory
    

    I've installed iy by ‍‍‍‍‍‍‍‍‍‍‍‍‍'pip'

    opened by perpi 3
  • Does not find video

    Does not find video

    $ sudo pip install autosub
    $ ls
    test.avi
    $ autosub --format=srt -C 2 -S en-US -D en -o test.srt test.avi
    Traceback (most recent call last):
      File "/usr/local/bin/autosub", line 256, in <module>
        sys.exit(main())
      File "/usr/local/bin/autosub", line 193, in main
        audio_filename, audio_rate = extract_audio(args.source_path)
      File "/usr/local/bin/autosub", line 103, in extract_audio
        subprocess.check_output(command)
      File "/usr/lib/python2.7/subprocess.py", line 566, in check_output
        process = Popen(stdout=PIPE, *popenargs, **kwargs)
      File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
        errread, errwrite)
      File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
        raise child_exception
    OSError: [Errno 2] No such file or directory
    $ autosub test.avi
    Traceback (most recent call last):
      File "/usr/local/bin/autosub", line 256, in <module>
        sys.exit(main())
      File "/usr/local/bin/autosub", line 193, in main
        audio_filename, audio_rate = extract_audio(args.source_path)
      File "/usr/local/bin/autosub", line 103, in extract_audio
        subprocess.check_output(command)
      File "/usr/lib/python2.7/subprocess.py", line 566, in check_output
        process = Popen(stdout=PIPE, *popenargs, **kwargs)
      File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
        errread, errwrite)
      File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
        raise child_exception
    OSError: [Errno 2] No such file or directory
    
    opened by richardbaronpenman 3
  • Tried everything.

    Tried everything.

    Tried with python3 and python2 pip install git+https://github.com/agermanidis/autosub.git pip2 install git+https://github.com/agermanidis/autosub.git pip3 install git+https://github.com/agermanidis/autosub.git sudo update-alternatives --config python There are 2 choices for the alternative python (providing /usr/bin/python). Selection Path Priority Status

    • 0 /usr/bin/python3 2 auto mode 1 /usr/bin/python2 1 manual mode 2 /usr/bin/python3 2 manual mode Etc. (On Ubuntu 20.04)

    Still getting:

    (With Python3): File "/home/pacman/.local/bin/autosub", line 8, in sys.exit(main()) File "/home/pacman/.local/lib/python3.8/site-packages/autosub/init.py", line 397, in main subtitle_file_path = generate_subtitles( File "/home/pacman/.local/lib/python3.8/site-packages/autosub/init.py", line 247, in generate_subtitles regions = find_speech_regions(audio_filename) File "/home/pacman/.local/lib/python3.8/site-packages/autosub/init.py", line 198, in find_speech_regions reader = wave.open(filename) File "/usr/lib/python3.8/wave.py", line 510, in open return Wave_read(f) File "/usr/lib/python3.8/wave.py", line 164, in init self.initfp(f) File "/usr/lib/python3.8/wave.py", line 129, in initfp self._file = Chunk(file, bigendian = 0) File "/usr/lib/python3.8/chunk.py", line 63, in init raise EOFError EOFError

    (With Python2): autosub -S en test.mp4 Traceback (most recent call last): File "/home/pacman/.local/bin/autosub", line 8, in sys.exit(main()) File "/home/pacman/.local/lib/python2.7/site-packages/autosub/init.py", line 404, in main output=args.output, File "/home/pacman/.local/lib/python2.7/site-packages/autosub/init.py", line 247, in generate_subtitles regions = find_speech_regions(audio_filename) File "/home/pacman/.local/lib/python2.7/site-packages/autosub/init.py", line 198, in find_speech_regions reader = wave.open(filename) File "/usr/lib/python2.7/wave.py", line 511, in open return Wave_read(f) File "/usr/lib/python2.7/wave.py", line 164, in init self.initfp(f) File "/usr/lib/python2.7/wave.py", line 129, in initfp self._file = Chunk(file, bigendian = 0) File "/usr/lib/python2.7/chunk.py", line 63, in init raise EOFError EOFError

    (Under windows it worked...)

    (Sorry for the big font, dunno...)

    opened by HakkaTjakka 2
  • not working

    not working

    % autosub -h                                                                                                     
      File "/usr/local/bin/autosub", line 136
        print "The given file does not exist: {0}".format(filename)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
    
    
    opened by dportabella 1
  • Not compatible with 64-bit Windows?

    Not compatible with 64-bit Windows?

    Installed by pip install autosub, then enter autosub, only to find not recognized as an internal or external command, operable program or batch file. Used where autosub to find the location of autosub executable file, and then found that it had no name extension. Renamed it to autosub.exe and run, got a ''This version of this file is not compatible with the version of Windows you’re running"

    I use Windows 10 21H2 (19044.1706), with Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32

    opened by SyzygyYuan 1
  •   File ">

    File "/usr/local/bin/autosub", line 33, in

    Getting

    Traceback (most recent call last):
      File "/usr/local/bin/autosub", line 33, in <module>
        sys.exit(load_entry_point('autosub==0.4.0', 'console_scripts', 'autosub')())
      File "/usr/local/bin/autosub", line 25, in importlib_load_entry_point
        return next(matches).load()
    StopIteration
    
    opened by theapache64 0
  • installed using sudo python3 -m pip install autosub

    installed using sudo python3 -m pip install autosub

    Will not run had to sudo ln -s /volume1/@appstore/py3k/usr/local/bin/autosub /usr/local/bin/autosub

    autosub -h

     File "/usr/local/bin/autosub", line 136
        print "The given file does not exist: {0}".format(filename)
              ^
    
    opened by ozykisser 3
  • Again not working Ubuntu 20.04

    Again not working Ubuntu 20.04

    Ubuntu 20.04 Python 2 (after cleaning up .local) Python 3 (after cleaning up .local)

    pip install git+https://github.com/agermanidis/autosub.git (after cleaning up .local) pip2 install git+https://github.com/agermanidis/autosub.git (after cleaning up .local) pip3 install git+https://github.com/agermanidis/autosub.git (after cleaning up .local)

    Tried all combinations. First it didn't work. Then one day later it worked. Then next day stopped working, again. Tried the pip install and/or clone and/or .zip. Also tried other repo's. Under Ubuntu for Windows 10 still working, but a copy from there is not working under real Linux. Please help. Is it obstructed? Like (lots) of other stuff? (40 years of experience on things like this. Almost never something works good.)

    pacman@PACMAN-PC:~$ autosub -S en -D en test2.mp4 Traceback (most recent call last): File "/home/pacman/.local/bin/autosub", line 304, in sys.exit(main()) File "/home/pacman/.local/bin/autosub", line 232, in main regions = find_speech_regions(audio_filename) File "/home/pacman/.local/bin/autosub", line 147, in find_speech_regions reader = wave.open(filename) File "/usr/lib/python2.7/wave.py", line 511, in open return Wave_read(f) File "/usr/lib/python2.7/wave.py", line 164, in init self.initfp(f) File "/usr/lib/python2.7/wave.py", line 129, in initfp self._file = Chunk(file, bigendian = 0) File "/usr/lib/python2.7/chunk.py", line 63, in init raise EOFError EOFError

    opened by HakkaTjakka 0
  • returned non-zero exit status 1

    returned non-zero exit status 1

    The problem is “returned non-zero exit status 1” Using windows 10, install ffmpeg and add path. similar questions: https://github.com/agermanidis/autosub/pull/74 https://github.com/agermanidis/autosub/issues/20


    (py36_cgb) C:\Users\congm\Desktop\XXX>autosub -S fr -D zh-CN video.mp4 Output file #0 does not contain any stream Traceback (most recent call last): File "C:\software\Anaconda3\envs\py36_cgb\Scripts\autosub-script.py", line 33, in sys.exit(load_entry_point('autosub==0.4.0', 'console_scripts', 'autosub')()) File "C:\software\Anaconda3\envs\py36_cgb\lib\site-packages\autosub_init_.py", line 404, in main output=args.output, File "C:\software\Anaconda3\envs\py36_cgb\lib\site-packages\autosub_init_.py", line 245, in generate_subtitles audio_filename, audio_rate = extract_audio(source_path) File "C:\software\Anaconda3\envs\py36_cgb\lib\site-packages\autosub_init_.py", line 190, in extract_audio subprocess.check_output(command, stdin=open(os.devnull), shell=use_shell) File "C:\software\Anaconda3\envs\py36_cgb\lib\subprocess.py", line 356, in check_output **kwargs).stdout File "C:\software\Anaconda3\envs\py36_cgb\lib\subprocess.py", line 438, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['ffmpeg', '-y', '-i', 'video.mp4', '-ac', '1', '-ar', '16000', '-loglevel', 'error', 'C:\Users\congm\AppData\Local\Temp\tmpr2x_jqqi.wav']' returned non-zero exit status 1.


    (py36_cgb) C:\Users\congm\Desktop\VITAE_Sylvie_Lorthois>where ffmpeg C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\ffmpeg.exe C:\software\ImageMagick-7.0.10-Q16-HDRI\ffmpeg.exe D:\software\ffmpeg-2021-12-06-git-ef00d40e32-full_build\bin\ffmpeg.exe


    opened by congmingyige 1
Owner
Anastasis Germanidis
🎭
Anastasis Germanidis
Baseline is a cross-platform library and command-line utility that creates file-oriented baselines of your systems.

Baselining, on steroids! Baseline is a cross-platform library and command-line utility that creates file-oriented baselines of your systems. The proje

Nelson 4 Dec 9, 2022
A command-line utility that, given a markdown file, checks whether all its links work.

A command-line utility written in Python that checks validity of links in a markdown file.

Teclado 2 Dec 8, 2021
AML Command Transfer. A lightweight tool to transfer any command line to Azure Machine Learning Services

AML Command Transfer (ACT) ACT is a lightweight tool to transfer any command from the local machine to AML or ITP, both of which are Azure Machine Lea

Microsoft 11 Aug 10, 2022
A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Stream your favorite shows straight from the command line.

A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Installation pip install -r requirements.txt It use

Jonardon Hazarika 17 Dec 11, 2022
Command line tool for monitoring changes of File entities scoped in a Synapse File View

Synapse Monitoring Provides tools for monitoring and keeping track of File entity changes in Synapse with the use of File Views. Learn more about File

Sage Bionetworks 3 May 28, 2022
A lightweight Python module and command-line tool for generating NATO APP-6(D) compliant military symbols from both ID codes and natural language names

Python military symbols This is a lightweight Python module, including a command-line script, to generate NATO APP-6(D) compliant military symbol icon

Nick Royer 5 Dec 27, 2022
Library and command-line utility for rendering projects templates.

A library for rendering project templates. Works with local paths and git URLs. Your project can include any file and Copier can dynamically replace v

null 808 Jan 4, 2023
A command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, VueJS projects.

Cookiecutter A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python

null 18.6k Dec 30, 2022
A command line utility to export Google Keep notes to markdown.

Keep-Exporter A command line utility to export Google Keep notes to markdown files with metadata stored as a frontmatter header. Supports exporting: S

Nathan Beals 85 Dec 17, 2022
A command line utility for tracking a stock market portfolio. Primarily featuring high resolution braille graphs.

A command line stock market / portfolio tracker originally insipred by Ericm's Stonks program, featuring unicode for incredibly high detailed graphs even in a terminal.

Conrad Selig 51 Nov 29, 2022
📦 A command line utility to put text in a box.

boxie A command line utility to put text in a box. Installation pip install boxie If you are on Linux you may need to use sudo to access this globally

Eliaz Bobadilla 10 Jun 30, 2022
Tiny command-line utility for mapping broken keys to other positions.

brokenkey Tiny command-line utility for mapping broken keys to other positions. Installation Clone this repository using git: git clone https://github

null 0 Oct 4, 2021
This is a CLI utility that allows you to view RedFlagDeals.com on the command line.

RFD Description Motivation Installation Usage View Hot Deals View and Sort Hot Deals Search Advanced View Posts Shell Completion bash zsh Description

Dave G 8 Nov 29, 2022
img-proof (IPA) provides a command line utility to test images in the Public Cloud

overview img-proof (IPA) provides a command line utility to test images in the Public Cloud (AWS, Azure, GCE, etc.). With img-proof you can now test c

null 13 Jan 7, 2022
cmsis-pack-manager is a python module, Rust crate and command line utility for managing current device information that is stored in many CMSIS PACKs

cmsis-pack-manager cmsis-pack-manager is a python module, Rust crate and command line utility for managing current device information that is stored i

pyocd 20 Dec 21, 2022
A Python module and command line utility for working with web archive data using the WACZ format specification

py-wacz The py-wacz repository contains a Python module and command line utility for working with web archive data using the WACZ format specification

Webrecorder 14 Oct 24, 2022
A Python module and command-line utility for converting .ANS format ANSI art to HTML

ansipants A Python module and command-line utility for converting .ANS format ANSI art to HTML. Installation pip install ansipants Command-line usage

null 4 Oct 16, 2022
Booky - A command line utility for bookmarking files on your terminal!

Booky A command line utility for bookmarking files for quick access With it you can: Bookmark and delete your (aliases of) files at demand Launch them

Pran 1 Sep 11, 2022
split-manga-pages: a command line utility written in Python that converts your double-page layout manga to single-page layout.

split-manga-pages split-manga-pages is a command line utility written in Python that converts your double-page layout manga (or any images in double p

Christoffer Aakre 3 May 24, 2022