长按(python)录音键播放语音

Long Press (python) record button and play voice

我有一个按钮,我想用一个按钮触发两个动作。我 不知道,要用长按呼叫一个class speak

try several ways but none please help me

def speak():
tts.save(filename)
   playsound.playsound(filename)
speak()
name = driver.find_element_by_xpath(element)
TouchAction.long_press(name, duration=3000).perform().release()???

你可以这样做:

def do_two_things():
    do_this()
    do_that_too()

def do_this():
    # do this thing

def do_that_too():
    # yes, do that too!

...
TouchAction.long_press(name, duration=3000).do_two_things()