Skip to content
Snippets Groups Projects
S Gopi's avatar
S GOPI authored
ef473d1a
History
Name Last commit Last update
README.md
server.go

Video Transcription in Multiple Languages with Google Cloud

This README provides instructions for configuring and running the Go program 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.

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.

Installing and Running the Program

  1. Install Go:

    go version
  2. 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
  3. 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.
  4. Run the Program:

    • Execute the Go program:
    go run main.go

Output

  • The 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 language code (e.g., output_language_code.srt).

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 or Go documentation.