Skip to content
Snippets Groups Projects
Name Last commit Last update
README.md
server.go

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

  1. Google Cloud SDK: Install the Google Cloud SDK. Follow the instructions here.

  2. Google Cloud Project: Create a Google Cloud project and enable the Video Intelligence API.

  3. Authentication: You have two options for authentication: using a service account or using gcloud auth login.

Authentication Methods

Option 1: Using Service Account Key

  1. 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.
  2. 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"

Option 2: Using gcloud auth login

  1. 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.
  2. 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

  3. 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

  1. Install Go:

    go version
  2. 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
  3. 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
  4. Update Configuration:

    • Modify the bucketName, objectName, and filePath variables in the code to match your Google Cloud Storage bucket name, desired object name, and the path to your local video file.
  5. 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:

  1. Install Postman:

  2. Create a New Request:

    • Open Postman and create a new HTTP request.
  3. 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".
  4. 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:

  1. Open the Video File: Open your video file in the video player.

  2. 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 or Track.

  3. Select the SRT File: Navigate to the location where your SRT files are saved and select the desired SRT file.

  4. 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.