为什么python pyttsx3忽略我的第三个输入?



我试图让pyttsx3说文本,一个变量,然后更多的文本,但由于某种原因,它忽略了第三个输入,并移动到下一行文本。下面是代码:

elif "what is the weather" in query:
replaced_temp = temp.replace('F', '')
tts.say('In' + g.city, 'it is currently' + replaced_temp)
tts.runAndWait()
print("completed")

当我运行代码时,它说,"In "没有别的,它跳到下一行并打印完成。

我尝试过单独的tts。说几行,把演讲分成不同的部分,它是有效的,只是在代码行之间有大的停顿。

为什么不试试使用f-strings:

tts.say(f"In {g.city} it is currently {replaced_temp}")

相关内容

最新更新