The Video Intelligence API transcribes speech to text from supported video files. There are two supported models, "default" and "video."
Request Speech Transcription for a Video
REST
Send the process request
The following shows how to send a POST
request to the
videos:annotate
method.
The example uses the access token for a service account set up for the project
using the Google Cloud CLI. For instructions on installing the Google Cloud CLI,
setting up a project with a service
account, and obtaining an access token, see the
Video Intelligence quickstart.
Before using any of the request data, make the following replacements:
- INPUT_URI: a Cloud Storage bucket that contains
the file you want to annotate, including the file name. Must
start with
gs://
.
For example:"inputUri": "gs://cloud-videointelligence-demo/assistant.mp4",
- LANGUAGE_CODE: [Optional] See supported languages
- PROJECT_NUMBER: The numeric identifier for your Cloud project
HTTP method and URL:
POST https://videointelligence.googleapis.com/v1/videos:annotate
Request JSON body:
{ "inputUri": "INPUT_URI", "features": ["SPEECH_TRANSCRIPTION"], "videoContext": { "speechTranscriptionConfig": { "languageCode": "LANGUAGE_CODE", "enableAutomaticPunctuation": true, "filterProfanity": true } } }
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/operations/OPERATION_ID" }
If the request is successful, Video Intelligence returns the name
for your operation. The
above shows an example of such a response, where project-number
is the number of your project and operation-id
is the ID of the long-running operation created for the request.
Get the results
To get the results of your request, you must send a GET
, using the operation name returned from the
call to videos:annotate
, as shown in the following example.
Before using any of the request data, make the following replacements:
- OPERATION_NAME: the name of the operation as
returned by Video Intelligence API. The operation name has the format
projects/PROJECT_NUMBER/locations/LOCATION_ID/operations/OPERATION_ID
- PROJECT_NUMBER: The numeric identifier for your Cloud project
HTTP method and URL:
GET https://videointelligence.googleapis.com/v1/OPERATION_NAME
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
Download annotation results
Copy the annotation from the source to the destination bucket: (see Copy files and objects)
gsutil cp gcs_uri gs://my-bucket
Note: If the output gcs uri is provided by the user, then the annotation is stored in that gcs uri.
Go
Java
Node.js
Python
Additional languages
C#: Please follow the C# setup instructions on the client libraries page and then visit the Video Intelligence reference documentation for .NET.
PHP: Please follow the PHP setup instructions on the client libraries page and then visit the Video Intelligence reference documentation for PHP.
Ruby: Please follow the Ruby setup instructions on the client libraries page and then visit the Video Intelligence reference documentation for Ruby.