Giter Site home page Giter Site logo

autosub's Introduction

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

autosub's People

Contributors

agermanidis avatar alopatindev avatar arkadiusz-wieczorek avatar cdric49 avatar gardenia22 avatar guifereis avatar jeandown123 avatar macchado avatar mattfisher avatar n0whereruoxi avatar peskdale avatar pytranscriber avatar rnabel avatar scls19fr avatar shaung avatar xennygrimmato avatar yasondinalt avatar ye-will avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

autosub's Issues

Installation problems

Installing collected packages: progressbar, six, httplib2, uritemplate, pyasn1, rsa, pyasn1-modules, oauth2client, google-api-python-client, urllib3, idna, chardet, requests, pysrt, autosub
Found existing installation: six 1.4.1
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 778, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip/utils/init.py", line 267, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-5if5AG-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

No file or directory

I made sure that video file "welcome.mp4" is in the directory where I ran

autosub welcome.py

Outputs the error:

Traceback (most recent call last):
File "/home/rahul/miniconda2/bin/autosub", line 284, in
sys.exit(main())
File "/home/rahul/miniconda2/bin/autosub", line 210, in main
audio_filename, audio_rate = extract_audio(args.source_path)
File "/home/rahul/miniconda2/bin/autosub", line 120, in extract_audio
subprocess.check_output(command)
File "/home/rahul/miniconda2/lib/python2.7/subprocess.py", line 566, in check_output
process = Popen(stdout=PIPE, _popenargs, *_kwargs)
File "/home/rahul/miniconda2/lib/python2.7/subprocess.py", line 710, in init
errread, errwrite)
File "/home/rahul/miniconda2/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

problem with de_DE to de

Traceback (most recent call last):
File "/usr/local/bin/autosub", line 257, in
sys.exit(main())
File "/usr/local/bin/autosub", line 240, in main
formatted_subtitles = formatter(timed_subtitles)
File "/usr/local/lib/python2.7/dist-packages/autosub/formatters.py", line 13, in srt_formatter
return '\n'.join(map(str, f))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 34: ordinal not in range(128)

Would be nice to catch these exceptions to get the rest running.

Is there are any requirement for source video, I just return a empty *.srt file

I found and downloaded this project today and have tried several times to create srt file as follow, but it just return empty. So I consider that if there are any requirement for source video or something wrong in my program?

autosub -C 4  ./wiml.wav
Converting speech regions to FLAC files: 100% |##################| Time: 0:00:01
Performing speech recognition: 100% |############################| Time: 0:00:04
Subtitles file created at ./wiml.srt

autosub -C 4  ./android.mp4 
Converting speech regions to FLAC files: 100% |##################| Time: 0:00:01
Performing speech recognition: 100% |############################| Time: 0:00:02
Subtitles file created at ./android.srt

autosub  ./spill.mp4
Converting speech regions to FLAC files: 100% |##################| Time: 0:00:00
Performing speech recognition: 100% |############################| Time: 0:00:01
Subtitles file created at ./spill.srt

Ps:

  1. I download 'spill.mp4' from 'https://www.youtube.com/watch?v=4_mvu35FrFg' which is the test video in #31 .But I still create a empty .srt file.
  2. It is just take several seconds to complete recognition process. Is it normal?
  3. this is the origin file sample ( ./wiml.wav) attribute:
Codec: WAV
CHannels: Mono
Sample rate: 16000HZ
Bitrate:N/A
  1. btw, It is ok for me to connect to google:
wget www.google.com
--2017-03-26 16:11:53--  http://www.google.com/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:8087... connected.
Proxy request sent, awaiting response... 301 
Location: https://www.google.com/ [following]
--2017-03-26 16:11:53--  https://www.google.com/
Connecting to localhost (localhost)|127.0.0.1|:8087... connected.
Proxy request sent, awaiting response... 302 Found
Location: http://www.google.com.hk/url?sa=p&hl=zh-CN&pref=hkredirect&pval=yes&q=http://www.google.com.hk/%3Fgws_rd%3Dcr&ust=1490515943883163&usg=AFQjCNEN29XXuEQQlfOE3M_SZTGZKSvsbg [following]
--2017-03-26 16:11:53--  http://www.google.com.hk/url?sa=p&hl=zh-CN&pref=hkredirect&pval=yes&q=http://www.google.com.hk/%3Fgws_rd%3Dcr&ust=1490515943883163&usg=AFQjCNEN29XXuEQQlfOE3M_SZTGZKSvsbg
Reusing existing connection to localhost:8087.
Proxy request sent, awaiting response... 302 
Location: http://www.google.com.hk/?gws_rd=cr [following]
--2017-03-26 16:11:54--  http://www.google.com.hk/?gws_rd=cr
Reusing existing connection to localhost:8087.
Proxy request sent, awaiting response... 200 
Length: 11020 (11K) [text/html]
Saving to: ‘index.html’

100%[======================================>] 11,020      --.-K/s   in 0s      

ImportError: No module named autosub

I installed autosub on windows, with python27 to c:\Python27\Scripts
I run it with the following command.
But while doing so I get many errors while the program tries to fork new instances of itself.

How to fix this?

Batch Script

@echo off
SET PATH=%PATH%;P:\utilities\MeGUI_2418_x86\tools\ffmpeg\
SET PATH=%PATH%;c:\Python27\Scripts\
c:
cd\Python27\Scripts\
c:\Python27\python.exe autosub "theaudioinput.mp3"

Output

    Traceback (most recent call last):
    C  File "<string>", line 1, in <module>
      File "c:\Python27\lib\multiprocessing\forking.py", line 380, in main--:--:--
        prepare(preparation_data)
      File "c:\Python27\lib\multiprocessing\forking.py", line 489, in prepare
        file, path_name, etc = imp.find_module(main_name, dirs)
    ImportError: No module named autosub
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\Python27\lib\multiprocessing\forking.py", line 380, in main
        prepare(preparation_data)
      File "c:\Python27\lib\multiprocessing\forking.py", line 489, in prepare
        file, path_name, etc = imp.find_module(main_name, dirs)
    ImportError: No module named autosub
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\Python27\lib\multiprocessing\forking.py", line 380, in main
        prepare(preparation_data)
      File "c:\Python27\lib\multiprocessing\forking.py", line 489, in prepare
        file, path_name, etc = imp.find_module(main_name, dirs)
    ImportError: No module named autosub
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\Python27\lib\multiprocessing\forking.py", line 380, in main
        prepare(preparation_data)
      File "c:\Python27\lib\multiprocessing\forking.py", line 489, in prepare
        file, path_name, etc = imp.find_module(main_name, dirs)
    ImportError: No module named autosub
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\Python27\lib\multiprocessing\forking.py", line 380, in main
        prepare(preparation_data)
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\Python27\lib\multiprocessing\forking.py", line 380, in main
        prepare(preparation_data)
      File "c:\Python27\lib\multiprocessing\forking.py", line 489, in prepare
        file, path_name, etc = imp.find_module(main_name, dirs)
    ImportError: No module named autosub
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\Python27\lib\multiprocessing\forking.py", line 380, in main
        prepare(preparation_data)
      File "c:\Python27\lib\multiprocessing\forking.py", line 489, in prepare
        file, path_name, etc = imp.find_module(main_name, dirs)
    ImportError: No module named autosub
    Traceback (most recent call last):
      File "c:\Python27\lib\multiprocessing\forking.py", line 489, in prepare
      File "<string>", line 1, in <module>
          File "c:\Python27\lib\multiprocessing\forking.py", line 380, in main
    file, path_name, etc = imp.find_module(main_name, dirs)
        ImportErrorprepare(preparation_data)
    :   File "c:\Python27\lib\multiprocessing\forking.py", line 489, in prepar

Ability to change length of subtitle

I'm new to this and am finding it useful. However, for most transcripts I'd like it to be able to control how many characters you can have for each subtitle. For interview transcription, I'd set it at 300 characters, so it doesn't interrupt the text flow quite so often.

Also, if there is any way to grab the starting timecode from the video file, that would also be enormously helpful. But I'm not sure if FLAC files have timecode capabilities.

Thanks. And good work.

Error during extracting the subtitle from video

I followed the guide everything is installed correctly, opened my cmd in the directory of the video but when i tried to generate subtitles this occurred:
C:\Users\wasee>C:\Python27\python.exe C:\Python27\scripts\autosub_app.py -S en -D en YouVideo.mp4
Traceback (most recent call last):
File "C:\Python27\scripts\autosub_app.py", line 283, in
sys.exit(main())
File "C:\Python27\scripts\autosub_app.py", line 209, in main
audio_filename, audio_rate = extract_audio(args.source_path)
File "C:\Python27\scripts\autosub_app.py", line 119, in extract_audio
subprocess.check_output(command)
File "C:\Python27\lib\subprocess.py", line 567, in check_output
process = Popen(stdout=PIPE, _popenargs, *_kwargs)
File "C:\Python27\lib\subprocess.py", line 711, in init
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 959, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

1OSError: [Errno 2] No such file or directory

Hi ;)

I am trying to run your script via php shell_exec comand but i keep getting this error.

1OSError: [Errno 2] No such file or directory

My php script is running as follows.

$output = shell_exec("cd {$targetDir}/ &&  /usr/local/bin/autosub movie.mp4 2>&1");

Any suggest would be great?

Thanks in advance.

Update on error

1Traceback (most recent call last): File "/usr/local/bin/autosub", line 283, in sys.exit(main()) File "/usr/local/bin/autosub", line 209, in main audio_filename, audio_rate = extract_audio(args.source_path) File "/usr/local/bin/autosub", line 119, in extract_audio subprocess.check_output(command) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 566, in check_output process = Popen(stdout=PIPE, *popenargs, **kwargs) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__ errread, errwrite) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory

Capitalisation within lines is lost

The use of capitalize() on each line of the speech API output here causes capital letters in proper nouns and abbreviations to be lost.

For example:
API output: the city of York is in the UK
Subtitle: The city of york is in the uk

Instead, something along the lines of

line = line['result'][0]['alternative'][0]['transcript']
return line[:1].upper() + line[1:]

could be used instead.

SyntaxError: Missing parentheses in call to 'print'

I was trying to install autosub on Windows 8.1 but i did get this message:

pip install autosub
Collecting autosub
  Downloading autosub-0.3.8.tar.gz
Collecting google-api-python-client>=1.4.2 (from autosub)
  Downloading google_api_python_client-1.5.1-py2.py3-none-any.whl (50kB)
    100% |################################| 51kB 1.6MB/s
Requirement already satisfied (use --upgrade to upgrade): requests>=2.3.0 in c:\users\<user>\appdata\local\progr
ams\python\python35-32\lib\site-packages (from autosub)
Collecting pysrt>=1.0.1 (from autosub)
  Downloading pysrt-1.1.1.tar.gz (104kB)
    100% |################################| 112kB 6.6MB/s
Collecting progressbar>=2.3 (from autosub)
  Downloading progressbar-2.3.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\<user>\AppData\Local\Temp\pip-build-rjxli7ux\progressbar\setup.py", line 5, in <module>
        import progressbar
      File "C:\Users\<user>\AppData\Local\Temp\pip-build-rjxli7ux\progressbar\progressbar\__init__.py", line 59,
 in <module>
        from progressbar.widgets import *
      File "C:\Users\<user>\AppData\Local\Temp\pip-build-rjxli7ux\progressbar\progressbar\widgets.py", line 121,
 in <module>
        class FileTransferSpeed(Widget):
      File "c:\users\<user>\appdata\local\programs\python\python35-32\lib\abc.py", line 133, in __new__
        cls = super().__new__(mcls, name, bases, namespace)
    ValueError: 'format' in __slots__ conflicts with class variable

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\<user>\AppData\Local\Temp\pip-build-rjxl
i7ux\progressbar\

The reason i believe was python 3 so i tried python 2 instead and it seems to work but instead i now get this message when i try to run it:

python autosub
  File "autosub", line 252
    See --help for further information."
                                       ^
SyntaxError: Missing parentheses in call to 'print'

So i can't even get the help to show up :(

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'>, ())

What's the problem?

When I run 'pip install autosub' ,there is a error.
I use python3.5.1-amd64 & pip 8.0.2

Using cached progressbar-2.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\xxx\AppData\Local\Temp\pip-build-tl1gmkiv\progressbar\setu
.py", line 5, in
import progressbar
File "C:\Users\xxx\AppData\Local\Temp\pip-build-tl1gmkiv\progressbar\prog
essbar__init__.py", line 59, in
from progressbar.widgets import *
File "C:\Users\xxx\AppData\Local\Temp\pip-build-tl1gmkiv\progressbar\prog
essbar\widgets.py", line 121, in
class FileTransferSpeed(Widget):
File "c:\program files\python35\lib\abc.py", line 133, in new
cls = super().new(mcls, name, bases, namespace)
ValueError: 'format' in slots conflicts with class variable
....

Error Installing autosub

Error when running the install command pip install autosub

Collecting autosub
  Using cached autosub-0.3.12.tar.gz
Collecting google-api-python-client>=1.4.2 (from autosub)
  Using cached google_api_python_client-1.6.2-py2.py3-none-any.whl
Collecting requests>=2.3.0 (from autosub)
  Using cached requests-2.18.1-py2.py3-none-any.whl
Collecting pysrt>=1.0.1 (from autosub)
  Using cached pysrt-1.1.1.tar.gz
Collecting progressbar>=2.3 (from autosub)
  Using cached progressbar-2.3.tar.gz
Collecting six<2dev,>=1.6.1 (from google-api-python-client>=1.4.2->autosub)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting httplib2<1dev,>=0.9.2 (from google-api-python-client>=1.4.2->autosub)
  Using cached httplib2-0.10.3.tar.gz
Collecting uritemplate<4dev,>=3.0.0 (from google-api-python-client>=1.4.2->autosub)
  Using cached uritemplate-3.0.0-py2.py3-none-any.whl
Collecting oauth2client<5.0.0dev,>=1.5.0 (from google-api-python-client>=1.4.2->autosub)
  Using cached oauth2client-4.1.2-py2.py3-none-any.whl
Collecting urllib3<1.22,>=1.21.1 (from requests>=2.3.0->autosub)
  Using cached urllib3-1.21.1-py2.py3-none-any.whl
Collecting idna<2.6,>=2.5 (from requests>=2.3.0->autosub)
  Using cached idna-2.5-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests>=2.3.0->autosub)
  Using cached certifi-2017.4.17-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests>=2.3.0->autosub)
  Using cached chardet-3.0.4-py2.py3-none-any.whl
Collecting rsa>=3.1.4 (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client>=1.4.2->autosub)
  Using cached rsa-3.4.2-py2.py3-none-any.whl
Collecting pyasn1-modules>=0.0.5 (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client>=1.4.2->autosub)
  Using cached pyasn1_modules-0.0.9-py2.py3-none-any.whl
Collecting pyasn1>=0.1.7 (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client>=1.4.2->autosub)
  Using cached pyasn1-0.2.3-py2.py3-none-any.whl
Installing collected packages: six, httplib2, uritemplate, pyasn1, rsa, pyasn1-modules, oauth2client, google-api-python-client, urllib3, idna, certifi, chardet, requests, pysrt, progressbar, autosub
  Found existing installation: six 1.4.1
    DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/var/folders/nf/n6bqf42169s8n0q3669609n40000gn/T/pip-kmtfhQ-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

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.

Option to spell out numbers

Is there any way I can force the program to spell out numbers (i.e, eight instead of 8) when it generates the subtitles? It is very difficult to find and replace them as any search just catches the times....

Option of two steps(Suggestion)

Great script.
One suggestion, add the option of two steps.

  1. Generate an empty subtitle (srt) with the times. To also modify or correct some time with your favorite program (assgisub, edit subtitle, etc).
  2. Based on the times of empty file (srt), fill it with the SpeechGoogle.

Thank you.

ImportError: No module named constants

I have this error. Can anyone help me? I tried to uninstall and reinstall autosub many times but not still not working. Thank you!

Traceback (most recent call last):
File "C:\Python27\Scripts\autosub_app.py", line 17, in
from autosub.constants import LANGUAGE_CODES
File "C:\Python27\Scripts\autosub.py", line 17, in
ImportError: No module named constants

File "constants.py" was already in "lib" folder.

Please help me. Thank you so much!

Request/Suggestion for Multiple File handling Enhancements

Hello, I'm a github newbie and have only taken a couple of Python classes so if this is in the wrong place or out of line please forgive me. I think I have 2 ideas that would make this code even more useful than in already is and probably wouldn't take to much more effort for someone as skilled as you.
For the sake of brevity I'm simply say that I've got over 12k in short clips I'm working with (less than 30 seconds each) and that's the context of what I'm looking at this code with.
Here's are my suggestions:

1.) Building in a loop to go through a folder of video files. With my minimal skills I think I could put this together but I think it could help in this main code too.

2.) Have the option to have the code rename the original video file with the first X number of characters from the sub folder file, substituting spaces with underscores. This is more complex than #1 above, but for those of us dealing with large camera dumps of video files and sorting through lots of video files like I am it would be a lifesaver. This would really be pushing my limits in programming to figure out.

With these two enhancements I think you'd have quite the script. It wouldn't be aimed at your original target but the potential audience is much larger. I don't know if you have any interest in including these features but I wanted to suggest them and see what your thoughts are.

Regardless I may take a swipe at this and see if I can hack something together to get it to work over the next couple of weeks.

Thanks for sharing your work!

Chinese character problem

I got it a chinese subtitle from a english move.
chinese subtitle need GB2312 can work but it still keep UTF8 windows10 player can't load it

your api key

does it matter that it's in the constants? Can it be used maliciously?

Just thought I'd check =)

Google Speech to Text API key restrictions?

Hello,

I was just wondering what, if any, restrictions are there with respect to running the script with the included Google Speech to Text API Key? For example, would it be appropriate for business use? Or would that be breaking Google's TOS somehow?

Thanks.

Request for Improved Accuracy

Excellent script - I wonder if there is a way to improve accuracy of the subtitles (not necessarily translations) without making additional audio adjustments? I would like to use this script to replace a process that involves uploading to Youtube to retrieve their auto generated captions. Perhaps this could be incorporated as optional, as I am not as concerned about the speed of output though others may be.

To illustrate, the screenshot I'm including is a side-by-side comparison of the .SRT files, one generated by Autosub and the other by the Youtube generator.

Suggestions welcome, thank you.

initial autosub caption test vs youtube comparison

[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'

“python setup.py egg_info” failed with error code 1 when installing autosub

I tried to install Autosub but it shown error, and I cannot find a solution that work for me.

I already installed ffmpeg that required by Autosub and added path for it.

I also upgraded my setuptools.

C:\WINDOWS\system32>pip install autosub
Collecting autosub
  Using cached autosub-0.3.11.tar.gz
Collecting google-api-python-client>=1.4.2 (from autosub)
  Using cached google_api_python_client-1.6.2-py2.py3-none-any.whl
Requirement already satisfied: requests>=2.3.0 in c:\program files\python36\lib\site-packages (from autosub)
Collecting pysrt>=1.0.1 (from autosub)
  Using cached pysrt-1.1.1.tar.gz
Collecting progressbar>=2.3 (from autosub)
  Using cached progressbar-2.3.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\CHEKWE~1\AppData\Local\Temp\pip-build-4wnmhm6k\progressbar\setup.py", line 5, in <module>
        import progressbar
      File "C:\Users\CHEKWE~1\AppData\Local\Temp\pip-build-4wnmhm6k\progressbar\progressbar\__init__.py", line 59, in <module>
        from progressbar.widgets import *
      File "C:\Users\CHEKWE~1\AppData\Local\Temp\pip-build-4wnmhm6k\progressbar\progressbar\widgets.py", line 121, in <module>
        class FileTransferSpeed(Widget):
      File "c:\program files\python36\lib\abc.py", line 133, in __new__
        cls = super().__new__(mcls, name, bases, namespace)
    ValueError: 'format' in __slots__ conflicts with class variable

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\CHEKWE~1\AppData\Local\Temp\pip-build-4wnmhm6k\progressbar\

I found another answer that said enter easy_install -U setuptools but shown error too. (cmd is run as admin)

C:\WINDOWS\system32>easy_install -U setuptools
Searching for setuptools
Reading https://pypi.python.org/simple/setuptools/
Best match: setuptools 35.0.1
Processing setuptools-35.0.1-py3.6.egg
setuptools 35.0.1 is already the active version in easy-install.pth
Installing easy_install-script.py script to c:\program files\python36\Scripts
Installing easy_install.exe script to c:\program files\python36\Scripts
error: [WinError 5] Access is denied: 'c:\\program files\\python36\\Scripts\\easy_install.exe'

Any help would be appreciated.

Files with spaces will raise an exception

screenshot from 2015-07-04 08 48 10

generating the command everytime or writing a list substitution function would be a good idea,

cmd = ['ffmpeg', 'filename', ]
for x, y in kwargs.iteritems():
    cmd[cmd.index(x)] = y

rather than str.format and splitting.
str.format and splitting is also a working idea if you separate the ffmpeg arguments with a unique token(but that is just complicated)

great tool btw...

Some kind of infinite loop when running

I have successfully installed and tried running it, the help shows, but when I try to create subtitles, it gets stuck in some kind of loop. There is constant text output in the windows that is too fast to read and seems garbled when copied. Pasting it below:

D:>python autosub -F srt -S en -D en PuertoRico.mp4
Traceback (most recent call last):
File "", line 1, in
Traceback (most recent call last):
Traceback (most recent call last):
File "", line 1, in
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
C File "", line 1, in
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
Traceback (most recent call last):
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
Traceback (most recent call last):
File "", line 1, in iles: 0% | | ETA: --:--:--
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
file, path_name, etc = imp.find_module(main_name, dirs)
File "", line 1, in
Traceback (most recent call last):
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
File "", line 1, in
file, path_name, etc = imp.find_module(main_name, dirs)
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
Traceback (most recent call last):
ImportError : prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
ImportErrorN File "", line 1, in
Traceback (most recent call last):
file, path_name, etc = imp.find_module(main_name, dirs)
: o module named autosub File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
File "", line 1, in
file, path_name, etc = imp.find_module(main_name, dirs)
ImportErrorN
prepare(preparation_data)
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
ImportError: : File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
prepare(preparation_data)
o module named autosubNN Traceback (most recent call last):
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare

o module named autosubo module named autosubTraceback (most recent call last):

File "", line 1, in
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
file, path_name, etc = imp.find_module(main_name, dirs)
file, path_name, etc = imp.find_module(main_name, dirs)

File "", line 1, in
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
ImportErrorImportErrorfile, path_name, etc = imp.find_module(main_name, dirs)
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
ImportErrorfile, path_name, etc = imp.find_module(main_name, dirs)
: : : ImportErrorNprepare(preparation_data)
o module named autosubprepare(preparation_data)
N: N File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare

o module named autosub File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
No module named autosub
o module named autosub
file, path_name, etc = imp.find_module(main_name, dirs)

file, path_name, etc = imp.find_module(main_name, dirs)
ImportErrorImportError: No module named autosub
: No module named autosub
Traceback (most recent call last):
File "", line 1, in
Traceback (most recent call last):
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
File "", line 1, in
Traceback (most recent call last):
Traceback (most recent call last):
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
Traceback (most recent call last):
File "", line 1, in
File "", line 1, in
File "", line 1, in
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
prepare(preparation_data)
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
file, path_name, etc = imp.find_module(main_name, dirs)
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
file, path_name, etc = imp.find_module(main_name, dirs)
ImportErrorfile, path_name, etc = imp.find_module(main_name, dirs)
ImportErrorfile, path_name, etc = imp.find_module(main_name, dirs)
file, path_name, etc = imp.find_module(main_name, dirs)
: ImportErrorNImportErrorImportError: : o module named autosub: : NN
NNo module named autosubo module named autosubo module named autosubo module named autosub

Traceback (most recent call last):
File "", line 1, in
Traceback (most recent call last):
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
File "", line 1, in
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
File "", line 1, in
File "", line 1, in
prepare(preparation_data)
File "", line 1, in
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
prepare(preparation_data)
file, path_name, etc = imp.find_module(main_name, dirs)
prepare(preparation_data)
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
ImportError File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
: file, path_name, etc = imp.find_module(main_name, dirs)
file, path_name, etc = imp.find_module(main_name, dirs)
Nfile, path_name, etc = imp.find_module(main_name, dirs)
ImportErrorImportErroro module named autosubImportErrorfile, path_name, etc = imp.find_module(main_name, dirs)
: :
: ImportErrorNNN: o module named autosubo module named autosubo module named autosub

No module named autosub
Traceback (most recent call last):
File "", line 1, in
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
Traceback (most recent call last):
Traceback (most recent call last):
File "", line 1, in
Traceback (most recent call last):
File "", line 1, in
file, path_name, etc = imp.find_module(main_name, dirs)
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
File "", line 1, in
File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
Traceback (most recent call last):
ImportError File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
File "", line 1, in
: prepare(preparation_data)
N File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
prepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
o module named autosubprepare(preparation_data)
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare

File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
prepare(preparation_data)
file, path_name, etc = imp.find_module(main_name, dirs)
File "C:\Python27\lib\multiprocessing\forking.py", line 503, in prepare
ImportErrorfile, path_name, etc = imp.find_module(main_name, dirs)
file, path_name, etc = imp.find_module(main_name, dirs)
ImportError: ImportError: Nfile, path_name, etc = imp.find_module(main_name, dirs)
: No module named autosubImportErrorNo module named autosub
: o module named autosub
N
o module named autosub
^C
D:>

Issues With Installation

I am getting some errors with progressbar when installing:

$ python3 -m pip install autosub
Collecting autosub
  Using cached autosub-0.3.11.tar.gz
Collecting google-api-python-client>=1.4.2 (from autosub)
  Using cached google_api_python_client-1.6.1-py2.py3-none-any.whl
Collecting requests>=2.3.0 (from autosub)
  Using cached requests-2.12.4-py2.py3-none-any.whl
Collecting pysrt>=1.0.1 (from autosub)
  Using cached pysrt-1.1.1.tar.gz
Collecting progressbar>=2.3 (from autosub)
  Using cached progressbar-2.3.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/yf/q0zr3n9s33q_y9rtsnfdnrzh0000gn/T/pip-build-l9c_ljng/progressbar/setup.py", line 5, in <module>
        import progressbar
      File "/private/var/folders/yf/q0zr3n9s33q_y9rtsnfdnrzh0000gn/T/pip-build-l9c_ljng/progressbar/progressbar/__init__.py", line 59, in <module>
        from progressbar.widgets import *
      File "/private/var/folders/yf/q0zr3n9s33q_y9rtsnfdnrzh0000gn/T/pip-build-l9c_ljng/progressbar/progressbar/widgets.py", line 121, in <module>
        class FileTransferSpeed(Widget):
      File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/abc.py", line 133, in __new__
        cls = super().__new__(mcls, name, bases, namespace)
    ValueError: 'format' in __slots__ conflicts with class variable
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/yf/q0zr3n9s33q_y9rtsnfdnrzh0000gn/T/pip-build-l9c_ljng/progressbar/

Could this have something to do with the latest 3.6 release?

moov atom not found

The details show as follow.

allen@allen-vm:~$ autosub -S en-GB -D zh-CN SimplySolar.mp4
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x932caa0] moov atom not found
SimplySolar.mp4: Invalid data found when processing input
Traceback (most recent call last):
File "/usr/local/bin/autosub", line 260, in
sys.exit(main())
File "/usr/local/bin/autosub", line 194, in main
audio_filename, audio_rate = extract_audio(args.source_path)
File "/usr/local/bin/autosub", line 104, in extract_audio
subprocess.check_output(command)
File "/usr/lib/python2.7/subprocess.py", line 544, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['ffmpeg', '-y', '-i', 'SimplySolar.mp4', '-ac', '1', '-ar', '16000', '-loglevel', 'error', '/tmp/tmpdlIVEL.wav']' returned non-zero exit status 1

Run On Mac OS

Hello , i have successfully installed this on windows. But there is not tutorial for installing on Mac i want to use it on mac.. please help.

No srt output

After one hour past, I just get a blank srt file.Why?

Tips to improve translation.

Tips to improve translation.

For Video YouTube: ¡Bienvenidos a Extraordinerd!

Audio
extraordinarid
Result Run Script Autosub

Results: Very BAD

bad translation

Methods Improve Translation..

Method 1 : Trim/Crop

Crop video, 10 seconds Audio.
extraordinarid_trim

Results:

Speech: Medium
Timing: Good
extraordinarid 10 seconds

Method 2 Silence noise

Silence Audio (Noise,music, etc.)
extraoird_silencioaudiotext
Observations: The best method, but it requires a long time to identify the sounds, voices, ambient noise.

Results: Very good

extraoird_subtitlesilenciomusica

Method 3 Use Filters

Use Filters of FFmpeg, loudnorm or dynaudnorm
ffmpeg -i myvideo.mp4 -af loudnorm=i=-5 myvideoFilter.wav
extraoird_loudnormminus5text

Results: Very good

extraoird_subtitleloudnormminus5

Observations: It requires a special compilation of ffmpeg, but can be downloaded from here.

Method 4 Change threshold

Modify the script, and Zero the value of threshold=0
extraordinarid_subtitlezerothreshold

Observations:this case, it worked like that with the filter, but it is not always so. LOST TOTAL TIMING.

Notes

Note 1 : For speed, the audio must be converted to mono and frequency to 16000
Note 2 : For methods 2 to 4, the script could not identify the silences, so cutting it done automatically at 6.1 seconds (min_region_size = 0.5, max_region_size = 6)

About Google Speech API

While I was developing my own Speech-to-text generator. I came to know that google charges for speech API after 60 minutes.
As you have also used this API.. so are you really paying for this API every month? Or using for free? If free..please let me know so that i can use it for my project

doesn't find all speech regions

Hi,

I tried to create subtitles for some home videos of mine. And only two sentences where found in a 2min long video.

I tried changing the percentile and the min & max region sizes, but had no luck with it.

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

Encoding error with unicode content

I triggered a unicode error when trying a non-ascii language:

$ autosub test.avi -S en-US -D zh-TW
Converting speech regions to FLAC files: 100% |###########################################################################################################| Time: 0:01:49
Performing speech recognition: 100% |#####################################################################################################################| Time: 0:08:55
Translating from en-US to zh-TW: 100% |###################################################################################################################| Time: 0:00:06
Traceback (most recent call last):
  File "git/autosub/bin/autosub", line 260, in <module>
    sys.exit(main())
  File "git/autosub/bin/autosub", line 243, in main
    formatted_subtitles = formatter(timed_subtitles)
  File "build/bdist.linux-x86_64/egg/autosub/formatters.py", line 13, in srt_formatter
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 32: ordinal not in range(128)

Install AutoSub Step to Step in Windows with Translate subtitle

Requeriments
Windows 32 or 64 bits.
Connection Internet.
Links Downloads
Python
FFMPEG
AutoInstall autosub_app 0.3.12.zip
SampleVideos Spanish - English.zip
Subtitle Editor Aegisub
For Version autosub 0.3.9
Note: Uninstall Python 3.x
Tutorial Video Youtube

  1. Install Python 2.7 (32 bits)
    https://www.python.org/ftp/python/2.7.12/python-2.7.12.msi
    python
    ## Note: Check Add Python.exe to Path

  2. Run cmd (Win+R)
    C:\Python27\Scripts\pip.exe install autosub
    Or
    C:\Python27\Scripts\pip.exe install https://pypi.python.org/packages/35/7b/9d5361c0f7abfcc6d826a5279b1c4501f7616505629f6c54857587ec6e37/autosub-0.3.9.tar.gz
    or
    (Download Last version autosub https://pypi.python.org/pypi/autosub)
    C:\Python27\Scripts\pip.exe install "c:\youdownloaded\autosub-0.3.9.tar.gz"

    Message Output Normal

    Installing collected packages: autosub
    Successfully installed autosub-0.3.9
    
    
  3. Change Name File "autosub" to "autosub_app.py"
    Rename C:\Python27\Scripts\autosub autosub_app.py

  4. Modify with notepad.exe or Notepad++(Edit Text) autosub_app.py
    4.1 In line 48 add ", delete=False"
    temp = tempfile.NamedTemporaryFile(suffix='.flac')
    by
    temp = tempfile.NamedTemporaryFile(suffix='.flac', delete=False)
    4.2 Eliminate line 53 os.system('stty sane'). (Optional)
    UPDATE For last Version Autosub (23 May 2017)
    In Windows xp,7,8,10
    With Program Notepad change lines :
    Line 127 change
    exe_file = os.path.join(path, program)
    exe_file = os.path.join(path, program + ".exe")
    Line 47 change
    temp = tempfile.NamedTemporaryFile(suffix='.flac')
    temp = tempfile.NamedTemporaryFile(suffix='.flac', delete=False)

  5. Download(https://ffmpeg.zeranoe.com/builds/) and
    Copy ffmpeg.exe to C:\Python27\

  6. Restart Windows

  7. Test Script C:\Python27\python.exe C:\Python27\scripts\autosub_app.py --list-languages

SampleVideos Spanish - English.zip
autosub_app 0.3.12.zip

Auto-generating subtitles for any video file

Spanish
C:\Python27\python.exe C:\Python27\scripts\autosub_app.py -S es -D es TuVideo.mp4
English
C:\Python27\python.exe C:\Python27\scripts\autosub_app.py -S en -D en YouVideo.mp4
Japanese
C:\Python27\python.exe C:\Python27\scripts\autosub_app.py -S ja -D ja YouAnimeVideo.mp4
cmd

Optional
Compile script Python(Exe Executable)
C:\Python27\python.exe -m compileall C:\Python27\scripts\autosub_app.py
Run
C:\Python27\scripts\autosub_app.pyc YouVideo.mp4 (English Default)
Upgrade Pip
python -m pip install --upgrade pip

One-Click EASY with SENDTO.

autosub_app.zip
Create batch by language (JA) AutoSub_Jap.bat and copy to directory SendTo
"shell:sendto"
"%APPDATA%\Microsoft\Windows\SendTo"
AutoSub_Jap.bat
C:\Python27\python.exe C:\Python27\Scripts\autosub_app.py -C 2 -S ja -D ja %1
sendto
sendto

http://www.howtogeek.com/howto/windows-vista/customize-the-windows-vista-send-to-menu/
7.- Translate your Subtitles
Download Subtitle Edit https://github.com/SubtitleEdit/subtitleedit/releases
SubtitleEdit-3.4.13-Setup.zip Or VersionPortable SE3413PL.zip

  • Run SubtitleEdit.exe
  • Open Subtitle (TuVideo.srt,YouAnimeVideo.srt,YouVideo)
  • Menu-Auto-Translate-(PowerbyGoogle)
  • From(Japanese) To:English
  • Translate
    SUBTITLEEdit

Or

https://sourceforge.net/projects/srt-tran/
SRTTRANSLATOR

Results:

Link Video Youtube Test

Comparison

Auto-Generated by Youtube
President Obama Addresses the Nation on the BP Oil Spill (inglés).Youtube.srt.txt
Generated by Script AutoSub
President Obama Addresses the Nation on the BP Oil Spill (inglés).AutoSub.srt.txt
Time Process: 01:15 Abot Minute
Times are best generated by AUTOSUB.

Errors Commons in Windows

-Error install pip
"python setup.py egg_info"
Solution
Install Python 2.7 uninstall 3.x

"WindowsError [Error 2]"

C:\Python27>python.exe C:\Python27\scripts\autosub_app.py -S en -D en test.mp4
Traceback (most recent call last):
  File "C:\Python27\scripts\autosub_app.py", line 284, in <module>
    sys.exit(main())
  File "C:\Python27\scripts\autosub_app.py", line 210, in main
    audio_filename, audio_rate = extract_audio(args.source_path)
  File "C:\Python27\scripts\autosub_app.py", line 120, in extract_audio
    subprocess.check_output(command)
  File "C:\Python27\lib\subprocess.py", line 566, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "C:\Python27\lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
    startupinfo)
WindowsError: [Error 2]

Solution.
Copy ffmpeg.exe to C:\Python27\
or
Or ADD Path (Directory) File ffmpeg.
Examples: c:\ffmpeg\ , c:\Program Files\ffmpeg, c:\Mydownloads
Link Help Add Path(Directory)
http://www.computerhope.com/issues/ch000549.htm
python

Error infinite loop

"File "C:\Python27\lib\multiprocessing\forking.py", line 380"
"File "C:\Python27\lib\multiprocessing\forking.py", line 503"
ImportError : prepare(preparation_data)

Solution
Change name script C:\Python27\Scripts\autosub autosub_app.py

Error Permission denied Files Flac
c:...local\temp\tmpksjd.flac Permission denied
Solution:
Modify Script, close file. Link
#15

----------------------Before - Original-------------------------

class FLACConverter(object):
    def __init__(self, source_path, include_before=0.25, include_after=0.25):
        self.source_path = source_path
        self.include_before = include_before
        self.include_after = include_after

    def __call__(self, region):
        try:
            start, end = region
            start = max(0, start - self.include_before)
            end += self.include_after
            temp = tempfile.NamedTemporaryFile(suffix='.flac')
            command = ["ffmpeg", "-y", "-i", self.source_path,
                       "-ss", str(start), "-t", str(end - start),
                       "-loglevel", "error", temp.name]
            subprocess.check_output(command)
            os.system('stty sane')
            return temp.read()

----------------------After - Modified Option 1 ------------------------

class FLACConverter(object):
    def __init__(self, source_path, include_before=0.25, include_after=0.25):
        self.source_path = source_path
        self.include_before = include_before
        self.include_after = include_after

    def __call__(self, region):
        try:
            start, end = region
            start = max(0, start - self.include_before)
            end += self.include_after
            temp = tempfile.NamedTemporaryFile(suffix='.flac')      
            temp.close()
            command = ["ffmpeg", "-y", "-i", self.source_path,
                       "-ss", str(start), "-t", str(end - start),
                       "-loglevel", "error", temp.name]
            subprocess.check_output(command)
            return open(temp.name, "rb").read()

----------------------after - Modified Option 2 ------------------------

class FLACConverter(object):
    def __init__(self, source_path, include_before=0.25, include_after=0.25):
        self.source_path = source_path
        self.include_before = include_before
        self.include_after = include_after

    def __call__(self, region):
        try:
            start, end = region
            start = max(0, start - self.include_before)
            end += self.include_after
            temp = tempfile.NamedTemporaryFile(suffix='.flac', delete=False)
            command = ["ffmpeg", "-y", "-i", self.source_path,
                       "-ss", str(start), "-t", str(end - start),
                       "-loglevel", "error", temp.name]
            subprocess.check_output(command)
            return temp.read()

        except KeyboardInterrupt:
            return

Message Normal Output Pip install autosub

Collecting autosub
  Downloading autosub-0.3.9.tar.gz
Collecting google-api-python-client>=1.4.2 (from autosub)
  Downloading google_api_python_client-1.5.1-py2.py3-none-any.whl (50kB)
Collecting requests>=2.3.0 (from autosub)
  Downloading requests-2.11.0-py2.py3-none-any.whl (514kB)
Collecting pysrt>=1.0.1 (from autosub)
  Downloading pysrt-1.1.1.tar.gz (104kB)
Collecting progressbar>=2.3 (from autosub)
  Downloading progressbar-2.3.tar.gz
Collecting six<2,>=1.6.1 (from google-api-python-client>=1.4.2->autosub)
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting uritemplate<1,>=0.6 (from google-api-python-client>=1.4.2->autosub)
  Downloading uritemplate-0.6.tar.gz
Collecting httplib2<1,>=0.8 (from google-api-python-client>=1.4.2->autosub)
  Downloading httplib2-0.9.2.zip (210kB)
Collecting oauth2client (from google-api-python-client>=1.4.2->autosub)
  Downloading oauth2client-3.0.0.tar.gz (77kB)
Collecting chardet (from pysrt>=1.0.1->autosub)
  Downloading chardet-2.3.0.tar.gz (164kB)
Collecting simplejson>=2.5.0 (from uritemplate<1,>=0.6->google-api-python-client>=1.4.2->autosub)
  Downloading simplejson-3.8.2-cp27-cp27m-win32.whl (65kB)
Collecting pyasn1>=0.1.7 (from oauth2client->google-api-python-client>=1.4.2->autosub)
  Downloading pyasn1-0.1.9-py2.py3-none-any.whl
Collecting pyasn1-modules>=0.0.5 (from oauth2client->google-api-python-client>=1.4.2->autosub)
  Downloading pyasn1_modules-0.0.8-py2.py3-none-any.whl
Collecting rsa>=3.1.4 (from oauth2client->google-api-python-client>=1.4.2->autosub)
  Downloading rsa-3.4.2-py2.py3-none-any.whl (46kB)
Installing collected packages: six, simplejson, uritemplate, httplib2, pyasn1, pyasn1-modules, rsa, oauth2client, google-api-python-client, requests, chardet, pysrt, progressbar, autosub
  Running setup.py install for uritemplate: started
    Running setup.py install for uritemplate: finished with status 'done'
  Running setup.py install for httplib2: started
    Running setup.py install for httplib2: finished with status 'done'
  Running setup.py install for oauth2client: started
    Running setup.py install for oauth2client: finished with status 'done'
  Running setup.py install for chardet: started
    Running setup.py install for chardet: finished with status 'done'
  Running setup.py install for pysrt: started
    Running setup.py install for pysrt: finished with status 'done'
  Running setup.py install for progressbar: started
    Running setup.py install for progressbar: finished with status 'done'
  Running setup.py install for autosub: started
    Running setup.py install for autosub: finished with status 'done'
Successfully installed autosub-0.3.9 chardet-2.3.0 google-api-python-client-1.5.1 httplib2-0.9.2 oauth2client-3.0.0 progressbar-2.3 pyasn1-0.1.9 pyasn1-modules-0.0.8 pysrt-1.1.1 requests-2.11.0 rsa-3.4.2 simplejson-3.8.2 six-1.10.0 uritemplate-0.6


For Version autosub 0.3.9
File For Windows Modified. Rename autosub_app.py.txt to autosub_app.py, and copy

C:\Python27\Scripts

autosub_app.py.txt
SampleVideos Spanish - English.zip
autosub_app 0.3.12.zip

Ubuntu not generating srt files correctly(only 5% accuracy)

Hi,
thanks for the great library 👍

Installed autosub with python 2.7 in ubuntu 14.04 and using ffmpeg. Autosub is generating subtitle files, but the subtitle files are not accurate, its about only 5% accuracy.

I used the command as 'autosub videofile.mp4'.
Tried this video : https://www.youtube.com/watch?v=Ya6Av7uecbg

and the output is
President Obama Addresses the Nation on the BP Oil Spill.txt

Do I need to install/setup any additional libraries/plug-ins. Is any specific ffmpeg version needed. Is any machine configurations needed to change.

Please help.

Error in writing subtitle

Traceback (most recent call last):
  File "/usr/local/bin/autosub", line 256, in <module>
    sys.exit(main())
  File "/usr/local/bin/autosub", line 247, in main
    open(dest, 'wb').write(formatted_subtitles)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 125: ordinal not in range(128)```

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",)'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.