awacke1 commited on
Commit
6a989f3
1 Parent(s): ff16fff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py CHANGED
@@ -473,6 +473,37 @@ def extract_urls(text):
473
  return ''
474
 
475
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
476
 
477
  def display_terms_with_links(terms):
478
  """Display terms with various search links."""
 
473
  return ''
474
 
475
 
476
+ # HTML5 based Speech Synthesis (Text to Speech in Browser)
477
+ @st.cache_resource
478
+ def SpeechSynthesis(result):
479
+ documentHTML5='''
480
+ <!DOCTYPE html>
481
+ <html>
482
+ <head>
483
+ <title>Read It Aloud</title>
484
+ <script type="text/javascript">
485
+ function readAloud() {
486
+ const text = document.getElementById("textArea").value;
487
+ const speech = new SpeechSynthesisUtterance(text);
488
+ window.speechSynthesis.speak(speech);
489
+ }
490
+ </script>
491
+ </head>
492
+ <body>
493
+ <h1>🔊 Read It Aloud</h1>
494
+ <textarea id="textArea" rows="10" cols="80">
495
+ '''
496
+ documentHTML5 = documentHTML5 + result
497
+ documentHTML5 = documentHTML5 + '''
498
+ </textarea>
499
+ <br>
500
+ <button onclick="readAloud()">🔊 Read Aloud</button>
501
+ </body>
502
+ </html>
503
+ '''
504
+ components.html(documentHTML5, width=1280, height=300)
505
+
506
+
507
 
508
  def display_terms_with_links(terms):
509
  """Display terms with various search links."""