PHP Text to Speech using Microsoft Speech API

Submitted by: 
Visitors have accessed this post 4402 times.

Microsoft Speech API
The Speech Application Programming Interface
or SAPI is an API developed by Microsoft to
allow the use of speech recognition and speech
synthesis within Windows applications. To date,
a number of versions of the API have been released,
which have shipped either as part of a Speech SDK,
or as part of the Windows OS itself. Applications
that use SAPI include Microsoft Office, Microsoft
Agent and Microsoft Speech Server.


before you can run this file, add first


at the end of your 'php.ini' file

Xampp for Windows = (Drive Letter):\xampp\php\php.ini
Wamp (Drive Letter):\wamp\bin\apache\apache(version)\bin\php.ini ----(I'm not sure about this one because I'm using Xampp)

For Installation of COM() function:

If you get error(s), refer to this link:

Using this code, you can embed text-to-speech which you can use in registration system, attendance system and the like.

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.


1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.


What is your Operating System? If it is windows, did you configure your php.ini file like what I describe above? If you still get error(s) just visit this link

Remember, this script will run only on Microsoft Windows

Fatal error: Uncaught exception 'com_exception' with message 'Source: UnknownDescription: Unknown' in E:\Web Server\5.6\htdocs\sapi\index.php:31 Stack trace: #0 E:\Web Server\5.6\htdocs\sapi\index.php(31): com->Speak('Congratulations...') #1 {main} thrown in E:\Web Server\5.6\htdocs\sapi\index.php on line 31

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.