Skip to content
Permalink
196c1205be
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
23 lines (20 sloc) 885 Bytes
#!/usr/bin/python3
import socket
import win32com.client as wincl
client = socket.socket() # Connect to IP:Port
port = 12346
client.connect(('localhost', port))
try:
while True:
msg = input('>') # User inputs a message
client.send( msg.encode('utf-8') ) # Encode the messsage in bits and send it to server
rawmsg = client.recv(1024) # recieve up to 1024 bytes
msg = rawmsg.decode('utf-8').rstrip('\r\n') # Decode received message from bits to string
print(msg) # convert and clean the input
speak = wincl.Dispatch("SAPI.SpVoice")
msg = msg.replace('m/s','meters per second') # So speach reads m/s correctly
speak.Speak(msg)
except KeyboardInterrupt:
print('Shutdown')
client.shutdown(1)
client.close()