简体   繁体   English

Pyintaller 可执行文件打印出不需要的东西,例如 SpeechRecognition JSON

[英]Pyintaller executable print out unwanted stuff like SpeechRecognition JSON

I use Pyinstaller to create executable.我使用 Pyinstaller 创建可执行文件。 In my program I use SpeechRecognition after I ran the program it prints out a JSON file (from API response) which normally my program not print anything.在我的程序中,我在运行程序后使用 SpeechRecognition,它打印出一个 JSON 文件(来自 API 响应),通常我的程序不打印任何内容。

for example it print out this one that don't want it to例如它打印出这个不想要它的

result2: { 'alternative': [ {'confidence': 0.97219545, 'transcript': 'hello world'}, {'transcript': 'helloworld'}], 'final': True}

btw I use pyinstaller --onefile filename.py to make exe file.顺便说一句,我使用pyinstaller --onefile filename.py来制作 exe 文件。 I didnt use --windowed because when I tried it not found sys.stdout module我没有使用--windowed因为当我尝试它时找不到 sys.stdout 模块

Tried to find something in SpeechRecognition module and found out the result2 JSON may come from this.试图在 SpeechRecognition 模块中找到一些东西,发现 result2 JSON 可能来自这个。

It's a problem with speech_recognition.这是 speech_recognition 的问题。 Sorry, this should have been a comment, but apparently I don't have enough reputation to comment, only to answer...对不起,这应该是评论,但显然我没有足够的声誉来评论,只能回答......

I've found multiple questions like these and I don't understand why they're being downvoted, but it's the recognize_google function that is printing that "result2".我发现了多个这样的问题,我不明白为什么他们被否决了,但打印“result2”的是 recognize_google function。 If you're storing the result in a variable, the result is fine (as in, it only contains the words you want, not the rest).如果您将结果存储在变量中,则结果很好(例如,它只包含您想要的词,而不包含其余词)。

You can fix this by downgrading to speech_recognition 3.8.1.您可以通过降级到 speech_recognition 3.8.1 来解决此问题。 That's the only answer I found so far.这是迄今为止我找到的唯一答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM