awacke1 commited on
Commit
a08b1c9
1 Parent(s): 3064bde

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py CHANGED
@@ -38,6 +38,8 @@ from langchain.chains import ConversationalRetrievalChain
38
  from templates import css, bot_template, user_template
39
  from io import BytesIO
40
 
 
 
41
 
42
  # page config and sidebar declares up front allow all other functions to see global class variables
43
  st.set_page_config(page_title="AI Human Body - Homunculus Body Reasoner", layout="wide")
@@ -54,6 +56,39 @@ with col1:
54
  # Define a context dictionary to maintain the state between exec calls
55
  context = {}
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  def create_file(filename, prompt, response, should_save=True):
58
  if not should_save:
59
  return
 
38
  from templates import css, bot_template, user_template
39
  from io import BytesIO
40
 
41
+ import streamlit.components.v1 as components # Import Streamlit Components for HTML5
42
+
43
 
44
  # page config and sidebar declares up front allow all other functions to see global class variables
45
  st.set_page_config(page_title="AI Human Body - Homunculus Body Reasoner", layout="wide")
 
56
  # Define a context dictionary to maintain the state between exec calls
57
  context = {}
58
 
59
+ def SpeechSynthesis(result):
60
+ documentHTML5='''
61
+ <!DOCTYPE html>
62
+ <html>
63
+ <head>
64
+ <title>Read It Aloud</title>
65
+ <script type="text/javascript">
66
+ function readAloud() {
67
+ const text = document.getElementById("textArea").value;
68
+ const speech = new SpeechSynthesisUtterance(text);
69
+ window.speechSynthesis.speak(speech);
70
+ }
71
+ </script>
72
+ </head>
73
+ <body>
74
+ <h1>🔊 Read It Aloud</h1>
75
+ <textarea id="textArea" rows="10" cols="80">
76
+ '''
77
+ documentHTML5 = documentHTML5 + result
78
+ documentHTML5 = documentHTML5 + '''
79
+ </textarea>
80
+ <br>
81
+ <button onclick="readAloud()">🔊 Read Aloud</button>
82
+ </body>
83
+ </html>
84
+ '''
85
+
86
+ components.html(documentHTML5, width=1280, height=1024)
87
+ #return result
88
+
89
+
90
+
91
+
92
  def create_file(filename, prompt, response, should_save=True):
93
  if not should_save:
94
  return