第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

從用戶輸入在 python 中循環(huán)

從用戶輸入在 python 中循環(huán)

大話西游666 2022-08-02 18:15:37
我試圖讓一個(gè)python文本到語音程序無限運(yùn)行,直到用戶決定退出,任何幫助將不勝感激這是我的代碼:# IMPORTimport gtts as gTTSimport os # TTSmyText = input("Enter your text: ")language = 'en'output = gTTS.gTTS(text=myText,, slow=False,)output.save("output.mp3")os.system("start output.mp3")# Restartdef get_answer(prompt):    answer = input(prompt)    # 1 while not (answer == "yes" or answer == "no"    # 2 while answer not in ("yes", "no"):    # 3 while answer not in ["yes", "no"]:    while answer not in ("yes", "no"):        answer = input(prompt)    return answerprint(get_answer("yes or no? "))
查看完整描述

1 回答

?
繁花不似錦

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超4個(gè)贊

# IMPORT

import gtts as gTTS

import os 


# FUNCTIONS

def get_answer(prompt):

    answer = input(prompt)

    # 1 while not (answer == "yes" or answer == "no"

    # 2 while answer not in ("yes", "no"):

    # 3 while answer not in ["yes", "no"]:

    while answer not in ("yes", "no"):

        answer = input(prompt)

    return answer


# TTS

while True:

    myText = input("Enter your text: ")


    language = 'en'


    output = gTTS.gTTS(text=myText,, slow=False,)



    output.save("output.mp3")


    os.system("start output.mp3")


    # Restart

    if get_answer("quit (yes or no?): ") == yes: break #break out of the loop


查看完整回答
反對(duì) 回復(fù) 2022-08-02
  • 1 回答
  • 0 關(guān)注
  • 133 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)