Чтение голосом текста из буфера обмена
Пример воспроизведения голосом текста из буфера обмена. Читает английским
голосовым движком.
Платформа: Windows.
Автор: Kristopher Windsor.
Создано: 2008 год.
' Speak the Clipboard! v1.0 ' (C) 2008 Innova and Kristopher Windsor #DEFINE UNICODE #INCLUDE Once "disphelper/disphelper.bi" #INCLUDE Once "windows.bi" Function clipboard () As String Dim As Zstring Ptr s_ptr Dim As HANDLE hglb Dim As String s = "" If (IsClipboardFormatAvailable(CF_TEXT) = 0) Then Return "" If OpenClipboard( NULL ) <> 0 Then hglb = GetClipboardData(cf_text) s_ptr = GlobalLock(hglb) If (s_ptr <> NULL) Then s = *s_ptr GlobalUnlock(hglb) End If CloseClipboard() End If Return s End Function Sub speak (Byref text As String) Dim myt As Wstring * 512 Dim As Integer isSpeaking Dim As HRESULT hr DISPATCH_OBJ(tts) dhInitialize(TRUE) dhToggleExceptions(FALSE) 'set this TRUE to get error codes myt = "Sapi.SpVoice" hr = dhCreateObject(@myt, NULL, @tts) If hr <> 0 Then Exit Sub myt = text dhCallMethod(tts, ".Speak(%S)", @myt) SAFE_RELEASE(tts) End Sub Dim As String c, pc Screenres 320, 240, 32 Do pc = c c = clipboard() If Len(c) And c <> pc Then speak(c) End If Sleep 1000 Loop Until Inkey = Chr(27)