Metadata-Version: 2.1
Name: stenocaptioner
Version: 0.3.2
Summary: 
License: MIT
Author: nekanat
Author-email: nekanat.stock@gmail.com
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: ffmpeg-python (==0.2.0)
Requires-Dist: more-itertools (>=9.0.0,<10.0.0)
Requires-Dist: moviepy (>=1.0.3,<2.0.0)
Requires-Dist: numpy (>=1.23.5,<2.0.0)
Requires-Dist: openai-whisper (>=20231117,<20231118)
Requires-Dist: scipy (>=1.9.3,<2.0.0)
Requires-Dist: torch (>=1.13.0,<2.0.0)
Requires-Dist: tqdm (>=4.64.1,<5.0.0)
Requires-Dist: transformers (>=4.25.1,<5.0.0)
Requires-Dist: youtube-dl (>=2021.12.17,<2022.0.0)
Description-Content-Type: text/markdown

# stenocaptioner

![PyPI - Python Version](https://img.shields.io/pypi/pyversions/stenocaptioner)
[![Downloads](https://pepy.tech/badge/stenocaptioner)](https://pepy.tech/project/stenocaptioner)

Automatic subtitling tool using whisper.

## Dependencies

* [whisper](https://github.com/openai/whisper)
* [moviepy](https://github.com/Zulko/moviepy)
* [youtube_dl](https://github.com/ytdl-org/youtube-dl)

## Installation

### Ubuntu

```sh
sudo apt-get -y install imagemagick fonts-vlgothic
```

You will also need to modify the ImageMagick configuration file to comment out the following policy.

```
sudo vi /etc/ImageMagick-6/policy.xml
  <!--
  <policy domain="path" pattern="@*" rights="none">
  -->
```

Install with pip.

```sh
pip install stenocaptioner
```

## Usage

You can give the url of youtube video as an argument.

```sh
stenocaptioner https://www.youtube.com/watch?v=ldybnuFxdiQ --language ja
```

### Options

```sh
stenocaptioner --help
usage: stenocaptioner [-h] [--language LANGUAGE] [--model-type {tiny,base,small,medium,large}] [--text-color TEXT_COLOR] [--background-color BACKGROUND_COLOR]
                      [--contour-color CONTOUR_COLOR] [--contour-width CONTOUR_WIDTH] [--font FONT] [--fontsize FONTSIZE] [--fadein-duration FADEIN_DURATION]
                      [--fadeout-duration FADEOUT_DURATION] [--save-text] [--load-text LOAD_TEXT] [--letter-effect {none,typing,arrive,cascade}] [--side-margin SIDE_MARGIN]
                      [--bottom-margin BOTTOM_MARGIN]
                      url

positional arguments:
  url                   URL of the video.

options:
  -h, --help            show this help message and exit
  --language LANGUAGE   Language of the text.
  --model-type {tiny,base,small,medium,large}
                        Whisper model type.
  --text-color TEXT_COLOR
                        Color of the text.
  --background-color BACKGROUND_COLOR
                        Color of the background.
  --contour-color CONTOUR_COLOR
                        Color of the contour.
  --contour-width CONTOUR_WIDTH
                        Width of the contour.
  --font FONT           Font name.
  --fontsize FONTSIZE   Font size.
  --fadein-duration FADEIN_DURATION
                        Duration of the fade-in effect.
  --fadeout-duration FADEOUT_DURATION
                        Duration of the fade-out effect.
  --save-text           Save the transcribed text.
  --load-text LOAD_TEXT
                        Load the transcribed text.
  --letter-effect {none,typing,arrive,cascade}
                        Effect of the letters.
  --side-margin SIDE_MARGIN
                        Margin of the text from the side of the video. It is expressed as a ratio of the width of the image.
  --bottom-margin BOTTOM_MARGIN
                        Margin of the text from the bottom of the video. It is expressed as a ratio of the height of the image.

```

### Original video

![demo_org](https://raw.githubusercontent.com/neka-nat/stenocaptioner/master/assets/demo_org.gif)

### Basic Result

![result_basic](https://raw.githubusercontent.com/neka-nat/stenocaptioner/master/assets/result_basic.gif)

### Background color

```sh
stenocaptioner https://www.youtube.com/watch?v=ldybnuFxdiQ --language ja --background-color blue
```

![result_bg_color_blue](https://raw.githubusercontent.com/neka-nat/stenocaptioner/master/assets/result_bg_color_blue.gif)

### Contour

```sh
stenocaptioner https://www.youtube.com/watch?v=ldybnuFxdiQ --language ja --contour-color black
```

![result_contour](https://raw.githubusercontent.com/neka-nat/stenocaptioner/master/assets/result_contour.gif)

### Font

Download https://fontfree.me/3132.

```sh
stenocaptioner https://www.youtube.com/watch?v=ldybnuFxdiQ --language ja --font ./gomarice_mukasi_mukasi.ttf
```

![result_font](https://raw.githubusercontent.com/neka-nat/stenocaptioner/master/assets/result_font.gif)

### Effect (typing)

```sh
stenocaptioner https://www.youtube.com/watch?v=ldybnuFxdiQ --language ja --letter-effect typing
```

![result_typing](https://raw.githubusercontent.com/neka-nat/stenocaptioner/master/assets/result_typing.gif)

### Effect (arrive)

```sh
stenocaptioner https://www.youtube.com/watch?v=ldybnuFxdiQ --language ja --letter-effect arrive
```

![result_arrive](https://raw.githubusercontent.com/neka-nat/stenocaptioner/master/assets/result_arrive.gif)

### Effect (cascade)

```sh
stenocaptioner https://www.youtube.com/watch?v=ldybnuFxdiQ --language ja --letter-effect cascade
```

![result_cascade](https://raw.githubusercontent.com/neka-nat/stenocaptioner/master/assets/result_cascade.gif)

