Shcoder001

speech_rec

Apr 13th, 2023
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. import speech_recognition as sr
  2. from tkinter import *
  3.  
  4. window = Tk()
  5. window.title('Чат бот')
  6. window.geometry('800x500')
  7. label = Label(window, text='', font=('', 10))
  8. label.place(x=0, y=100)
  9.  
  10.  
  11. def speak():
  12.     r = sr.Recognizer()
  13.     with sr.Microphone() as source:
  14.         r.adjust_for_ambient_noise(source)
  15.         window.title('Скажите текст')
  16.         window.update()
  17.         data = r.record(source, duration=5)
  18.         text = r.recognize_google(data, language='ru')
  19.         label['text'] = text
  20.         window.title('Чат бот')
  21.  
  22.  
  23. Button(window, text='Начать говорить', command=speak).place(x=240, y=300)
  24.  
  25. window.mainloop()
  26.  
Advertisement
Add Comment
Please, Sign In to add comment