Hell0各位,我正在使用CloudSpeechAPI,在麦克风的帮助下,我得到了一个口语输出,作为python文件中的输出。我想将此输出用作java文件的输入。有没有办法将python的输出链接为java文件的输入
import os
import aiy.audio
import aiy.cloudspeech
import aiy.voicehat
def main():
recognizer = aiy.cloudspeech.get_recognizer()
button = aiy.voicehat.get_button()
led = aiy.voicehat.get_led()
aiy.audio.get_recorder().start()
while True:
print('Press the button and speak')
button.wait_for_press()
print('Listening...')
text = recognizer.recognize()
if text is None:
print('Sorry, I did not hear you.')
else:
if 'goodbye' in text:
os._exit(0)
text = recognizer.recognize()
print('You said "', text, '"')
if __name__ == '__main__':
main()
在本文中,我希望将文本输出用作java程序中的输入
您不清楚Java程序通常如何接受文本,但这里有两种可能的解决方案:
subprocess
模块启动它,并将字符串作为命令行参数传递李>相关问题 更多 >
编程相关推荐