語学学習に最適! 動画字幕に日本語訳「も」付加する
はじめに
以前書いた上記の記事で、
OpenAI Whisper を用いて、動画に字幕を表示できるようになったものの、
字幕中に知らない単語が出てきた場合、都度動画を一時停止して単語の意味を調べたりすると、
スムーズな視聴や学習の流れが中断されるという課題に直面しました。
そこで、
オリジナル言語だけでなく、母語である日本語も一緒に表示できれば、
語学学習がさらにスムーズに進むと思いました。
目的
OpenAI Whisper を用いて、動画の音声ファイルの文字起こしをし、
オリジナル言語に、Google 翻訳 で日本語訳を付加することで、
最終的な字幕ファイルを作成します。
対象読者
- 語学学習において、動画の字幕をオリジナル言語と日本語で一緒に表示し、学習効率をあげたい方
- Python Package の OpenAI Whisper や Google 翻訳を活用したい方
環境
Mac
[nix-shell:~]$ sw_vers
ProductName: macOS
ProductVersion: 26.0.1
BuildVersion: 25A362
yt-dlp 動画ダウンローダー
[nix-shell:~]$ yt-dlp --version
2025.10.22
Python
[nix-shell:~]$ python --version
Python 3.13.7
Python Package
[nix-shell:~]$ pip show openai-whisper
Name: openai-whisper
Version: 20250625
Summary: Robust Speech Recognition via Large-Scale Weak Supervision
Home-page: https://github.com/openai/whisper
Author: OpenAI
Author-email:
License: MIT
Location: /nix/store/hy55xhqfnkn4m78id6w6yqg1wi0jfnkr-python3.13-whisper-20250625/lib/python3.13/site-packages
Requires: more-itertools, numba, numpy, tiktoken, torch, tqdm
Required-by:
[nix-shell:~]$ pip show googletrans
Name: googletrans
Version: 4.0.2
Summary: An unofficial Google Translate API for Python
Home-page: https://github.com/ssut/py-googletrans
Author:
Author-email: Suhun Han <suhunhankr@gmail.com>
License:
Location: /nix/store/r9vdqw3ls64g9dnm103lpzc7pyp6pggx-python3.13-googletrans-4.0.2/lib/python3.13/site-packages
Requires: httpx
Required-by:
VLC Media Player 動画プレーヤー
[nix-shell:~]$ vlc --version
VLC media player 3.0.21 Vetinari (revision 3.0.21-0-gdd8bfdbabe)
作成したシェルスクリプトと内部で呼び出す Python スクリプト
git clone し、
./dualsubgen 動画URL
で実行します。
実例
本記事では、以下の YouTube 動画
URL: https://youtu.be/OYSinG2DxN4?si=LNx12XFqwSGDWdbP
を使用して、
オリジナル言語(英語)と日本語が併記された字幕ファイルを作成します。
実行手順
一時ディレクトリを作成します。
[nix-shell:~]$ cd /tmp
[nix-shell:/tmp]$ mkdir English
[nix-shell:/tmp]$ cd English/
スクリプト
./dualsubgen.sh https://youtu.be/OYSinG2DxN4?si=LNx12XFqwSGDWdbP
を実行します。
実行結果中に yt-dlp に関連するいくつかの WARNING が表示されますが、
字幕ファイルの作成に影響はありませんので、そのまま進めて大丈夫です。
[nix-shell:/tmp/English]$ ~/bin/dualsubgen/dualsubgen.sh https://youtu.be/OYSinG2DxN4?si=LNx12XFqwSGDWdbP
WARNING: [youtube] OYSinG2DxN4: Some tv client https formats have been skipped as they are missing a url. YouTube may have enabled the SABR-only or Server-Side Ad Placement experiment for the current session. See https://github.com/yt-dlp/yt-dlp/issues/12482 for more details
WARNING: [youtube] OYSinG2DxN4: Some web_safari client https formats have been skipped as they are missing a url. YouTube is forcing SABR streaming for this client. See https://github.com/yt-dlp/yt-dlp/issues/12482 for more details
WARNING: [youtube] OYSinG2DxN4: Some web client https formats have been skipped as they are missing a url. YouTube is forcing SABR streaming for this client. See https://github.com/yt-dlp/yt-dlp/issues/12482 for more details
Dharma & Greg 1x22 - "Much Ado During Nothing"/Dharma & Greg 1x22 - "Much Ado During Nothing".mp4
[youtube] Extracting URL: https://youtu.be/OYSinG2DxN4?si=LNx12XFqwSGDWdbP
[youtube] OYSinG2DxN4: Downloading webpage
[youtube] OYSinG2DxN4: Downloading android sdkless player API JSON
[youtube] OYSinG2DxN4: Downloading tv client config
[youtube] OYSinG2DxN4: Downloading tv player API JSON
[youtube] OYSinG2DxN4: Downloading web safari player API JSON
[youtube] OYSinG2DxN4: Downloading player 6e4dbefe-main
WARNING: [youtube] OYSinG2DxN4: Signature extraction failed: Some formats may be missing
player = https://www.youtube.com/s/player/6e4dbefe/player_ias.vflset/en_US/base.js
Please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
WARNING: [youtube] OYSinG2DxN4: Some web_safari client https formats have been skipped as they are missing a url. YouTube is forcing SABR streaming for this client. See https://github.com/yt-dlp/yt-dlp/issues/12482 for more details
WARNING: [youtube] OYSinG2DxN4: Some web client https formats have been skipped as they are missing a url. YouTube is forcing SABR streaming for this client. See https://github.com/yt-dlp/yt-dlp/issues/12482 for more details
[youtube] OYSinG2DxN4: Downloading m3u8 information
[info] OYSinG2DxN4: Downloading 1 format(s): 95
[download] Sleeping 4.00 seconds as required by the site...
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 240
[download] Destination: Dharma & Greg 1x22 - "Much Ado During Nothing"/Dharma & Greg 1x22 - "Much Ado During Nothing".mp4
[download] 100% of 190.69MiB in 00:01:23 at 2.27MiB/s
[FixupM3u8] Fixing MPEG-TS in MP4 container of "Dharma & Greg 1x22 - "Much Ado During Nothing"/Dharma & Greg 1x22 - "Much Ado During Nothing".mp4"
extract the audio mp3 file to generate srt file!
[youtube] Extracting URL: https://youtu.be/OYSinG2DxN4?si=LNx12XFqwSGDWdbP
[youtube] OYSinG2DxN4: Downloading webpage
[youtube] OYSinG2DxN4: Downloading android sdkless player API JSON
[youtube] OYSinG2DxN4: Downloading tv client config
[youtube] OYSinG2DxN4: Downloading tv player API JSON
[youtube] OYSinG2DxN4: Downloading web safari player API JSON
[youtube] OYSinG2DxN4: Downloading player 6e4dbefe-main
WARNING: [youtube] OYSinG2DxN4: Signature extraction failed: Some formats may be missing
player = https://www.youtube.com/s/player/6e4dbefe/player_ias.vflset/en_US/base.js
Please report this issue on https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using yt-dlp -U
WARNING: [youtube] OYSinG2DxN4: Some web_safari client https formats have been skipped as they are missing a url. YouTube is forcing SABR streaming for this client. See https://github.com/yt-dlp/yt-dlp/issues/12482 for more details
WARNING: [youtube] OYSinG2DxN4: Some web client https formats have been skipped as they are missing a url. YouTube is forcing SABR streaming for this client. See https://github.com/yt-dlp/yt-dlp/issues/12482 for more details
[youtube] OYSinG2DxN4: Downloading m3u8 information
[info] OYSinG2DxN4: Downloading 1 format(s): 251
[download] Sleeping 4.00 seconds as required by the site...
[download] Destination: Dharma & Greg 1x22 - "Much Ado During Nothing"/Dharma & Greg 1x22 - "Much Ado During Nothing".webm
[download] 100% of 16.15MiB in 00:00:04 at 3.32MiB/s
[ExtractAudio] Destination: Dharma & Greg 1x22 - "Much Ado During Nothing"/Dharma & Greg 1x22 - "Much Ado During Nothing".mp3
Deleting original file Dharma & Greg 1x22 - "Much Ado During Nothing"/Dharma & Greg 1x22 - "Much Ado During Nothing".webm (pass -k to keep)
Dharma & Greg 1x22 - "Much Ado During Nothing"/Dharma & Greg 1x22 - "Much Ado During Nothing".mp3
....................................................................
Transcription done!
1
00:00:00,000 --> 00:00:02,000
I
私
2
00:00:11,759 --> 00:00:17,379
Good break wake up what fell asleep. I know you were wonderful
良い休憩、眠ったものを目覚めさせてください。あなたが素晴らしかったことは知っています
...
...
183
00:20:45,359 --> 00:20:47,359
Oh
おお
[nix-shell:/tmp/English]$
実行結果
[nix-shell:/tmp/English]$ ls -lR
.:
total 0
drwxr-xr-x 5 yama wheel 160 Oct 27 15:22 'Dharma & Greg 1x22 - "Much Ado During Nothing"'
'./Dharma & Greg 1x22 - "Much Ado During Nothing"':
total 197580
-rw-r--r-- 1 yama wheel 17037860 Oct 27 15:21 'Dharma & Greg 1x22 - "Much Ado During Nothing".mp3'
-rw-r--r-- 1 yama wheel 184723245 Oct 27 15:20 'Dharma & Greg 1x22 - "Much Ado During Nothing".mp4'
-rw-r--r-- 1 yama wheel 32319 Oct 27 15:22 'Dharma & Greg 1x22 - "Much Ado During Nothing".srt'
字幕表示の確認
ダウンロードされた動画ファイル
'Dharma & Greg 1x22 - "Much Ado During Nothing".mp4'
を VLC Media Player で再生します。
出力された字幕(SRT)ファイル
'Dharma & Greg 1x22 - "Much Ado During Nothing".srt'
中の
2
00:00:11,759 --> 00:00:17,379
Good break wake up what fell asleep. I know you were wonderful
良い休憩、眠ったものを目覚めさせてください。あなたが素晴らしかったことは知っています
のように
オリジナル言語の英語と付加した日本語訳の
両言語で、字幕表示されているのが分かると思います。
表示されない場合は、VLC のメニューから
『字幕』→『字幕トラック』
を選択して確認してみて下さい。

まとめ
OpenAI Whisper の文字起こしで、オリジナル言語を
GoogleTransで、日本語訳を付加した字幕ファイルを作成する方法を
紹介しました。
動画による字幕に日本語訳を併記することで、より捗る語学学習環境が構築できます。
ぜひ、ご自身の語学環境の一つとして、このスクリプトをご利用ください。
Discussion