Problema con variabile

di il
1 risposte

Problema con variabile

Ciao a tutti, volevo chiedere un info su un programma che sto scrivendo:
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.response_selection import get_first_response
from chatterbot.comparisons import levenshtein_distance
from gtts import gTTS
import subprocess

import logging

logging.basicConfig(level=logging.CRITICAL)


bot = ChatBot(
"compare",
storage_adapter = "chatterbot.storage.SQLStorageAdapter",
database = "./db.sqlite3",
logic_adapters = [
"chatterbot.logic.BestMatch"
],
statement_comparison_function = levenshtein_distance,
response_selection_method = get_first_response
)

with open("inzio.txt") as f:
conversation = f.readlines()
trainer = ListTrainer(bot)
trainer.train(conversation)

while True:
try:
user_input = input("Tu: ")
bot_response = bot.get_response(user_input)
print("Chappie: ", bot_response)
text = (bot_response)
tts = gTTS(text=text, lang='it')
tts.save("tts_output_audio.mp3")
playsound.playsound('tts_output_audio.mp3', True)
except(KeyboardInterrupt, EOFError, SystemExit):
print("ciao")
break
qui:

text = (bot_response)
tts = gTTS(text=text, lang='it')
tts.save("tts_output_audio.mp3")

non funziona, mi segnala un errore della libreria, se metto su text="prova", allora funziona, ma io voglio che prende la risposta



errore è: File "C:\Users\matteo\AppData\Local\Programs\Python\Python39\lib\site-packages\gtts\tts.py", line 165, in _tokenize
text = text.strip()
AttributeError: 'tuple' object has no attribute 'strip'


la libreria va in errore

1 Risposte

Devi accedere o registrarti per scrivere nel forum
1 risposte