from gtts import gTTS
import random
import time
import playsaund
def say_message(message):
print(message)
vfile = gTTS(message, lang="ru")
file_name = str("_audio_" + "golos" + str(time.time()) + "_" + str(random.randint(0, 10000)) + ".mp3")
vfile.save(file_name)
playsound.playsound(file_name)
def lislisten_command():
return input("Скажите вашу команнду: ")
def do_this_command(message):
message = message.lower()
if "привет" in message:
say_message("Привет друг")
elif "пока" in message:
say_message("Пока")
exit()
else:
say_message("Данной команды не существует!")
while True:
command = lislisten_command()
do_this_command(command)
C:\Users\Дом\Desktop\Py>golos.py
Скажите вашу команнду: привет
Привет друг
Traceback (most recent call last):
File "C:\Users\Дом\Desktop\Py\golos.py", line 33, in <module>
do_this_command(command)
File "C:\Users\Дом\Desktop\Py\golos.py", line 23, in do_this_command
say_message("Привет друг")
File "C:\Users\Дом\Desktop\Py\golos.py", line 12, in say_message
playsound.playsound(file_name)
AttributeError: 'function' object has no attribute 'playsound'
C:\Users\Дом\Desktop\Py>