awacke1 commited on
Commit
797a2a5
·
verified ·
1 Parent(s): d2899f8

Update mycomponent/__init__.py

Browse files
Files changed (1) hide show
  1. mycomponent/__init__.py +1 -33
mycomponent/__init__.py CHANGED
@@ -1,34 +1,2 @@
1
- import os
2
  import streamlit.components.v1 as components
3
-
4
- # Declare the component with a path to index.html
5
- mycomponent = components.declare_component(
6
- "mycomponent",
7
- path=os.path.dirname(os.path.abspath(__file__))
8
- )
9
-
10
- # Python function to interact with the component
11
- def speech_component(default_value=""):
12
- """
13
- A custom Streamlit component for continuous speech recognition.
14
-
15
- Args:
16
- default_value (str): Initial value to display in the input field.
17
-
18
- Returns:
19
- dict: The latest transcript data from the component.
20
- """
21
- # Pass the default value to the component and receive data back
22
- component_value = mycomponent(my_input_value=default_value, key="speech_component")
23
-
24
- # If no value is returned yet, return an empty dict
25
- if component_value is None:
26
- return {"value": ""}
27
-
28
- # Return the component value (expecting a dict with 'value' key)
29
- return component_value
30
-
31
- if __name__ == "__main__":
32
- # Test the component standalone
33
- value = speech_component("Say something...")
34
- st.write("Received from component:", value)
 
 
1
  import streamlit.components.v1 as components
2
+ mycomponent = components.declare_component("mycomponent",path="./mycomponent")