Mini Project Server
This README provides instructions for configuring and running the this program (server) that uploads a video file to Google Cloud Storage, transcribes it into multiple languages using the Google Cloud Video Intelligence API, and saves the transcriptions as SRT files. Additionally, you can use a client application or Postman to interact with the server.
Prerequisites
-
Google Cloud SDK: Install the Google Cloud SDK. Follow the instructions here.
-
Google Cloud Project: Create a Google Cloud project and enable the Video Intelligence API.
-
Authentication: You have two options for authentication: using a service account or using
gcloud auth login
.
Authentication Methods
Option 1: Using Service Account Key
-
Create a Service Account:
- Go to the Service Accounts page.
- Create a new service account and grant it the "Storage Object Admin" and "Video Intelligence API Admin" roles.
- Generate a key in JSON format and download it to your local machine.
-
Set the Environment Variable:
- Set the
GOOGLE_APPLICATION_CREDENTIALS
environment variable to the path of the JSON key file you downloaded.
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account-file.json"
- Set the
gcloud auth login
Option 2: Using -
Authenticate Using
gcloud
:- Run the following command to authenticate with your Google account:
gcloud auth login
- This command will open a web browser where you can log in to your Google account.
-
Set the Project ID:
- Ensure you have set the correct Google Cloud project ID:
gcloud config set project YOUR_PROJECT_ID
Note: Using
gcloud auth login
will authenticate using your Google user account credentials, and your user account must have the necessary permissions for accessing Google Cloud Storage and Video Intelligence API.If you have found any authentication errors while processing the Video. Follow the 3rd Step
-
Set up Application Default Credentials:
- Install and initialize the gcloud CLI. When you initialize the gcloud CLI, be sure to specify a Google Cloud project in which you have permission to access the resources your application needs.
- Configure ADC:
gcloud auth application-default login
A sign-in screen appears. After you sign in, your credentials are stored in the local credential file used by ADC. For Additional help, Refer here.
Installing and Running the Server Program
-
Install Go:
- Download and install Go from the official Go website.
- Verify the installation by running:
go version
-
Clone the Server Repository:
- Clone the server repository:
git clone https://git.selfmade.ninja/skopeemail/mini-project-server
- Navigate to the server directory:
cd server
-
Install Go Dependencies:
- Initialize your Go module if you haven't already:
go mod init your-module-name
- Install the required packages as listed in your
go.mod
file:
go get cloud.google.com/go/storage go get cloud.google.com/go/videointelligence go get google.golang.org/genproto go get google.golang.org/grpc go get google.golang.org/protobuf
-
Update Configuration:
- Modify the
bucketName
,objectName
, andfilePath
variables in the code to match your Google Cloud Storage bucket name, desired object name, and the path to your local video file.
- Modify the
-
Run the Program:
- Execute the Go program:
go run server.go
Client Repository
To interact with the server, you can use a client application. You can find the client repository here.
Alternative: Using Postman
Alternatively, you can use Postman to interact with the server:
-
Install Postman:
- Download and install Postman from the official Postman website.
-
Create a New Request:
- Open Postman and create a new HTTP request.
-
Set the Request Details:
- Set the request method to POST.
- Enter the server URL (e.g.,
http://localhost:8080/upload
) in the request URL field. - In the "Body" tab, select "form-data" and add a key for the video file with type "File".
-
Send the Request:
- Click the "Send" button to upload the video file and process the transcription.
Adding SRT Files to Video Player
After the SRT files are successfully generated, you can add them to a video player to view the transcriptions. Here are the general steps:
-
Open the Video File: Open your video file in the video player.
-
Add SRT Subtitles: Use the video player’s option to add subtitle files. This option is usually found in the menu under something like
Subtitle
orTrack
. -
Select the SRT File: Navigate to the location where your SRT files are saved and select the desired SRT file.
-
Enable Subtitles: Ensure that subtitles are enabled in the video player settings.
Output
The server program will upload the video file to Google Cloud Storage, transcribe it in the specified languages, and save the transcriptions as SRT files. Each SRT file will be named according to the video file name (e.g., video_file_name.srt
). The client application or Postman will allow you to interact with the server, upload videos, and view transcriptions.You need to use an Video Player to see the outputs as well in the video. You can use any video player for it or use this player here.
Troubleshooting
- Permissions Issues: Ensure that your Google account or service account has the necessary permissions for both Google Cloud Storage and Video Intelligence API.
- File Path Issues: Verify that the local file path provided is correct and accessible.
-
Authentication Issues: Ensure that you have correctly authenticated using either the service account key or
gcloud auth login
.
For additional help, refer to the Google Cloud documentation, Go documentation, Postman documentation, and your video player's documentation.