I am trying to get this to just read the text when it is run instead of opening a window.
I tried using invoke Start_sapi5 and Stop_sapi5 but got errors.
Andy
; #########################################################################
; Simple Text-to-speech Demo by Siekmanski
; #########################################################################
.386
.model flat, stdcall
option casemap :none
; #########################################################################
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\ole32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\ole32.lib
include coinvoke.inc
include sapi51.inc
; #########################################################################
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
IDD_TTS equ 101
IDC_EDIT equ 1000
.data
hInstance dd 0
Spraak_Buffer db 1024 dup(0)
Tekst db 1024 dup(0)
Tekst_intro db "This is a way to implement a TTS (text to speech) program in assembly.",0
Speech SpVoice NULL
.code
start:
; #########################################################################
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke CoInitialize,NULL
invoke DialogBoxParam,hInstance,IDD_TTS,0,ADDR WndProc,0
invoke CoUninitialize
invoke ExitProcess,0
; #########################################################################
Start_sapi5 proc
invoke CoCreateInstance,addr CLSID_SpVoice,NULL,CLSCTX_ALL,addr IID_ISpVoice,addr Speech
ret
Start_sapi5 endp
; #########################################################################
Stop_sapi5 proc
RELEASE_INTERFACE Speech
ret
Stop_sapi5 endp
; #########################################################################
WndProc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
.if uMsg == WM_INITDIALOG
invoke Start_sapi5
invoke SetDlgItemText,hWin,IDC_EDIT,addr Tekst_intro
.elseif uMsg == WM_CLOSE
jmp Einde_prog
.elseif uMsg == WM_COMMAND
.if wParam == IDOK
.if( Speech )
invoke GetDlgItemText,hWin,IDC_EDIT,addr Tekst,sizeof Tekst
invoke MultiByteToWideChar,NULL,NULL,addr Tekst,-1,addr Spraak_Buffer,1024
coinvoke Speech,ISpVoice,Speak,addr Spraak_Buffer,SPF_DEFAULT,NULL
.endif
xor eax,eax
ret
.elseif wParam == IDCANCEL
Einde_prog: invoke EndDialog,hWin,0
invoke Stop_sapi5
xor eax,eax
ret
.endif
.endif
xor eax,eax
ret
WndProc endp
Hello Magnum
Text to Speech without a window.
What impressive, Siekmanski. Is it needed to redistribute anything or just compiling your source (I haven't got masm at hand he he)?
Hi avcaballero,
Text to speech is a part of Windows OS.
Siekmanski,
Thanks a lot.
Andy