Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Voice Assistant/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from gtts import gTTS
import speech_recognition as sr


#function to listen the audio
def listen():
# obtain audio from the microphone
r = sr.Recognizer()
Expand All @@ -25,15 +25,15 @@ def listen():
return 'Error'



#function to say the text
def say(text):
voice = gTTS(text, lang = "ru")
unique_filename = "audio_" + str(random.randint(0, 100000)) + ".mp3"
voice.save(unique_filename)
playsound.playsound(unique_filename)
print("Assistant:", text)


#function to handle the message
def handle_message(message):
message = message.lower()
if "привет" in message:
Expand All @@ -44,7 +44,7 @@ def handle_message(message):
say("Я такой команды не знаю")



#finish function
def finish():
print("Пока")
exit()
Expand Down