I am looking to build a speech recognition app for my android phone, but plyer's stt function does not work on my phone or my windows computer, but it's tts function does. Does anyone have a sample kivy speech recognition app that can run on both devices?
This is the code i am using now(which i got from [here][1]) but it crashes on my phone:
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 BtnEscuchar(self):
self.ids.lblMensaje.text = "Say something!"
Clock.schedule_once(lambda d: self.GetAudio(), 0)
def GetAudio(self):
r = sr.Recognizer()
with sr.Microphone() as source:
audio = r.listen(source)
self.audio = audio
try:
self.ids.lblMensaje.text = "Google Speech Recognition thinks you said " + r.recognize_google(audio,
language='es')
except sr.UnknownValueError:
print("I cannot hear what you said")
except sr.RequestError as e:
print("Error!")
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
main = testspkApp()
main.run()
i apologize in advance if i have made an obvious mistake: i am quite new to this stuff.
question from:
https://stackoverflow.com/questions/65599898/sample-speech-recogniton-kivy-android-app-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…