Shared Code

This directory contains code that is shared between the frontend and backend for the advanced speech & text translation application.

Files

types.ts

Comprehensive TypeScript interfaces and types used across the application:

  • Language: Extended language definition with speech capabilities and native names
  • Voice: Voice configuration for text-to-speech
  • TranslationRequest/Response: API communication types
  • SpeechRecognitionResult: Speech recognition result structure
  • SpeechSynthesisOptions: Text-to-speech configuration

languages.ts

Complete language definitions and utility functions:

  • SUPPORTED_LANGUAGES: Array of 60+ languages with regional support
  • Regional Grouping: Languages organized by geographic regions
  • Speech Capabilities: Indicators for speech recognition and synthesis support
  • Native Scripts: Support for Devanagari, Telugu, Tamil, Arabic, and other scripts
  • Helper Functions: Utilities for filtering and finding languages

Language Support

Regional Languages

  • Indian Languages: 12+ languages including Telugu, Marathi, Tamil, Hindi, Bengali
  • Southeast Asian: Thai, Vietnamese, Indonesian, Filipino, and more
  • European: 25+ European languages with regional variants
  • Middle Eastern: Arabic, Persian, Hebrew with proper script support
  • African: Swahili, Afrikaans, Zulu, Amharic

Speech Capabilities

  • Recognition Supported: 45+ languages with speech-to-text
  • Synthesis Supported: 55+ languages with text-to-speech
  • Native Pronunciation: Authentic accents for regional languages
  • Script Rendering: Proper display of non-Latin scripts

Important Notes

Cross-Environment Compatibility

  • Code in this directory must work in both browser and server environments
  • Do not use Deno-specific APIs here as they won't work in the browser
  • Use https://esm.sh for any imports to ensure compatibility
  • All functions are pure and side-effect free

Performance Considerations

  • Language arrays are optimized for fast lookups
  • Helper functions use efficient filtering and searching
  • Types are designed to minimize bundle size
  • Regional grouping reduces UI rendering complexity

Internationalization

  • Native names are provided in original scripts
  • Language codes follow ISO 639-1 and BCP 47 standards
  • Regional variants are properly distinguished
  • Cultural context is preserved in language definitions