Skip to content

speak( phrase ) — Merciglobal Custom JS Function

Overview

The speak( phrase ) function is a custom JavaScript utility developed for Merciglobal Cloud ERP that leverages browser-based speech synthesis capabilities to audibly pronounce a given phrase or string.

This is especially helpful in accessibility-enhanced modules or ERP dashboards where voice notifications or auditory cues are needed.


Syntax

speak("Hello, welcome to Merciglobal Cloud ERP!");

How It Works

  • Uses the Web Speech API’s SpeechSynthesis interface.
  • Takes a single string argument (phrase).
  • Converts text to speech using the browser’s default voice.

Function Definition

function speak(phrase) {
  if ('speechSynthesis' in window) {
    const utterance = new SpeechSynthesisUtterance(phrase);
    window.speechSynthesis.speak(utterance);
  } else {
    console.warn("Speech synthesis not supported in this browser.");
  }
}

Use Cases

  • 🎧 Voice feedback in user interfaces.
  • 🔐 Alerting users with audio when an action is completed or failed.
  • 🧑‍🦯 Accessibility support for visually impaired users.
  • 📦 Order processing updates in warehouse or logistics modules.

Example Usage in Merciglobal

// Voice notification after successful invoice generation
speak("Invoice has been generated successfully.");

// Warning alert for stock depletion
speak("Warning! Inventory stock is below threshold.");

Browser Compatibility

Browser Support
Chrome ✅ Yes
Firefox ✅ Yes
Safari ✅ Yes
Edge ✅ Yes
Internet Explorer ❌ No

ℹ️ Mobile browser support may vary.


Performance Note

  • Since speech synthesis is asynchronous, be aware it won't block other JavaScript executions.
  • Useful in non-critical UI moments.

Tips for Developers

  • Use speechSynthesis.cancel() to stop current speech if needed.
  • Customize voice, pitch, and rate for more advanced use cases:
    utterance.voice = speechSynthesis.getVoices()[0];
    utterance.pitch = 1;
    utterance.rate = 1;
    

  • 📦 Inventory Management
  • 📢 Notification System
  • 🧑‍💼 User Experience Enhancements

For any issues or enhancements, contact the Merciglobal DevOps Team or check the internal ERP integration docs.


Merciglobal Cloud ERPDriving smarter, faster business with accessible tech.