Не работает код с использованием PYTTSX3 и SpeechRecognition

помогите решить проблему. Установил библиотеки pyttsx3, apiai, request и speech_recognition. До установки speech_recognition код работал нормально и при вводе любого запроса на сервера dialogflow pyttsx3 произносил ответ. Сейчас он почему то перестал произносить ответ. Вот код:

import apiai
import json
import requests
import pyttsx3
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone(device_index=1) as source:
    print('Скажите что нибудь')
    audio = r.listen(source)

voice = r.recognize_google(audio, language= 'ru-RU')
print('Вы сказали: ' + voice.lower())
engine = pyttsx3.init()
voices = engine.getProperty('voices')
#engine.setProperty('voice', voices[4].id)
ip = requests.get('https://ramziv.com/ip').text
sound = voice.lower
def send_message(message):
    request = apiai.ApiAI('0e141f1ab3614b20a967c1101753e25e').text_request()
    request.lang = 'ru'
    request.session_id = ip
    request.query = sound
    response = json.loads(request.getresponse().read().decode('utf-8'))
    print(response['result']['fulfillment']['speech'])
    engine.say(response['result']['fulfillment']['speech'])
    engine.runAndWait()
    return response ['result']['action']

print('Введите свое сообщение сюда или напишите exit')
#message = input('>>')
action = None
#while True:
 #   action = send_message(message)
  #  if action == 'smalltalk.greetings.bye':
   #     break
    #message = input('>>')

Помогите пожалуйста как можно скорее


Ответы (0 шт):