This is a simple command-line tool that automates the process of generating subtitle files in SRT format. It uses Google's Speech-to-Text API to transcribe the audio from a given video file and then creates an SRT file with the transcribed text.
- Go 1.21 or higher
- FFmpeg installed and available in your PATH
- Google Cloud credentials set up for Speech-to-Text API
-
Go to the Google Cloud Console.
-
Create a new project or select an existing one.
-
Navigate to "APIs & Services" > "Credentials".
-
Create a new service account and download the JSON key file.
-
Set the
GOOGLE_APPLICATION_CREDENTIALS
environment variable to the path of the downloaded JSON key file:export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your-service-account-file.json"
(Add this line to your
.bashrc
or.zshrc
to make it permanent)
-
Clone the repository:
git clone https://github.com/zucchivan/subtitle-generator.git
-
Navigate to the project
cmd
directory:cd subtitle-generator/cmd
-
Install the required Go packages:
go mod download
-
Build the application:
go build -o subtitle-generator
To generate an SRT file for a video, run the following command:
./subtitle-generator -video=/path/to/your-video.mp4
This will generate an SRT file under ~/out/ with the same name as the input video file.