Arcade Voyage: Language, Voice, and Multimodal Processing | GSP154

Solution for Arcade Voyage: Language, Voice, and Multimodal Processing | GSP154. 1 lab: GSP154. Fast copy-paste commands for Google Cloud.

GSP154 — Video Intelligence: Qwik Start

Estimated time: 10 minutes

# 🚀 Video Intelligence: Qwik Start | GSP154 > ⚠️ **Disclaimer:** This is an independent, community-made walkthrough created for educational purposes, hands-on practice, and Google Cloud certification preparation. This guide is designed to help learners understand the Google Cloud Video Intelligence API, service account authentication, video annotation, and metadata extraction through practical exercises. Always attempt the lab yourself first and follow Google Cloud Skills Boost / Qwiklabs Term

clear
CYAN='\033[0;96m'
BOLD='\033[1m'
RESET='\033[0m'
echo "${CYAN}${BOLD}"
echo "    ____        _    _ _            __  ___             "
echo "   / __ \      | |  (_) |          / _| / _ \             "
echo "  | |  | |_ __ | |__  _| |_  ___   | |_ | | | |_ __ ___  "
echo "  | |  | | '__| '_ \| | __| / _ \  |  _|| | | | '_ \ / __| "
echo "  | |__| | |  | |_) | | |_ | (_) | | |  | |_| | |_) \__ \ "
echo "   \____/|_|  |_.__/|_|\__| \___/  |_|   \___/| .__/|___/ "
echo "                                              | |         "
echo "                                              |_|         "
echo "${RESET}"

echo "▶ Setting up authorization..."
export PROJECT_ID=$(gcloud config get-value project)

echo "▶ Creating service account 'quickstart'..."
gcloud iam service-accounts create quickstart

echo "▶ Generating service account key..."
gcloud iam service-accounts keys create key.json \
    --iam-account quickstart@${PROJECT_ID}.iam.gserviceaccount.com

echo "▶ Activating service account..."
gcloud auth activate-service-account --key-file key.json

echo "▶ Printing access token..."
gcloud auth print-access-token

echo "✓ Authorization setup complete."
echo "▶ Creating request.json..."
cat > request.json <<EOF
{
   "inputUri":"gs://spls/gsp154/video/train.mp4",
   "features": [
       "LABEL_DETECTION"
   ]
}
EOF

echo "▶ Sending annotate video request..."
response=$(curl -s -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    'https://videointelligence.googleapis.com/v1/videos:annotate' \
    -d @request.json)

echo "Initial Response:"
echo "$response"

echo "▶ Extracting operation name..."
operation_path=$(echo $response | jq -r '.name')

if [ "$operation_path" != "null" ] && [ -n "$operation_path" ]; then
    echo "▶ Operation Name: $operation_path"
    echo "▶ Waiting 20 seconds for API processing to progress..."
    sleep 20
    
    echo "▶ Fetching operation status..."
    curl -s -H 'Content-Type: application/json' \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        "https://videointelligence.googleapis.com/v1/${operation_path}"
    
    echo ""
    echo "✓ Video annotation request completed."
else
    echo "▶ Error: Could not extract operation name from response."
fi