Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kivy上的Python SpeechRecognition应用程序在使用buildozer部署到android上后无法工作_Python_Android_Python 3.x_Kivy_Speech Recognition - Fatal编程技术网

Kivy上的Python SpeechRecognition应用程序在使用buildozer部署到android上后无法工作

Kivy上的Python SpeechRecognition应用程序在使用buildozer部署到android上后无法工作,python,android,python-3.x,kivy,speech-recognition,Python,Android,Python 3.x,Kivy,Speech Recognition,我对这款Kivy和语音识别还不熟悉。 实际上,我正在为语音识别构建一个Kivy。 语音识别在我的pc上运行得很好,但在android应用程序中,当我点击speak按钮时,它就会崩溃 下面显示的是我所写的代码 from kivy.app import App from kivy.uix.screenmanager import ScreenManager, Screen from kivy.clock import Clock, mainthread import speech_recogniti

我对这款Kivy和语音识别还不熟悉。 实际上,我正在为语音识别构建一个Kivy。 语音识别在我的pc上运行得很好,但在android应用程序中,当我点击speak按钮时,它就会崩溃

下面显示的是我所写的代码

from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.clock import Clock, mainthread
import speech_recognition as sr
 
class Principal(Screen):
    def Btnclick(self):
        self.ids.lblMessage.text = "Say something!"
        Clock.schedule_once(lambda d: self.GetAudio(), 0)
 
    def GetAudio(self):
        r = sr.Recognizer()
        with sr.Microphone() as source:
            r.adjust_for_ambient_noise(source,duration=1)
            audio = r.listen(source)
        self.audio = audio
        try:
            self.ids.lblMessage.text = "Google Speech Recognition thinks you said " + r.recognize_google(audio, language = 'en-us')
        except sr.UnknownValueError:
            self.ids.lblMessage.text = "Google Speech Recognition could not understand audio"
        except sr.RequestError as e:
            self.ids.lblMessage = "Could not request results from Google Speech Recognition service; {0}".format(e)
 
class testspkApp(App):
 
    def build(self):
        sm = ScreenManager()
        self.sm = sm
        sm.add_widget(Principal(name='Principal'))
        return sm
 
    def on_pause(self):
        return False
 
 
if __name__ == "__main__":
    main = testspkApp()
    main.run()
上述代码的.kv文件

<Principal>:
    id: HomeScreen
    BoxLayout:
        orientation: 'vertical'
        Button:
            text:'speak'
            on_release: root.Btnclick()
        Label:
            id: lblMessage
            text: 'Hello'
:
id:主屏幕
盒子布局:
方向:“垂直”
按钮:
文字:“说话”
发布时:root.Btnclick()
标签:
id:LBL消息
短信:“你好”
当我在自己的电脑上运行时,它工作得很好

我想用buildozer把它转换成我的android应用程序

在buildozer.spec文件中,我包括**需求=python3,kivy==2.0.0,SpeechRecognition,pyjnius**和Android规范**中的Android.permissions:互联网,录制音频**

在buildozer规范中,我已经定义了**log_level=2**

我是错过了什么还是出了什么差错? 因为语音识别在我的手机上不起作用


请帮助我,因为我正在为我的大学迷你项目制作此软件。

是否显示任何类型的错误?不,我没有收到任何错误要求可能缺失,pip3知道PC上的要求,但不知道Android上的要求。请参阅“需求”部分。如果您想知道缺少什么,请运行调试器。请记住,所有要求都必须是纯Python或有配方。谢谢@JackThreadfin因为你,我注意到我遗漏了什么,但还有一个问题,根据你为要求建议的链接,我使用SpeechRecognition作为麦克风,它需要pyaudio。因此,我已经安装了pyaudio,并决定将其添加到buildozer.spec文件的要求中。我收到错误,无法转换为android apk。是不是因为pyaudio不支持android apk?