-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
56 lines (37 loc) · 976 Bytes
/
utils.py
File metadata and controls
56 lines (37 loc) · 976 Bytes
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
from gtts import gTTS #Tratamento de ádio
import os
import time
def text_in_audio(text):
'''
Converte texto em áudio, salva em audio.mp3 e reproduz esse.
'''
try:
# Converte o conteúdo de text em áudio.
tts = gTTS(text=text, lang='pt-br')
# Salva o coteúdo do áudio em audio.mp3.
tts.save('audio.mp3')
# Reproduz audio.mp3 em segundo plano.
os.system('mpg123 audio.mp3 2> /dev/null &')
return 1
except:
return 0
def rm_audio():
'''
Remove o arquivo audio.mp3.
'''
try:
os.system('rm audio.mp3')
return 1
except:
return 0
def typing_effect(texto):
'''
Produz o efeito de digitação.
'''
try:
for letra in texto:
print(letra, end='', flush=True)
time.sleep(0.09)
return 1
except:
return 0