Я написал программу виртуального помощника, но программа не распознает мой голос и не отвечает. Пожалуйста, помогите мне

#python

Вопрос:

 import pyaudio  import speech_recognition as sr import os from gtts import gTTS import datetime import warnings import calendar import random import wikipedia  #To ignore any warning mesages warnings.filterwarnings('ignore')  #record audio and return it as string def recordAudio():   #Record the audio  r = sr.Recognizer() #creating a recognizer object   #open the microphone and start recording  with sr.Microphone() as source:  print('say something!')  audio = r.listen(source)   #Use googles speech recognition  data = ''  try:  data = r.recognize_google(audio)  print('You said: ' data)  except sr.UnknownValueError: #check for unknown errors   print('Sorry I didnt get you')  except sr.RequestError as e:  print('Request results from google speech recognition service error' e)   return data  # A function to get the virtual assistant's response  def assistantResponse(text):   print(text)   #convert the text to speech  myobj = gTTS(text=text, lang='en', slow=False)   #save the converted audio to a file  myobj.save('assistant_response.mp3')   #play the converted file  os.system('start assistant_response.mp3')  # a function for wake words for phrase def wakeWord(text):  WAKE_WORDS = ['butler']   text = text.lower() #converting all text to lower case   #Check to look for wake word  for phrase in WAKE_WORDS:  if phrase in text:  return True   #executed if wake word isn't found in the text from the loop  return False  # A function to get the current date def getDate():   now = datetime.datetime.now()  my_date = datetime.datetime.today()  weekday = calendar.day_name[my_date.weekday()] #eg Friday  monthNum = now.month  dayNum = now.day   # A list of months  month_names = ['January' , 'February', 'March', 'April' , 'May', 'June', 'July' , 'August', 'September', 'October' , 'November', 'December']    # A list of ordinal numbers  ordinalNumbers = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th', '11th', '12th','13th', '14th', '15th', '16th', '17th', '18th', '19th', '20th' '21st', '22nd', '23rd', '24th', '25th', '26th', '27th', '28th', '29th', '30th', '31st']   return 'Today is '  weekday  ' '  month_names[monthNum -1]   ' the '  ordinalNumbers[dayNum -1]   '.' #my code gives the wrong date this is the code foe tha day and date  # A function to return a random greeting response def greeting(text):   #greeting inputs  GREETING_INPUTS = ['hi', 'hey', 'hello there', 'wassup', 'greeting', 'namaste']   #greeting responses  GREETING_RESPONSES = ['hi sir', 'hello there sir', 'howdy', 'to infinity and beyond']   # if users input is a greeting, then give a response  for word in text.split():  if word.lower() in GREETING_INPUTS:  return random.choice(GREETING_RESPONSES)  '.'   #if no greeting was detected then return an empty string  return ''  # A function to get a person's first and last name from the text def getPerson(text):   wordList = text.split() #Splitting the text into words   for i in range(0, len(wordList)):  if i   3 lt;=len(wordList) - 1 and wordList[i].lower() == 'who' and wordList[i 1].lower() == 'is':  return wordList[i 2]   ' '  wordList[i 3]  while True:   #record the audio  text = recordAudio()  response = ''   #check for the wake word  if(wakeWord(text) == True):   #check for greetings by the user  response = response   greeting(text)   #check to see if the user said anything to have to do with the date  if('date' in text):  get_date=getDate()  response = response   ' '  get_date   #check if user says who is  if('who is' in text):  person = getPerson(text)  wiki = wikipedia.summary(person, sentences=2)  response = response  ' '  wiki   #ceck for time  if('time' in text):  now=datetime.datetime.now()  meridiem=''  if now.hour gt;=12:  meridiem = 'p.m'  hour = hour - 12  else:  meridiem = 'a.m'  hour=now.hour    #Check minute into proper string  if now.minute lt; 10:  minute = '0' str(now.minute)  else:  minute=str(now.minute)   response = response   ' '  'It is'  str(hour)  ':' minute  ' ' meridiem ' .'   #Have the assistant respond back using audio  assistantResponse(response)  
  1. Я использовал распознавание речи Google
  2. Мой код по какой-то причине указывает неправильную дату
  3. Программа вообще не улавливает мой голос, она улавливает мой голос только тогда, когда в комнате очень тихо
  4. Программа также не отвечает мне
  5. Есть ли какой-нибудь способ изменить голос на мужской?

Я относительно новичок в python и хотел что-то создать, поэтому я воспользовался помощью из учебника, теперь я понятия не имею, как это исправить. Помощь будет оценена по достоинству.

Спасибо