Simulate a key enter i.e return in a textbox

Hi Gradio experts,
I have simple example of a chatbot that can accept text input but also using audio(source=microphone). I have managed that after the recording the textbox of the user message is filled with the transcribe text. If enter manually a return then its ok. But it would be more user friendly if the audio is transcibted into the textbox it automatically submit i.e simulatie a key stroke with a ENTER/Return. I did try using a change event on the textbox and as a function print(chr(13)) but that does not work(no effect)

Thanks in advance.

mycode is:

def enterReturn():
return chr(13)

def clear_audio():
return None

def voice_to_text(voice_file, language=‘nl’):
print(voice_file)
audio_file= open(voice_file, “rb”)
with open(voice_file, “rb”) as audio_file:
transcript = openai.Audio.transcribe(
file = audio_file,
model = “whisper-1”,
response_format=“text”,
language=language
)
print(‘lang:’,lang)
return transcript

block = gr.Blocks(theme=gr.themes.Default(primary_hue=gr.themes.colors.green, secondary_hue=gr.themes.colors.blue))

with block:
gr.Markdown(“”“

test speech to text


“””)
chatbot = gr.Chatbot()
lang_choices = gr.Dropdown([‘nl’, ‘de’, ‘en’,‘fr’,‘id’,‘bn’,‘hi’,‘it’],interactive=True, value=‘nl’, label=‘Languages’)
with gr.Row():
msg = gr.Textbox(label=‘Question’,interactive=True)
with gr.Row():
audio_src=gr.Audio(source=“microphone”,type=“filepath”,autoplay=False)
audio_src.stop_recording(fn = voice_to_text,
inputs = [audio_src,lang_choices],
outputs = [msg])
btn= gr.Button(“clear”)
btn.click(lambda :None, None, audio_src)
with gr.Row():
clear = gr.Button(‘Clear’)
def user(user_message, history):
print(history + [[user_message, None]])
return “”, history + [[user_message, None]]

def bot(message,history):
    print('message','history: ',message, history)
    response = message[len(message)-1][0] #history[len(history)-1][0]
    bot_message = response 
    message[-1][1] = ""
    for character in bot_message:
        message[-1][1] += character
        time.sleep(0.05)
        yield message
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False, show_progress=True).then(
    bot, [chatbot,lang_choices], chatbot
)
clear.click(lambda: None, None, chatbot, queue=False)

block.queue().launch(debug = True,share=False)