pycharmers.cli.video_of_lyric module

pycharmers.cli.video_of_lyric.video_of_lyric(argv=['-M', 'html', '.', '_build'])[source]

Create a lyric Video.

Parameters
  • json (str) – Path to parameter json file.

  • --ttfontname (str) – A filename or file-like object containing a TrueType font. If the file is not found in this filename, the loader may also search in other directories, such as the fonts/ directory on Windows or /Library/Fonts/ , /System/Library/Fonts/ and ~/Library/Fonts/ on macOS.

  • --margin (int) – The margin size.

  • --mode (str) – Optional mode to use for color values.

  • --fontsize (int) – The font size.

  • --fontwidth (int) – The font width.

  • --fontheight (int) – The font height.

  • --img-size (tuple) – The image size.

  • --bgRGB (tuple) – he color of background image. (RGB)

  • --textRGB (tuple) – The color of text. (RGB)

  • --alpha-range (float) – How many seconds to set alpha to 1 (maximum).

  • --fps (float) – The video fps.

  • --span (int) – The span between lyrics.

>>> # Create a json.
>>> import numpy as np
>>> def func(word, start, end, indent='\t'*4):
...     print(f'{indent}"words": "{word}",')
...     print(f'{indent}"seconds": {[round(e,3) for e in np.linspace(start, end, len(word))]},')
>>> import json
>>> from pycharmers.utils import dumps_json
>>> with open("era-it-doo/era-it.json") as f:
...     data = json.load(f)
>>> print(dumps_json(data))
{
  "kwargs": {
    "ttfontname": "/Users/iwasakishuto/Library/Fonts/851MkPOP_002.ttf",
    "img_size": [
      360,
      640
    ],
    "fontsize": 38,
    "fontwidth": 30,
    "margin": 10,
    "bgRGB": [
      0,
      0,
      0,
      255
    ],
    "mode": "RGBA",
    "ret_position": "line"
  },
  "texts": [
    [{"words":"1日今日も、","seconds":[2.4, 2.624, 2.848, 3.072, 3.296, 3.52],"x":-1,"y":50},{"words":"こなした労働、","seconds":[4.1, 4.317, 4.533, 4.75, 4.967, 5.183, 5.4],"x":-1,"y":-1},{"words":"辛かったけど","seconds":[5.7, 5.96, 6.22, 6.48, 6.74, 7.0],"x":-1,"y":-1},{"words":"本当がんばったじゃん","seconds":[7.0, 7.222, 7.444, 7.667, 7.889, 8.111, 8.333, 8.556, 8.778, 9.0],"x":-1,"y":-1},{"words":"1日今日も、","seconds":[9.1, 9.38, 9.66, 9.94, 10.22, 10.5],"x":-1,"y":260},{"words":"いちいちどうこう、","seconds":[10.8, 10.962, 11.125, 11.288, 11.45, 11.612, 11.775, 11.938, 12.1],"x":-1,"y":-1},{"words":"いわれたけど","seconds":[12.3, 12.52, 12.74, 12.96, 13.18, 13.4],"x":-1,"y":-1},{"words":"本当にがんばったじゃん","seconds":[13.4, 13.59, 13.78, 13.97, 14.16, 14.35, 14.54, 14.73, 14.92, 15.11, 15.3],"x":-1,"y":-1}]
  ]
}

Note

When you run from the command line, execute as follows:

$ video_of_lyric dodo-era-it.json --audio dodo-era-it.mp4[.mp3]

Sample

_images/cli.video_of_lyric.gif