Can't convert tuple to string what can I do?

can synonym
can definition
can y
can verb
cant
can.'' acronym
can noun meaning
can't

I am trying to turn to out_chars from tuple to string. However, it seems quite troublesome since there is while loop and the state defined its to be tuple. What should I do

I try def convertString but not succesful

out_chars = []        
string = ()
for i, char_token in enumerate(computer_response_generator):
    out_chars.append(chars[char_token])
    print(possibly_escaped_char(out_chars), end='', flush=True)
    states = forward_text(net, sess, states, relevance, vocab, chars[char_token])
    if i >= max_length: 
        break
    states = forward_text(net, sess, states, relevance, vocab, sanitize_text(vocab, "\n> "))
    states = convertTuple(states)
    string = convertTuple(out_chars)
    print(Text_to_sp(string, states))

Traceback (most recent call last):

  File "/Users/quanducduy/anaconda3/chatbot-rnn-master/chatbot.py", line 358, in <module>
    main()
  File "/Users/quanducduy/anaconda3/chatbot-rnn-master/chatbot.py", line 44, in main
    sample_main(args)
  File "/Users/quanducduy/anaconda3/chatbot-rnn-master/chatbot.py", line 92, in sample_main
    args.relevance, args.temperature, args.topn, convertTuple)
  File "/Users/quanducduy/anaconda3/chatbot-rnn-master/chatbot.py", line 169, in chatbot
    print(Text_to_sp(string, states))
  File "/Users/quanducduy/anaconda3/chatbot-rnn-master/Text_to_speech.py", line 28, in Text_to_sp
    myobj.save("welcome.mp3")
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gtts/tts.py", line 249, in save
    self.write_to_fp(f)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gtts/tts.py", line 182, in write_to_fp
    text_parts = self._tokenize(self.text)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gtts/tts.py", line 144, in _tokenize
    text = text.strip()
AttributeError: 'tuple' object has no attribute 'strip'
Process finished with exit code 1

what does your tuple contains?? does it contain complex objects or simple strings numbers etc??? your problem is hard to understand from what you have posted above. but if you want o convert tuple to string you can do like this

 new_str = ''.join(yourtuple)

Verb Can, can meaning: 1. to be able to: 2. used to say that you can and will do something: 3. to be allowed to: . Learn more. Can definition, to be able to; have the ability, power, or skill to: She can solve the problem easily, I'm sure. See more.

I'm not sure that understand your question right, but if you want to make a string from tuple, its really simple.

def convertTuple(tup): 
    str =  ''.join(tup) 
    return str

tuple = ('g', 'e', 'e', 'k', 's') 
str = convertTuple(tuple) 
print(str) 

May I? Can I? - English Grammar - English, VerbEdit. can (third-person singular simple present can, present participle -, simple past could, past participle (obsolete except in adjectival use) couth). Define can. can synonyms, can pronunciation, can translation, English dictionary definition of can. to be able to, have the power or skill to: I can take a bus to the

If you cannot ensure all the elements of the tuple are strings, you have to cast them.

''.join([str(elem) for elem in myTuple])

CAN (noun) definition and synonyms, Can may refer to: Contents. 1 Containers; 2 Music; 3 Other; 4 See also. Containers[edit]. Aluminum can · Drink can · Oil can · Steel and tin cans · Trash can  110 synonyms of can from the Merriam-Webster Thesaurus, plus 97 related words, definitions, and antonyms. Find another word for can. Can: to bring (as an action or operation) to an immediate end.

Use can in a sentence, Can was the leading avant-garde rock group of the 70s. Can experimented with noise, synthesizers, non-traditional music, cut-and-paste techniques, and, most  A Controller Area Network (CAN bus) is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate with each other's applications without a host computer. It is a message-based protocol , designed originally for multiplex electrical wiring within automobiles to save on copper, but can also be used in many other

Can, 1.4Used to indicate that something is typically the case. 'antique clocks can seem out of place in modern homes'. More example sentences. Looking for online definition of CAN or what CAN stands for? CAN is listed in the World's largest and most authoritative dictionary database of abbreviations and acronyms The Free Dictionary

CAN, can. (kæn). n. 1. a container, esp for liquids, usually of thin sheet metal: a petrol can;  Can(stylised as CAN) was a German experimental rockband formed in Colognein 1968 by the core quartet of Holger Czukay(bass, tape editing), Irmin Schmidt(keyboards), Michael Karoli(guitar), and Jaki Liebezeit(drums).

Comments
  • It would be helpful if you show us an example of what consists out_chars and also the function convertTuple. Otherwise, only wild guesses. At this point, you are passing a tuple to the Text_to_sp, which apparently expects a string.