How dushyant60/video_avatar works
Project Type and Purpose
• This is a single-page ReactJS application that integrates Azure Cognitive Services’ Text-to-Speech Avatar feature (and Azure OpenAI) to render lifelike talking avatars in the browser. There is no custom backend—the app calls out directly to Azure services and an optional Coturn TURN server for WebRTC.
File-Structure Analysis
• Top-level “FrontEnd” directory contains a standard ReactJS project with:
• public/ – static HTML+assets
• src/ – React components, CSS, and utility modules
• src/components – UI pieces (Avatar, HomePage, MessageDrawer, VideoPicker, etc.)
• src/utility – core integration logic (Utility.js, conversationLogger.js, insightsGenerator.js, sessionutils.js, worker.js)
• Configuration files (.env via config.js, iceservers.txt for TURN servers)
• Dockerfile for containerizing the front end
• No backend folder—external Azure and TURN services provide all server-side functionality.
README Insights
• The app must be configured with environment variables for:
• Azure Cognitive Services (region, subscription key, voice/character/style)
• Azure OpenAI endpoint/key
• A script (installCoturn.sh) can set up your own TURN server to replace the retiring Azure TURN service.
Main Components
a. Client Browser (React App)
– UI Components: HomePage, UserInfoForm, VideoPicker, MessageDrawer, ScreenshotDrawer, Video_Res
– Utility Modules: conversationLogger (logs chat), insightsGenerator (post-analysis), worker.js (background tasks), sessionutils (state management)
b. Azure Cloud Services
– Azure OpenAI (text generation)
– Azure Cognitive Services Text-to-Speech Avatar (speech + animation)
c. TURN Server
– For WebRTC signaling/ICE traversal (either Azure TURN or your Coturn instance)
d. External Storage/Logging (optional)
Component Interactions and Data Flows
1. User enters text or message in the React UI
2. conversationLogger records the input; insightsGenerator may prepare analytics
3. React Utility calls Azure OpenAI endpoint → receives generated text response
4. Utility then calls Azure TTS Avatar API with text + avatar parameters → receives audio stream + animation instructions
5. React app’s worker thread may process the media, then routes the combined audio/video stream into the Video_Res component
6. WebRTC connection (if using real-time avatar) uses ICE servers from iceservers.txt or .env → TURN server for NAT traversal
7. UI displays the avatar talking; ScreenshotDrawer/MessageDrawer let you capture and review sessions
Architectural Patterns and Design Principles
• Single-page application with clear separation between:
• Presentation layer (React components in src/components)
• Integration layer (src/utility modules that orchestrate API calls)
• Background processing (Web Worker in src/utility/worker.js)
• External services are treated as microservices; the app has no own backend
• Use of environment-based configuration for credentials and region settings