Gopikanth123 commited on
Commit
76bd650
·
verified ·
1 Parent(s): 667a767

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -17,7 +17,7 @@ speech_recognition_html = """
17
  var transcript = event.results[event.resultIndex][0].transcript;
18
  document.getElementById('output').textContent = transcript;
19
  // Send transcript back to Streamlit using postMessage
20
- window.parent.postMessage({func: 'update_output', transcript: transcript}, '*');
21
  };
22
 
23
  recognition.onerror = function(event) {
@@ -45,4 +45,8 @@ output = st.empty()
45
 
46
  # The Streamlit component listens for the postMessage event and updates the output
47
  st.write("Recognized Text:")
 
 
48
  transcript = st.text_area("Transcript:", "", height=150)
 
 
 
17
  var transcript = event.results[event.resultIndex][0].transcript;
18
  document.getElementById('output').textContent = transcript;
19
  // Send transcript back to Streamlit using postMessage
20
+ window.parent.postMessage(JSON.stringify({func: 'update_output', transcript: transcript}), '*');
21
  };
22
 
23
  recognition.onerror = function(event) {
 
45
 
46
  # The Streamlit component listens for the postMessage event and updates the output
47
  st.write("Recognized Text:")
48
+
49
+ # In Streamlit, we capture the transcript message sent via postMessage
50
  transcript = st.text_area("Transcript:", "", height=150)
51
+
52
+ # You can handle the `postMessage` event by using the `streamlit.components.v1` methods for client-server interaction.