codevideo-virtual-author
is a TypeScript class that simulates a virtual author that can speak. This lightweight and versatile library is ideal for building educational tools, code playgrounds, and interactive coding environments within web applications.
This library heavily relies on the types from codevideo-types
import { VirtualAuthor } from '@fullstackcraftllc/codevideo-virtual-author';
// Initialize a VirtualAuthor instance with initial existing command history
const virtualAuthor = new VirtualAuthor();
// Apply speak action to the virtual author
virtualAuthor.applyActions([
{ name: 'speak-before', value: "Hi! I'm Chris, virtual CodeVideo author!" }
]);
// Use the virtual author object
const actionsApplied = virtualAuthor.getActionsApplied();
const currentSpeechCaption = virtualAuthor.getCurrentSpeechCaption();
// Log the final code and actions applied
console.log('Actions applied:');
console.log(actionsApplied);
console.log('Current speech caption:');
console.log(currentSpeechCaption); // "Hi! I'm Chris, virtual CodeVideo author!"
Apply a single action to the code.
Apply a series of actions to the virtual author.
Get the actions applied to the virtual author.
Get the current speech caption of the virtual author. Returns an empty string if no speech caption is set.
Why do we need a seemingly useless class? This library, along with codevideo-virtual-code-block
create the backbone of codevideo-virtual-code-editor
which are used to validate steps across the CodeVideo ecosystem. This is a small part of a larger project to create a declarative way to build, edit, and generate step by step educational video software courses.
See more at codevideo.io