movis.contrib.voicevox.make_timeline_from_voicevox#
- movis.contrib.voicevox.make_timeline_from_voicevox(audio_dir: str | PathLike, max_text_length: int = 25, extra_columns: tuple[tuple[str, Hashable], ...] = (('slide', 0), ('status', 'n'))) DataFrame [source]#
Create a
pandas.DataFrame
based on text files generated by Voicevox.This function reads
.txt
files from a directory generated by Voicevox and constructs aDataFrame
. Each row of theDataFrame
corresponds to a text file and includes columns such as'character'
,'hash'
, and'text'
, as well as any additional columns specified inextra_columns
.- Args:
- audio_dir:
The directory containing
.txt
files generated by Voicevox.- max_text_length:
The maximum length of text for each entry in the
'text'
column. Strings longer thanmax_text_length
are automatically line-breaked for subtitling convenience. Defaults to 25.- extra_columns:
Additional columns to be added to the DataFrame. Each inner tuple should contain a column name and a default value. Defaults to
(("slide", 0), ("status", "n"))
. For example,extra_columns=(("slide", 0), ("status", "n"))
will add two columns named'slide'
and'status'
with default values0
and'n'
, respectively.
Note
The
'character'
column is automatically added to the DataFrame based on the filename. For example, if the filename is'001_ずんだもん(ノーマル).txt'
, the'character'
column will be set to'zunda'
.Note
The
'hash'
column is automatically added to the DataFrame based on the content of the text file. This is used inmerget_timeline
to detect changes in the text file.- Returns:
A DataFrame with columns that may include ‘character’, ‘hash’, ‘text’, and any additional columns.
character
: The identifier for the Voicevox character.hash
: A hash prefix based on the content of the text file.text
: The text content, potentially divided into multiple parts if it exceedsmax_text_length
.Any additional columns specified in
extra_columns
.
- Examples:
>>> from movis.contrib.voicevox import make_timeline_from_voicevox >>> make_timeline_from_voicevox('audio') character hash text slide status 0 zunda 9bc5d6 こんにちは!このサンプルでは、簡単なずんだもん動画\nを作ります。 0 n 1 metan ca647c このような形で対談を行うのが解説動画の特徴です。 0 n 2 zunda 75d695 先生役と生徒役で対談することで、内容をわかりやすく\n視聴者に伝えられます。 0 n 3 metan 4d880b また疑問を生徒側が投げかけることで、より深い解説を\nスムーズに 0 n 4 metan e9e4f0 伝えられるのも利点と言えるでしょう。 0 n 5 zunda 702873 欠点としては、現状のところ深い内容を解説する動画に\nは作られていないことです。 0 n 6 zunda 4a1a86 手間がかかることが理由の一つかもしれませんが、この\nようなライブラリを通して 0 n 7 zunda cb26fc より多くのユーザー層へ、専門的な知識を伝えられるこ\nとを期待しています。 0 n