Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Update app.py
Browse files
    	
        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.
         |