BlitzSpeech v1.0 - Windows Text-to-Speech Library
Download: BlitzSpeech (https://www.syntaxboom.com/forum/dabzy/BlitzSpeech_1_0.zip)
About:
BlitzSpeech is a powerful, easy-to-use Windows Text-to-Speech (TTS) library that wraps Microsoft's Speech API (SAPI 5.3+) in a simple DLL. BlitzSpeech works seamlessly with Blitz3D, BlitzMax-NG, and Visual Studio C++, but not limited too. If you use a language that can import functions from DLL's, then all you need is to code the bridge.
- High-Quality Speech - Natural-sounding voices using Windows SAPI 5.3+
- Multi-Language - Access all installed Windows voices in 30+ languages
- Desktop + OneCore Voices - Supports both legacy SAPI and modern Windows 10/11 voices
- SAPI XML Support - Advanced speech control with SAPI XML markup
- WAV Export - Save speech to high-quality audio files
- Async/Sync - Blocking or non-blocking speech with full playback control
- Voice Control - Adjust rate, volume, pause, resume, and stop
- Smart File Reading - Auto-detects text file encoding (ANSI, UTF-8, both UTF-16 endian types)
What's in the Download:
Core Files
BlitzSpeech.dll - Main library (32-bit or 64-bit)
BlitzSpeech.lib - Import library
For Blitz3D
BlitzSpeech.decls - Function declarations
Examples/Blitz3D/ - Sample code
For BlitzMax-NG
BlitzSpeech.bmx - Complete header with constants
Examples/BlitzMaxNG/ - Sample code
For Visual Studio C++
BlitzSpeech.h - C/C++ header with full API
Examples/VisualStudio/ - Sample project
Documentation:
There is a readme file, but for usage, check the BMX-NG examples.
Quick examples:
Blitz3D
Include "BlitzSpeechInclude.bb"
InitSpeech()
SpeakText("Hello from Blitz3D!")
CleanupSpeech()
BlitzMax-NG
Import "BlitzSpeech.bmx"
InitSpeech()
SpeakText("Hello from BlitzMax-NG!")
CleanupSpeech()
Visual Studio C++
#include "BlitzSpeech.h"
int main() {
InitSpeech();
SpeakText("Hello from C++!");
CleanupSpeech();
return 0;
}
Setup (Visual Studio): Link BlitzSpeech.lib and copy BlitzSpeech.dll to your output directory.
Core Functions:
Initialization
InitSpeech() - Initialize the speech system
CleanupSpeech() - Clean up resources
Speech Output
SpeakText(text) - Speak text (synchronous)
SpeakTextFlags(text, flags) - Speak with custom flags
SpeakFile(filepath) - Read and speak a text file
Playback Control
PauseSpeech() - Pause speech
ResumeSpeech() - Resume speech
StopSpeech() - Stop immediately
IsSpeaking() - Check if speaking
WaitUntilSpeechIsDone(timeout_ms) - Wait for completion
Voice Management
GetVoiceCount() - Get number of voices
GetVoiceName(index) - Get voice name
GetVoiceLanguage(index) - Get voice language
GetVoiceType(index) - Get type (Desktop/OneCore)
SetSpeechVoice(index) - Set voice by index
SetSpeechVoiceByName(name) - Set voice by name
GetCurrentVoice() - Get active voice
Settings
SetSpeechRate(rate) - Speed (-10 to 10)
SetSpeechVolume(volume) - Volume (0 to 100)
File Output
SpeakToFileDefault(text, filepath) - Save to WAV
SpeakToFile(text, filepath, rate, bits, channels, flags) - Custom quality WAV
Utilities
GetFileEncoding(filepath) - Detect file encoding
AboutBlitzSpeech() - Show about dialog
Supported Languages:
English (US/UK/AU/CA/IN), Spanish, French, German, Italian, Portuguese, Dutch, Russian, Polish, Chinese, Japanese, Korean, Arabic, Czech, Danish, Finnish, Greek, Hebrew, Hindi, Hungarian, Norwegian, Swedish, Thai, Turkish, and more!
(Depends on installed Windows language packs)
Requirements:
OS: Windows 7 (Not personally tested) or later (Windows 10/11 for OneCore voices)
SAPI: 5.3+ (included in Windows)
Download showcases: VSC++ 2022, Blitz3D and BlitzMax-NG only at time of release.
License:
MIT License - Copyright © 2025 Michael Denathorn
Free to use in personal and commercial projects. See LICENSE file for details.
Any issues, let me know here, otherwise...
Enjoy! :)
Dabz
This didn't work for me using the Blitz3d example. I got 'userlib function not found'.
The Dll and decals are in the Blitz3d/userlib directory. I'm on Win10 .. is it possible I don't have the SAPI?
Also, in your example above for Blitz3d, should the include not be for "BlitzSpeechInclude.bb" rather than the decls file?
Mmmmm, how odd... Because I did test it! :/
Quote from: Stevie G on Today at 09:52 AMI'm on Win10 .. is it possible I don't have the SAPI?
No, your system will have it... If you delve into the VSC++ project, in the Debug folder, you will find an executable to test it.
So, not sure what has happened with the Blitz3D thing... But I'll take a look! ;)
Dabz
I know whats wrong, I used an old DECLS file, but then doing a rejig and a tidy I changed the names of the exported functions to match the more Blitz-like affair, and thus... Bundled the old DECLS file in the download without checking! :D
Me bad... But thanks for catching that! ;)
Here is the newer DECLS file:
.lib "BlitzSpeech.dll"
InitSpeech%():"_InitSpeech@0"
SpeakText%(text$):"_SpeakText@4"
SpeakTextFlags%(text$, flags%):"_SpeakTextFlags@8"
SetSpeechRate%(rate%):"_SetSpeechRate@4"
SetSpeechVolume%(volume%):"_SetSpeechVolume@4"
PauseSpeech%():"_PauseSpeech@0"
ResumeSpeech%():"_ResumeSpeech@0"
StopSpeech%():"_StopSpeech@0"
IsSpeaking%():"_IsSpeaking@0"
WaitUntilSpeechIsDone%(timeout_ms%):"_WaitUntilSpeechIsDone@4"
SpeakFile%(filepath$):"_SpeakFile@4"
SpeakToFileDefault%(text$, filepath$):"_SpeakToFileDefault@8"
SpeakToFile%(text$, filepath$, sampleRate%, bitsPerSample%, channels%, flags%):"_SpeakToFile@24"
GetFileEncoding%(filepath$):"_GetFileEncoding@4"
GetVoiceCount%():"_GetVoiceCount@0"
GetVoiceName$(index%):"_GetVoiceName@4"
GetVoiceLanguage$(index%):"_GetVoiceLanguage@4"
GetVoiceType%(index%):"_GetVoiceType@4"
SetSpeechVoice%(index%):"_SetSpeechVoice@4"
SetSpeechVoiceByName%(name$):"_SetSpeechVoiceByName@4"
GetCurrentVoice%():"_GetCurrentVoice@0"
AboutBlitzSpeech():"_AboutBlitzSpeech@0"
CleanupSpeech():"_CleanupSpeech@0"
Oh, and thanks for mentioning that typo... I was in monkey at a keyboard mode! :P Hehehe
For anyone else, the download has been updated! :)
Dabz
Magic, I'll give it a go and report back.
Champion, fingers crossed! ;)
I knew something would crop up... Lol, way of the "programming come release it to the masses" scenerio innit! :D
Dabz
Works now BUT the speech doesn't sound good. Difficult to describe ... kinda grainy with weird artifacts.
It's maybe my system, although I've never really had sound issues with Blitz. I'm using a version with inbuilt fmod - v1.108.
Hopefully someone else with Blitz can try and confirm.
Well, the dafault one is roboty, but if you look at the BlitzMax-NG example number 4, you can see how to list and use different (More human) voices.
Also, the speech comes from your Windows default sound driver.
All in all, on my system, it sounds grand, even the default one, yes, very much Stephen Hawkings sounding, but, not bad.
Dabz
I tried it on my newer Win11 machine and sounds fine - so problem is with my Win10 machine.
For the record though - it sounds nothing like Stephen Hawking, unless he was transitioning prior to his death! ;D
Quote from: Stevie G on Today at 01:01 PMFor the record though - it sounds nothing like Stephen Hawking, unless he was transitioning prior to his death! ;D
Anar, but it was the only example I could think off! :D
Dabz