SPEECH TO TEXT PROGRAM KIVY

Please if you like my content Please 
do not forget to support this 
channel on
 PayPal now for $1 only! Or less 

from kivy.properties import ObjectProperty, StringProperty, NumericProperty

import functools
import os.path
import json
import pickle
import speech_recognition as sr
from kivy.app import App
from kivy.lang.builder import Builder
from kivy.uix.widget import Widget
from kivy.uix.textinput import TextInput
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.uix.label import Label

screenmanager = """

ScreenManager:
FirstScreen:



<FirstScreen>:



name: 'first'
RelativeLayout:
orientation:'vertical'
pos: self.pos
size: root.size
id: test2

Label:
text: 'Welcome to Speech To Text Program Kivy!'
pos_hint: {'center_x': 0.5, 'center_y':0.905}
font_size: (self.height/15)* 0.75


Label:
text:'Press Record Button To Record Your Speech To Text!'
pos_hint:{'center_x':0.5, 'center_y': 0.705}
font_size: (self.height/15)* 0.65

Button:
text:'Record'
size_hint: .3, .1
pos_hint:{'center_x':0.47, 'center_y': 0.505}
on_press: root.record()


TextInput:
id: totext
pos_hint:{'center_x':0.47, 'center_y': 0.305}
size_hint: 0.6, 0.2














"""


class Switch(App):

def build(self):
screen = Builder.load_string(screenmanager)
return screen


class FirstScreen(Screen):
def record(self):
r = sr.Recognizer()

try:

# use the microphone as source for input.
with sr.Microphone() as source2:

# wait for a second to let the recognizer
# adjust the energy threshold based on
# the surrounding noise level
r.adjust_for_ambient_noise(source2, duration=0.2)

# listens for the user's input
audio2 = r.listen(source2)

# Using google to recognize audio
MyText = r.recognize_google(audio2)
MyText = MyText.lower()

self.ids.totext.text = str(MyText)


except sr.RequestError as e:
print("Could not request results; {0}".format(e))

except sr.UnknownValueError:
print("unknown error occured")




sm = ScreenManager()
sm.add_widget(FirstScreen(name='first'))


Switch().run()

No comments:

Post a Comment

Drawing App For Kivy

  Below here is the source code for Drawing Application for kivy. Please if you like this content.  Don't forget to Subscribe to my YouT...