Using espeak text to speech in Ubuntu, and the skype4py module, this will read out the contents of chat messages recieved-created to help me when away from my PC so if i have my hands full with the younger members of my family I can decide how urgent the chat is without having to go near the computer.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 | # ----------------------------------------------------------------------------------------------------
# Python / Skype4Py example that prints out chat messages
#
# Tested with Skype4Py version 0.9.28.5 and Skype verson 3.8.0.96
import sys
import os
import time
import Skype4Py
import random
def ndsSay(ndsWords):
ndsIn = str(ndsWords)
zcmd='espeak "'+ndsIn+'"'
print zcmd
f=os.popen(zcmd)
f.close()
ndsWords=""
ndsTalk=""
zcmd=''
# ----------------------------------------------------------------------------------------------------
# Fired on attachment status change. Here used to re-attach this script to Skype in case attachment is lost. Just in
#case.
def OnAttach(status):
print 'API attachment status: ' + skype.Convert.AttachmentStatusToText(status)
if status == Skype4Py.apiAttachAvailable:
skype.Attach()
if status == Skype4Py.apiAttachSuccess:
print('***************************************')
# ----------------------------------------------------------------------------------------------------
# Fired on chat message status change.
# Statuses can be: 'UNKNOWN' 'SENDING' 'SENT' 'RECEIVED' 'READ'
def OnMessageStatus(Message, Status):
if Status == 'RECEIVED':
print(Message.FromDisplayName + ': ' + Message.Body)
ndsSay(Message.FromDisplayName)
ndsSay(Message.Body)
if Status == 'READ':
ndsMonkey = "todo"
print(Message.FromDisplayName + ': ' + Message.Body)
ndsSay(Message.FromDisplayName)
ndsSay(Message.Body)
if Status == 'SENT':
print('Myself ' + Message.Body)
# ----------------------------------------------------------------------------------------------------
# Creating instance of Skype object, assigning handler functions and attaching to Skype.
skype = Skype4Py.Skype()
skype.OnAttachmentStatus = OnAttach
skype.OnMessageStatus = OnMessageStatus
print('***************************************')
print 'Connecting to Skype..'
skype.Attach()
# ----------------------------------------------------------------------------------------------------
# Looping until user types 'exit'
Cmd = ''
while not Cmd == 'exit':
Cmd = raw_input('')
|
Sign in to comment