0

I'm working in a python translator, so first of all I need to know the language and what does it have to translate, the translator will recognise phrases that are like How do you say spaguetti in french (for example). For gettig the language (last word) and the content (from fourth to last) and sent it to my function that need (the text, the language) i've done this:

tts.talk(translator(' '.join(phrase.split()[3:-2]), phrase.split()[-1]))

tts.talk is just a tts service that speech the translation. When I try this I get this error:

TypeError: 'module' object is not callable

I've tried to store ' '.join(phrase.split()[3:-2] and phrase.split()[-1] as variables and then include them, but id doesn't work anyway. What should I do?

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304

1 Answers1

0

How to trouble shoot code?

tts.talk(translator(' '.join(phrase.split()[3:-2]), phrase.split()[-1]))

break it into parts!

part1 = ' '.join(phrase.split()[3:-2])
part2 = phrase.split()[-1]
translated = translator(part1,part2)
talked = tts.talk(translated)

this is not an answer but more a tutorial on how to trouble shoot...

now figure out where it breaks and use the full traceback not just the final line

Joran Beasley
  • 110,522
  • 12
  • 160
  • 179