My code is:
import wx
import wx.adv
import os
import threading
class MyPanel(wx.Panel):
def __init__(self, parent, id):
wx.Panel.__init__(self, parent, id)
self.SetBackgroundColour("white")
gif_fname = wx.adv.Animation("edza_face.gif")
gif = wx.adv.AnimationCtrl(self, id, gif_fname, pos=(1, 1))
gif.GetAnimation()
self.gif = gif
self.Show()
bmp = wx.Bitmap("microphone.png", wx.BITMAP_TYPE_ANY)
self.button = wx.BitmapButton(self, id=wx.ID_ANY, bitmap=bmp,
size=(bmp.GetWidth() + 10,
bmp.GetHeight() + 10), pos=(500, 300))
self.button.Bind(wx.EVT_BUTTON, self.onButton)
self.gif.Stop()
def onButton(self, event):
def b():
self.gif.Play()
p2 = threading.Thread(target=os.system('espeak "hello a b c d e
h i j"'), args=(10, 10))
p1 = threading.Thread(target=b(), args=(0, 10))
# starting process 1
p1.start()
# starting process 2
p2.start()
# wait until process 1 is finished
p1.join()
# wait until process 2 is finished
p2.join()
if __name__ == "__main__":
app = wx.App()
frame = wx.Frame(None,
pos=wx.DefaultPosition, size=wx.Size(1000, 600),
style=wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION |
wx.CLOSE_BOX | wx.CLIP_CHILDREN,
title="v3.0-beta")
frame.SetIcon(wx.Icon("icons8-mind-map-48.ico"))
MyPanel(frame, -1)
frame.Show(True)
app.MainLoop()
I am working on a chatbot and I want a gif to start playing with the spoken text(espeak). I want the GIF and sound to start at the exact same time. But the GIF begins to play only after the entire phrase is spoken(tts espeak). How do I get both of the start together and if possible end at the same time too. I am using Python3, wxPython Phoenix, and espeak(using os.system)
Please Help