Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transcript feature #93

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All changes to this project will be documented in this file.

## [1.4.4] - 2024-10-08
- Add transcript feature

## [1.4.3] - 2024-09-30
- Add /tags API endpoint

Expand Down
2 changes: 2 additions & 0 deletions docs/Model/Video.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Name | Type | Description | Notes
**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]
**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]
**discarded** | **bool** | Returns `true` for videos you discarded when you have the Video Restore feature enabled. Returns `false` for every other video. | [optional]
**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]
**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]
**tags** | **string[]** | One array of tags (each tag is a string) in order to categorize a video. Tags may include spaces. | [optional]
**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]
**source** | [**\ApiVideo\Client\Model\VideoSource**](VideoSource.md) | | [optional]
Expand Down
2 changes: 2 additions & 0 deletions docs/Model/VideoCreationPayload.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ Name | Type | Description | Notes
**metadata** | [**\ApiVideo\Client\Model\Metadata[]**](Metadata.md) | A list of key value pairs that you use to provide metadata for your video. | [optional]
**clip** | [**\ApiVideo\Client\Model\VideoClip**](VideoClip.md) | | [optional]
**watermark** | [**\ApiVideo\Client\Model\VideoWatermark**](VideoWatermark.md) | | [optional]
**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]
**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]

[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
2 changes: 2 additions & 0 deletions docs/Model/VideoUpdatePayload.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ Name | Type | Description | Notes
**mp4Support** | **bool** | Whether the player supports the mp4 format. | [optional]
**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]
**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]
**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]
**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]

[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
4 changes: 2 additions & 2 deletions src/BaseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct(string $baseUri, ?string $apiKey, ClientInterface $h
$this->originSdkHeaderValue = "";

if ($apiKey) {
$this->authenticator = new Authenticator($this, $apiKey, 'php:1.4.3');
$this->authenticator = new Authenticator($this, $apiKey, 'php:1.4.4');
}
}

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

return $this->sendRequest($request, $skipAuthRequest);
}
Expand Down
96 changes: 96 additions & 0 deletions src/Model/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public static function getDefinition(): ModelDefinition
'discardedAt' => '\DateTime',
'deletesAt' => '\DateTime',
'discarded' => 'bool',
'language' => 'string',
'languageOrigin' => 'string',
'tags' => 'string[]',
'metadata' => '\ApiVideo\Client\Model\Metadata[]',
'source' => '\ApiVideo\Client\Model\VideoSource',
Expand All @@ -59,6 +61,8 @@ public static function getDefinition(): ModelDefinition
'discardedAt' => 'date-time',
'deletesAt' => 'date-time',
'discarded' => null,
'language' => null,
'languageOrigin' => null,
'tags' => null,
'metadata' => null,
'source' => null,
Expand All @@ -78,6 +82,8 @@ public static function getDefinition(): ModelDefinition
'discardedAt' => 'discardedAt',
'deletesAt' => 'deletesAt',
'discarded' => 'discarded',
'language' => 'language',
'languageOrigin' => 'languageOrigin',
'tags' => 'tags',
'metadata' => 'metadata',
'source' => 'source',
Expand All @@ -97,6 +103,8 @@ public static function getDefinition(): ModelDefinition
'discardedAt' => 'setDiscardedAt',
'deletesAt' => 'setDeletesAt',
'discarded' => 'setDiscarded',
'language' => 'setLanguage',
'languageOrigin' => 'setLanguageOrigin',
'tags' => 'setTags',
'metadata' => 'setMetadata',
'source' => 'setSource',
Expand All @@ -116,6 +124,8 @@ public static function getDefinition(): ModelDefinition
'discardedAt' => 'getDiscardedAt',
'deletesAt' => 'getDeletesAt',
'discarded' => 'getDiscarded',
'language' => 'getLanguage',
'languageOrigin' => 'getLanguageOrigin',
'tags' => 'getTags',
'metadata' => 'getMetadata',
'source' => 'getSource',
Expand All @@ -135,6 +145,8 @@ public static function getDefinition(): ModelDefinition
'discardedAt' => null,
'deletesAt' => null,
'discarded' => null,
'language' => null,
'languageOrigin' => null,
'tags' => null,
'metadata' => null,
'source' => null,
Expand All @@ -148,6 +160,21 @@ public static function getDefinition(): ModelDefinition
);
}

const LANGUAGE_ORIGIN_API = 'api';
const LANGUAGE_ORIGIN_AUTO = 'auto';

/**
* Gets allowable values of the enum
*
* @return string[]
*/
public function getLanguageOriginAllowableValues()
{
return [
self::LANGUAGE_ORIGIN_API,
self::LANGUAGE_ORIGIN_AUTO,
];
}

/**
* Associative array for storing property values
Expand All @@ -173,6 +200,8 @@ public function __construct(array $data = null)
$this->container['discardedAt'] = isset($data['discardedAt']) ? new \DateTime($data['discardedAt']) : null;
$this->container['deletesAt'] = isset($data['deletesAt']) ? new \DateTime($data['deletesAt']) : null;
$this->container['discarded'] = $data['discarded'] ?? null;
$this->container['language'] = $data['language'] ?? null;
$this->container['languageOrigin'] = $data['languageOrigin'] ?? null;
$this->container['tags'] = $data['tags'] ?? null;
$this->container['metadata'] = isset($data['metadata']) ? array_map(function(array $value): Metadata { return new Metadata($value); }, $data['metadata']) : null;
$this->container['source'] = isset($data['source']) ? new VideoSource($data['source']) : null;
Expand All @@ -195,6 +224,15 @@ public function listInvalidProperties()
if ($this->container['videoId'] === null) {
$invalidProperties[] = "'videoId' can't be null";
}
$allowedValues = $this->getLanguageOriginAllowableValues();
if (!is_null($this->container['languageOrigin']) && !in_array($this->container['languageOrigin'], $allowedValues, true)) {
$invalidProperties[] = sprintf(
"invalid value '%s' for 'languageOrigin', must be one of '%s'",
$this->container['languageOrigin'],
implode("', '", $allowedValues)
);
}

return $invalidProperties;
}

Expand Down Expand Up @@ -426,6 +464,64 @@ public function setDiscarded($discarded)
return $this;
}

/**
* Gets language
*
* @return string|null
*/
public function getLanguage()
{
return $this->container['language'];
}

/**
* Sets language
*
* @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.
*
* @return self
*/
public function setLanguage($language)
{
$this->container['language'] = $language;

return $this;
}

/**
* Gets languageOrigin
*
* @return string|null
*/
public function getLanguageOrigin()
{
return $this->container['languageOrigin'];
}

/**
* Sets languageOrigin
*
* @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.
*
* @return self
*/
public function setLanguageOrigin($languageOrigin)
{
$allowedValues = $this->getLanguageOriginAllowableValues();
if (!is_null($languageOrigin) && !in_array($languageOrigin, $allowedValues, true)) {
throw new \InvalidArgumentException(
sprintf(
"Invalid value '%s' for 'languageOrigin', must be one of '%s'",
$languageOrigin,
implode("', '", $allowedValues)
)
);
}
$this->container['languageOrigin'] = $languageOrigin;

return $this;
}

/**
* Gets tags
*
Expand Down
Loading
Loading