Interfacing LIVE SPEECH with Tkinter GUI

时光怂恿深爱的人放手 提交于 2019-12-02 06:35:43

问题


I want to interface pocketsphinx livespeech with Python tkinter GUI in such a way that GUI is visible on frontend and Livespeech works on Back-end.But when i merge tkinter code with livespeech code; livespeech code always runs first and GUI not shows till i stop the code;so i won't be able to perform my required task..,

    #*********************************** IMPORTING MODULES*****************
import tkinter
from tkinter import*
import tkinter.messagebox
import sqlite3
import os
from pocketsphinx import LiveSpeech, get_model_path


conn = sqlite3.connect('portal.db')
c = conn.cursor()

window = tkinter.Tk()
window.title("Smart Notice Board")

top = Canvas(window,width=400,height=200)
top.pack(fill=X)

def portal():
    print("2")

button_5 = Button(text='PORTAL SYSTEM', height = 2, width=17, activebackground = '#33B5e5', bg = 'brown', fg = 'white',command  = portal )
top.create_window(80,80, anchor='nw', window = button_5) 

#****************  TEXT TO SPEECH CODE***************

model_path = get_model_path()

speech = LiveSpeech(
    verbose=False,
    sampling_rate=16000,
    buffer_size=2048,
    no_search=False,
    full_utt=False,
    hmm=os.path.join(model_path, 'en-us'),
    lm=os.path.join(model_path, '8582.lm'),
    dic=os.path.join(model_path, '8582.dict')
)

for phrase in speech:
    print(phrase)
    a=str(phrase)
    if a == "HOME":
        print('ok')
        portal()
        print('1')

results are attached below; Only live speech runs

GUI opens when code exit

来源:https://stackoverflow.com/questions/56820304/interfacing-live-speech-with-tkinter-gui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!