-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSay_Ip_Adress.py
45 lines (34 loc) · 1.23 KB
/
Say_Ip_Adress.py
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
import sys
sys.path.append('/home/pi/.local/lib/python3.7/site-packages')
import socket
import pyttsx3
import time
engine = pyttsx3.init() # object creation
""" RATE"""
rate = engine.getProperty('rate') # getting details of current speaking rate
print(rate) # printing current voice rate
engine.setProperty('rate', 125) # setting up new voice rate
"""VOLUME"""
volume = engine.getProperty(
'volume') # getting to know current volume level (min=0 and max=1)
print(volume) # printing current volume level
engine.setProperty('volume', 1.0) # setting up volume level between 0 and 1
"""VOICE"""
voices = engine.getProperty('voices') # getting details of current voice
# engine.setProperty('voice', voices[0].id)
# changing index, changes voices. o for male
# changing index, changes voices. 1 for female
engine.setProperty('voice', voices[8].id)
# for idx, voice in enumerate(voices):
# print(idx, voice.id)
engine.say('Guten Tag.')
time.sleep(30) # wait 30s for internet connection
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
ip = s.getsockname()[0]
s.close()
print(ip)
ip = ip.replace('', ' ').replace('.', 'Punkt')
engine.say('Meine IP Adresse ist ' + ip)
engine.runAndWait()
engine.stop()