Skip to content

Commit 3d2afd3

Browse files
Merge pull request #93 from apivideo/add-transcript-feature
Add transcript feature
2 parents 940d14f + ad7c5bd commit 3d2afd3

File tree

8 files changed

+435
-14
lines changed

8 files changed

+435
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22
All changes to this project will be documented in this file.
33

4+
## [1.4.4] - 2024-10-08
5+
- Add transcript feature
6+
47
## [1.4.3] - 2024-09-30
58
- Add /tags API endpoint
69

docs/Model/Video.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Name | Type | Description | Notes
1313
**discardedAt** | [**\DateTime**](\DateTime.md) | The date and time the video was discarded. The API populates this field only if you have the Video Restore feature enabled and discard a video. Date and time are provided using ATOM UTC format. | [optional]
1414
**deletesAt** | [**\DateTime**](\DateTime.md) | The date and time the video will be permanently deleted. The API populates this field only if you have the Video Restore feature enabled and discard a video. Discarded videos are pemanently deleted after 90 days. Date and time are provided using ATOM UTC format. | [optional]
1515
**discarded** | **bool** | Returns `true` for videos you discarded when you have the Video Restore feature enabled. Returns `false` for every other video. | [optional]
16+
**language** | **string** | Returns the language of a video in [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. You can set the language during video creation via the API, otherwise it is detected automatically. | [optional]
17+
**languageOrigin** | **string** | Returns the origin of the last update on the video's `language` attribute. - `api` means that the last update was requested from the API. - `auto` means that the last update was done automatically by the API. | [optional]
1618
**tags** | **string[]** | One array of tags (each tag is a string) in order to categorize a video. Tags may include spaces. | [optional]
1719
**metadata** | [**\ApiVideo\Client\Model\Metadata[]**](Metadata.md) | Metadata you can use to categorise and filter videos. Metadata is a list of dictionaries, where each dictionary represents a key value pair for categorising a video. | [optional]
1820
**source** | [**\ApiVideo\Client\Model\VideoSource**](VideoSource.md) | | [optional]

docs/Model/VideoCreationPayload.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ Name | Type | Description | Notes
1515
**metadata** | [**\ApiVideo\Client\Model\Metadata[]**](Metadata.md) | A list of key value pairs that you use to provide metadata for your video. | [optional]
1616
**clip** | [**\ApiVideo\Client\Model\VideoClip**](VideoClip.md) | | [optional]
1717
**watermark** | [**\ApiVideo\Client\Model\VideoWatermark**](VideoWatermark.md) | | [optional]
18+
**language** | **string** | Use this parameter to set the language of the video. When this parameter is set, the API creates a transcript of the video using the language you specify. You must use the [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. `language` is a permanent attribute of the video. You can update it to another language using the [`PATCH /videos/{videoId}`](https://docs.api.video/reference/api/Videos#update-a-video-object) operation. This triggers the API to generate a new transcript using a different language. | [optional]
19+
**transcript** | **bool** | Use this parameter to enable transcription. - When `true`, the API generates a transcript for the video. - The default value is `false`. - If you define a video language using the `language` parameter, the API uses that language to transcribe the video. If you do not define a language, the API detects it based on the video. - When the API generates a transcript, it will be available as a caption for the video. | [optional]
1820

1921
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)

docs/Model/VideoUpdatePayload.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ Name | Type | Description | Notes
1212
**mp4Support** | **bool** | Whether the player supports the mp4 format. | [optional]
1313
**tags** | **string[]** | A list of terms or words you want to tag the video with. Make sure the list includes all the tags you want as whatever you send in this list will overwrite the existing list for the video. | [optional]
1414
**metadata** | [**\ApiVideo\Client\Model\Metadata[]**](Metadata.md) | A list (array) of dictionaries where each dictionary contains a key value pair that describes the video. As with tags, you must send the complete list of metadata you want as whatever you send here will overwrite the existing metadata for the video. | [optional]
15+
**language** | **string** | Use this parameter to set the language of the video. When this parameter is set, the API creates a transcript of the video using the language you specify. You must use the [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. `language` is a permanent attribute of the video. You can update it to another language using the [`PATCH /videos/{videoId}`](https://docs.api.video/reference/api/Videos#update-a-video-object) operation. This triggers the API to generate a new transcript using a different language. | [optional]
16+
**transcript** | **bool** | Use this parameter to enable transcription. - When `true`, the API generates a transcript for the video. - The default value is `false`. - If you define a video language using the `language` parameter, the API uses that language to transcribe the video. If you do not define a language, the API detects it based on the video. - When the API generates a transcript, it will be available as a caption for the video. | [optional]
1517

1618
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)

src/BaseClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function __construct(string $baseUri, ?string $apiKey, ClientInterface $h
7878
$this->originSdkHeaderValue = "";
7979

8080
if ($apiKey) {
81-
$this->authenticator = new Authenticator($this, $apiKey, 'php:1.4.3');
81+
$this->authenticator = new Authenticator($this, $apiKey, 'php:1.4.4');
8282
}
8383
}
8484

@@ -111,7 +111,7 @@ public function request(Request $commandRequest, bool $skipAuthRequest = false):
111111
if($this->originSdkHeaderValue) {
112112
$request = $request->withHeader('AV-Origin-Sdk', $this->originSdkHeaderValue);
113113
}
114-
$request = $request->withHeader('AV-Origin-Client', 'php:1.4.3');
114+
$request = $request->withHeader('AV-Origin-Client', 'php:1.4.4');
115115

116116
return $this->sendRequest($request, $skipAuthRequest);
117117
}

src/Model/Video.php

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public static function getDefinition(): ModelDefinition
4040
'discardedAt' => '\DateTime',
4141
'deletesAt' => '\DateTime',
4242
'discarded' => 'bool',
43+
'language' => 'string',
44+
'languageOrigin' => 'string',
4345
'tags' => 'string[]',
4446
'metadata' => '\ApiVideo\Client\Model\Metadata[]',
4547
'source' => '\ApiVideo\Client\Model\VideoSource',
@@ -59,6 +61,8 @@ public static function getDefinition(): ModelDefinition
5961
'discardedAt' => 'date-time',
6062
'deletesAt' => 'date-time',
6163
'discarded' => null,
64+
'language' => null,
65+
'languageOrigin' => null,
6266
'tags' => null,
6367
'metadata' => null,
6468
'source' => null,
@@ -78,6 +82,8 @@ public static function getDefinition(): ModelDefinition
7882
'discardedAt' => 'discardedAt',
7983
'deletesAt' => 'deletesAt',
8084
'discarded' => 'discarded',
85+
'language' => 'language',
86+
'languageOrigin' => 'languageOrigin',
8187
'tags' => 'tags',
8288
'metadata' => 'metadata',
8389
'source' => 'source',
@@ -97,6 +103,8 @@ public static function getDefinition(): ModelDefinition
97103
'discardedAt' => 'setDiscardedAt',
98104
'deletesAt' => 'setDeletesAt',
99105
'discarded' => 'setDiscarded',
106+
'language' => 'setLanguage',
107+
'languageOrigin' => 'setLanguageOrigin',
100108
'tags' => 'setTags',
101109
'metadata' => 'setMetadata',
102110
'source' => 'setSource',
@@ -116,6 +124,8 @@ public static function getDefinition(): ModelDefinition
116124
'discardedAt' => 'getDiscardedAt',
117125
'deletesAt' => 'getDeletesAt',
118126
'discarded' => 'getDiscarded',
127+
'language' => 'getLanguage',
128+
'languageOrigin' => 'getLanguageOrigin',
119129
'tags' => 'getTags',
120130
'metadata' => 'getMetadata',
121131
'source' => 'getSource',
@@ -135,6 +145,8 @@ public static function getDefinition(): ModelDefinition
135145
'discardedAt' => null,
136146
'deletesAt' => null,
137147
'discarded' => null,
148+
'language' => null,
149+
'languageOrigin' => null,
138150
'tags' => null,
139151
'metadata' => null,
140152
'source' => null,
@@ -148,6 +160,21 @@ public static function getDefinition(): ModelDefinition
148160
);
149161
}
150162

163+
const LANGUAGE_ORIGIN_API = 'api';
164+
const LANGUAGE_ORIGIN_AUTO = 'auto';
165+
166+
/**
167+
* Gets allowable values of the enum
168+
*
169+
* @return string[]
170+
*/
171+
public function getLanguageOriginAllowableValues()
172+
{
173+
return [
174+
self::LANGUAGE_ORIGIN_API,
175+
self::LANGUAGE_ORIGIN_AUTO,
176+
];
177+
}
151178

152179
/**
153180
* Associative array for storing property values
@@ -173,6 +200,8 @@ public function __construct(array $data = null)
173200
$this->container['discardedAt'] = isset($data['discardedAt']) ? new \DateTime($data['discardedAt']) : null;
174201
$this->container['deletesAt'] = isset($data['deletesAt']) ? new \DateTime($data['deletesAt']) : null;
175202
$this->container['discarded'] = $data['discarded'] ?? null;
203+
$this->container['language'] = $data['language'] ?? null;
204+
$this->container['languageOrigin'] = $data['languageOrigin'] ?? null;
176205
$this->container['tags'] = $data['tags'] ?? null;
177206
$this->container['metadata'] = isset($data['metadata']) ? array_map(function(array $value): Metadata { return new Metadata($value); }, $data['metadata']) : null;
178207
$this->container['source'] = isset($data['source']) ? new VideoSource($data['source']) : null;
@@ -195,6 +224,15 @@ public function listInvalidProperties()
195224
if ($this->container['videoId'] === null) {
196225
$invalidProperties[] = "'videoId' can't be null";
197226
}
227+
$allowedValues = $this->getLanguageOriginAllowableValues();
228+
if (!is_null($this->container['languageOrigin']) && !in_array($this->container['languageOrigin'], $allowedValues, true)) {
229+
$invalidProperties[] = sprintf(
230+
"invalid value '%s' for 'languageOrigin', must be one of '%s'",
231+
$this->container['languageOrigin'],
232+
implode("', '", $allowedValues)
233+
);
234+
}
235+
198236
return $invalidProperties;
199237
}
200238

@@ -426,6 +464,64 @@ public function setDiscarded($discarded)
426464
return $this;
427465
}
428466

467+
/**
468+
* Gets language
469+
*
470+
* @return string|null
471+
*/
472+
public function getLanguage()
473+
{
474+
return $this->container['language'];
475+
}
476+
477+
/**
478+
* Sets language
479+
*
480+
* @param string|null $language Returns the language of a video in [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format. You can set the language during video creation via the API, otherwise it is detected automatically.
481+
*
482+
* @return self
483+
*/
484+
public function setLanguage($language)
485+
{
486+
$this->container['language'] = $language;
487+
488+
return $this;
489+
}
490+
491+
/**
492+
* Gets languageOrigin
493+
*
494+
* @return string|null
495+
*/
496+
public function getLanguageOrigin()
497+
{
498+
return $this->container['languageOrigin'];
499+
}
500+
501+
/**
502+
* Sets languageOrigin
503+
*
504+
* @param string|null $languageOrigin Returns the origin of the last update on the video's `language` attribute. - `api` means that the last update was requested from the API. - `auto` means that the last update was done automatically by the API.
505+
*
506+
* @return self
507+
*/
508+
public function setLanguageOrigin($languageOrigin)
509+
{
510+
$allowedValues = $this->getLanguageOriginAllowableValues();
511+
if (!is_null($languageOrigin) && !in_array($languageOrigin, $allowedValues, true)) {
512+
throw new \InvalidArgumentException(
513+
sprintf(
514+
"Invalid value '%s' for 'languageOrigin', must be one of '%s'",
515+
$languageOrigin,
516+
implode("', '", $allowedValues)
517+
)
518+
);
519+
}
520+
$this->container['languageOrigin'] = $languageOrigin;
521+
522+
return $this;
523+
}
524+
429525
/**
430526
* Gets tags
431527
*

0 commit comments

Comments
 (0)