abdulazeezoj commited on
Commit
8d6d690
1 Parent(s): d513ed6

Add speech output

Browse files
Files changed (1) hide show
  1. src/web.py +14 -3
src/web.py CHANGED
@@ -2,6 +2,8 @@ import os
2
  import sys
3
  import pathlib
4
  import gradio as gr
 
 
5
 
6
  # Add Osanyin to the path
7
  sys.path.insert(0, str(pathlib.Path(__file__).parent.parent))
@@ -31,7 +33,12 @@ def bot(history):
31
  "Sorry, I don't know that.",
32
  )
33
 
34
- # Check if the answer is about out of context
 
 
 
 
 
35
 
36
  # Update the history
37
  history[-1][1] = answer
@@ -40,14 +47,18 @@ def bot(history):
40
 
41
 
42
  with gr.Blocks(title="Alaroye") as demo:
43
- chatbot = gr.Chatbot([], elem_id="chatbot", label="Alaroye").style(height=750)
44
 
45
  with gr.Row():
 
46
  with gr.Column(scale=0.85):
47
  txt = gr.Textbox(
48
  show_label=False,
49
  placeholder="Enter text and press enter, or upload an image",
50
- ).style(container=False)
 
 
 
51
  with gr.Column(scale=0.15, min_width=0):
52
  btn = gr.Button(value="Send")
53
 
 
2
  import sys
3
  import pathlib
4
  import gradio as gr
5
+ import threading
6
+
7
 
8
  # Add Osanyin to the path
9
  sys.path.insert(0, str(pathlib.Path(__file__).parent.parent))
 
33
  "Sorry, I don't know that.",
34
  )
35
 
36
+ # Speak the answer in a separate thread
37
+ def speak_answer():
38
+ alaroye._speak(answer)
39
+
40
+ speak_thread = threading.Thread(target=speak_answer)
41
+ speak_thread.start()
42
 
43
  # Update the history
44
  history[-1][1] = answer
 
47
 
48
 
49
  with gr.Blocks(title="Alaroye") as demo:
50
+ chatbot = gr.Chatbot([], elem_id="chatbot", label="Alaroye", height=750)
51
 
52
  with gr.Row():
53
+ # Column for text input
54
  with gr.Column(scale=0.85):
55
  txt = gr.Textbox(
56
  show_label=False,
57
  placeholder="Enter text and press enter, or upload an image",
58
+ container=False,
59
+ )
60
+
61
+ # Column for button
62
  with gr.Column(scale=0.15, min_width=0):
63
  btn = gr.Button(value="Send")
64