Create Unique Videos from Text Descriptions with Text2video

In the rapidly evolving world of content creation, the ability to generate engaging videos from text descriptions is revolutionizing how we tell stories and convey information. The Text2video service provides developers with powerful Cognitive Actions that allow for the synthesis of bizarre and creative videos based solely on textual input. This innovative approach not only simplifies the video creation process but also enhances creativity by transforming written narratives into visual experiences in near real-time.
Imagine a scenario where a writer can turn their poetic verses or imaginative stories into visually captivating videos without needing extensive video editing skills. Text2video allows for a seamless conversion of text to video, making it an invaluable tool for content creators, marketers, educators, and anyone looking to engage their audience through dynamic visual storytelling.
Prerequisites
To get started with Text2video, you will need a Cognitive Actions API key and a basic understanding of how to make API calls.
Generate Bizarre Videos from Text
The "Generate Bizarre Videos from Text" action is designed to turn imaginative language descriptions into unique video content. By leveraging advanced image-to-image translation models, this action synthesizes videos frame-by-frame, optimizing pixels to create visually striking outputs.
Input Requirements
To utilize this action, you need to provide a structured input that includes:
- prompts: A concatenated string of text descriptions separated by '&'. This field is required to specify the narrative for the video.
- fast: A boolean to determine if the video generation should prioritize speed over quality (default is true).
- width: An integer specifying the width of the video in pixels (default is 640).
- height: An integer specifying the height of the video in pixels (default is 360).
- frameRate: An integer for the number of frames per second for the output video (default is 8).
- temperature: A number that controls the variability of frame-to-frame changes (default is 30, range: 0-100).
- framesPerPrompt: An integer indicating how many video frames are allocated to each prompt (default is 20).
Example Input:
{
"fast": false,
"width": 640,
"height": 360,
"prompts": "Once upon a midnight dreary, while I pondered, weak and weary&Over many a quaint and curious volume of forgotten lore&While I nodded, nearly napping, suddenly there came a tapping&As of some one gently rapping, rapping at my chamber door&“’Tis some visitor,” I muttered, “tapping at my chamber door&Only this and nothing more.”",
"frameRate": 8,
"temperature": 30,
"framesPerPrompt": 40
}
Expected Output
The outputs are a series of URLs pointing to the generated video frames and the final video file, allowing you to visualize the transformation from text to video.
Example Output:
- URLs leading to generated images and videos:
https://assets.cognitiveactions.com/invocations/59d9f0cb-ce13-4eca-a6f5-72f7585f8e54/a39a7e8e-a70f-400b-b5da-6c285eb0790e.jpghttps://assets.cognitiveactions.com/invocations/59d9f0cb-ce13-4eca-a6f5-72f7585f8e54/b9e04c0a-9f40-476b-ac67-ea0eb094d164.mp4
import requests
import json
# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"
action_id = "a7495dac-06c5-4b69-9293-cc25181a8203" # Action ID for: Generate Bizarre Videos from Text
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"fast": false,
"width": 640,
"height": 360,
"prompts": "Once upon a midnight dreary, while I pondered, weak and weary&Over many a quaint and curious volume of forgotten lore&While I nodded, nearly napping, suddenly there came a tapping&As of some one gently rapping, rapping at my chamber door&“’Tis some visitor,” I muttered, “tapping at my chamber door&Only this and nothing more.”",
"frameRate": 8,
"temperature": 30,
"framesPerPrompt": 40
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json",
# Add any other required headers for the Cognitive Actions API
}
# Prepare the request body for the hypothetical execution endpoint
request_body = {
"action_id": action_id,
"inputs": payload
}
print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json=request_body
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully. Result:")
print(json.dumps(result, indent=2))
except requests.exceptions.RequestException as e:
print(f"Error executing action {action_id}: {e}")
if e.response is not None:
print(f"Response status: {e.response.status_code}")
try:
print(f"Response body: {e.response.json()}")
except json.JSONDecodeError:
print(f"Response body (non-JSON): {e.response.text}")
print("------------------------------------------------")
Use Cases for this Specific Action
- Creative Storytelling: Authors can visualize their stories, poems, or scripts, transforming text into captivating videos that enhance reader engagement.
- Marketing and Advertising: Marketers can create unique promotional videos from product descriptions, making advertisements more dynamic and appealing.
- Education and Training: Educators can generate instructional videos from textual content, providing visual aids that enhance learning experiences.
- Social Media Content: Content creators can produce eye-catching videos for platforms like Instagram or TikTok, driving more engagement through unique visual storytelling.
Conclusion
The Text2video service empowers developers and content creators to harness the power of AI to transform text into engaging video content effortlessly. By leveraging the "Generate Bizarre Videos from Text" action, you can unlock a world of creative possibilities, whether for storytelling, marketing, or education.
As you explore the capabilities of Text2video, consider how you can incorporate this technology into your projects to enhance audience engagement and bring your ideas to life. Start creating captivating videos today!