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 recipe for 0074 Multiple Language Captions. #197

Merged
merged 6 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions docs/recipes/0074-multiple-language-captions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Using Caption and Subtitle Files in Multiple Languages with Video Content
| | **Cookbook URLs** |
|--------------|-------------------|
| **Recipe:** | [https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/](https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/) |
| **JSON-LD:** | [https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/manifest.json](https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/manifest.json) |

### Method 1 - Construct Supplementing Annotation Using the `make_annotation` helper and a dictionary of the `body` properties
```python
--8<-- "docs/recipes/scripts/0074-multiple-language-captions-method1.py"
```
79 changes: 79 additions & 0 deletions docs/recipes/scripts/0074-multiple-language-captions-method1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from iiif_prezi3 import Manifest, ResourceItem, AnnotationPage, Annotation

manifest = Manifest(
id="https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/manifest.json",
label={"it": ["Per voi signore. Modelli francesi"]},
rights="http://rightsstatements.org/vocab/InC/1.0/",
requiredStatement={
"label": {
"en": [
"Rights"
]
},
"value": {
"en": [
"All rights reserved Cinecittà Luce spa"
]
}
}
)
manifest.add_label(
language="en",
value="For ladies. French models"
)
canvas = manifest.make_canvas(id="https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/canvas")
painting_anno_body = ResourceItem(
id="https://fixtures.iiif.io/video/europeana/Per_voi_signore_Modelli_francesi.mp4",
type="Video",
format="video/mp4"
)
painting_anno_page = AnnotationPage(
id="https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/canvas/page"
)
painting_anno = Annotation(
id="https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/canvas/page/annotation",
motivation="painting",
body=painting_anno_body,
target=canvas.id
)
hwd = {"height": 384, "width": 288, "duration": 65.0}
italian_captions = {
"id": "https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/Per_voi_signore_Modelli_francesi_it.vtt",
"type": "Text",
"format": "text/vtt",
"label": {
"it": [
"Sottotitoli in formato WebVTT"
]
},
"language": "it"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be done using the iiif-prezi library or is it missing this level of Annotation customisation?

Copy link
Member Author

@markpbaggett markpbaggett Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glenrobson apologies. I was asleep at the wheel on this initially.

I've refactored, and I think this should all be pure iiif-prezi3 now (unless I've overlooked something).

english_captions = {
"id": "https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/Per_voi_signore_Modelli_francesi_en.vtt",
"type": "Text",
"format": "text/vtt",
"label": {
"en": [
"Captions in WebVTT format"
]
},
"language": "en"
}
painting_anno_body.set_hwd(**hwd)
canvas.set_hwd(**hwd)
painting_anno_page.add_item(painting_anno)
canvas.add_item(painting_anno_page)
captions = canvas.make_annotation(
id="https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/manifest.json/subtitles_captions-files-vtt",
motivation="supplementing",
body={
"type": "Choice",
"items": [
english_captions,
italian_captions
]
},
target="https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/canvas",
anno_page_id="https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/manifest.json/anno/page/1"
)
print(manifest.json(indent=2))