Python SpeechRecognition app on Kivy not working after deploying on android using buildozer

Viewed 507

I am new to this Kivy and speech recognition. Actually I am building a Kivy for speech recognition. speech recognition works finely in my pc but the in android app it Crashes when I click the speak button.

Below shown is the code what I have written

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()

The .kv file for the above code

<Principal>:
    id: HomeScreen
    BoxLayout:
        orientation: 'vertical'
        Button:
            text:'speak'
            on_release: root.Btnclick()
        Label:
            id: lblMessage
            text: 'Hello'

This works fine when I run on my own PC.

I wanted to convert it to my android app using buildozer.

In the buildozer.spec file I have included ** requirements = python3,kivy==2.0.0,SpeechRecognition,pyjnius** and in Android specification ** android.permissions: INTERNET,RECORD_AUDIO **

and in buildozer specification i have menctioned ** log_level = 2**

Am I missing something or Am I went somewhere wrong? Because the Speech Recognition is not working on my mobile

Please help me because I am building this for my college mini project.

0 Answers
Related